Skip to content
Snippets Groups Projects
  1. Jul 12, 2017
    • Vladimir Davydov's avatar
      vinyl: zap include_deleted flag argument of vy_recovery_iterate · ea7af7f3
      Vladimir Davydov authored
      This flag is needed to skip records corresponding to dropped and
      incomplete runs on recovery, because given VY_LOG_CREATE_RUN the
      vy_recovery_iterate() callback can't tell if the run is used or
      going to be dropped. This flag needlessly complicates the code of
      vy_recovery_iterate(), which is supposed to simply replay all records
      recovered from the log, not try to be smart. Let's get rid of it and
      instead add a hint to vy_log_record indicating that a run created by
      VY_LOG_CREATE_RUN is going to be dropped.
      ea7af7f3
    • Vladimir Davydov's avatar
      vinyl: do not try to make index directory on truncate · 1b0aa562
      Vladimir Davydov authored
      vy_prepare_truncate_space() doesn't need to make directories for
      truncated indexes - they must already exist as the indexes were
      created. It just needs to create initial range for each of them.
      Factor out vy_index_init_range_tree() out of vy_index_create()
      and use it instead where appropriate.
      1b0aa562
    • Vladimir Davydov's avatar
      vinyl: refactor index recovery from vylog · 90fb2372
      Vladimir Davydov authored
      We have vy_recovery_lookup_index() function to look up an index in a
      recovery context by id and vy_recovery_iterate_index() to iterate over
      ranges, runs, and slices of a found index. vy_recovery_lookup_index()
      used to be a part of vy_recovery_iterate_index() and was factored out
      when index logging was moved to be called after WAL write, from
      vy_index_commit_create(), because during recovery we need to check if an
      index creation record was flushed to vylog before restart - currently we
      do it by trying to look it up in the recovery context.
      
      To stop using index lsn as vylog index id and remove lsn from index
      options, I'm planning to make the function loading an index from vylog
      advance an internal vylog counter so that the next time it is called it
      loads a newer incarnation of the same index. vy_recovery_lookup_index()
      doesn't fit this concept. So I introduce vy_recovery_load_index() that
      calls vy_recovery_lookup_index() and vy_recovery_iterate_index()
      internally and make the two functions private to vylog. To deal with
      indexes not logged due to vylog errors, I introduce a per index flag,
      vy_index->is_committed, which is set if the index record was flushed to
      vylog - the same approach is already used to handle index drop (see
      vy_index_commit_drop()).
      90fb2372
    • Roman Tsisyk's avatar
      Add comments to box_tuple_extract_key() · 6833e700
      Roman Tsisyk authored
      Closes #2535
      6833e700
    • Vladislav Shpilevoy's avatar
    • Alexandr Lyapunov's avatar
      vinyl: fix rollback of prepared TX · 87a2989b
      Alexandr Lyapunov authored
      Now if a prepared transaction is aborted, it expects to be the
      latest prepared TX in TX manager. It's not true in two cases:
      
      - The transaction failed during preparation. The TX is in partially
        prepared state and must rollback all the changes it made in mems
        but the preparation was not finished and thus the TX could not be
        considered as the latest in TX manager.
      
      - It's a cascading rollback with more than on TX. It would be
        graceful for the latest aborted TX to set the previous TX as
        the latest after the abortion. But the TX does not know the
        previous prepared TX and simply set to NULL appropriate pointer;
        when the time comes for the previous TX to be aborted it
        does not see itself as the latest.
      
      The TX must not expect itself to be the latest but must handle
      the last_prepared_tx pointer only if it is the latest.
      
      Fix it and add tests.
      
      Fix #2588 (case 1)
      Fix #2591 (case 2)
      87a2989b
  2. Jul 11, 2017
  3. Jul 10, 2017
    • Vladimir Davydov's avatar
      vinyl: get rid of vy_run_iterator->coio_read · eeb9a81e
      Vladimir Davydov authored
      Instead introduce vy_run_env_enable_coio(), which starts reader threads,
      and make vy_run_iterator automatically switch to coio if reader threads
      are running. With this patch, vy_read_iterator doesn't need a pointer to
      vy_env to add a run as a source, only vy_run_env.
      
      While we are at it, cleanup vy_conf a bit.
      
      Needed for #1906
      eeb9a81e
    • Vladimir Davydov's avatar
      vinyl: fix use-after-free of last_stmt in vy_run_write_page · 63f59df4
      Vladimir Davydov authored
      vy_run_write_page() doesn't take a reference to last_stmt, because it
      assumes that the write iterator guarantees it won't be deleted until
      'next' is called again. The iterator does pin a statement if it is read
      from a run file - see vy_write_iterator_set_tuple() - however there's a
      case when the last returned statement can go away under us. This will
      happen if the iterator is used for major compaction and the last source
      statement is a DELETE. In this case the iterator will unreference the
      last statement it returned to the caller, take a reference to the DELETE
      instead, but won't return the DELETE - see vy_write_iterator_next(). As
      a result, the caller, i.e. vy_run_write_page(), will hit use-after-free
      on an attempt to read last_stmt.
      
      To fix this bug, let's make vy_run_write_page() take a reference to
      last_stmt as it used to before the write iterator was reworked. A test
      case will be added later, after all iterator-related issues have been
      fixed.
      
      Closes #2578
      63f59df4
    • Georgy Kirichenko's avatar
      Add iconv support · aff6235c
      Georgy Kirichenko authored
      Iconv is a library to convert a sequence of characters in one
      character encoding to a sequence of characters in another character
      encoding. Example below converts utf-16 big endian string into utf-8
      string:
      
          convertor = require('iconv').new('UTF-16BE', 'UTF-8')
          converted_string = convertor(source_string)
      
      Closes #2587
      aff6235c
    • Vladimir Davydov's avatar
      vinyl: add missing mem_list_version increment · 3a73e5dc
      Vladimir Davydov authored
      vy_task_dump_new() deletes empty in-memory trees right away, but
      doesn't increment vy_index->mem_list_version, which may result in
      a read iterator crash accessing a deleted vy_mem.
      3a73e5dc
    • alyapunov's avatar
      Use open MP sort optimisation only for huge arrays · 2e864b5a
      alyapunov authored
      Now open MP sort is used for any size of an array.
      For small arrays it's an overkill and even can cause overhead
      due to thread pool creation.
      
      Invoke open MP sort only for big arrays and use old good
      single-thread qsort for small arrays.
      
      Fix #2431
      2e864b5a
    • Roman Tsisyk's avatar
      Fix logging of box.cfg.replication option · 6015e0df
      Roman Tsisyk authored
      Print original uri as is if it doesn't contain sensitive
      information.
      
      Closes #2292
      6015e0df
  4. Jul 09, 2017
  5. Jul 08, 2017
    • Vladimir Davydov's avatar
      vinyl: move read_set from vy_index to tx_manager · 56871b94
      Vladimir Davydov authored
      Needed to remove dependency of vy_index on struct txv.
      
      Needed for #1906
      56871b94
    • Konstantin Osipov's avatar
    • Georgy Kirichenko's avatar
      Altering a space takes effect immediately. · 8631ffb2
      Georgy Kirichenko authored
      Before this patch, the new space, created by alter specification,
      would be put into space cache only after successful WAL write.
      
      This behaviour is not linearizable: on a replica, the WAL is
      played sequentially, and the order of events could differ from the
      master.
      
      Besides, it could crash, as demonstrated in gh-2074 test case.
      
      Since we use a cascading rollback for all transactions on WAL
      write error, it's OK to put a space into space cache
      before WAL write, so that the new transactions apply to the new
      space.
      
      This patch does exactly that.
      
      All subsequent requests are executed against the new space.
      
      This patch also removes on_replace trigger in the old space, since
      all checks against the new tuple format are performed using the new
      space.
      
      Fixes #2074.
      8631ffb2
  6. Jul 07, 2017
  7. Jul 06, 2017
    • Konstantin Osipov's avatar
      alter: MoveIndex review fixes · 7b1028a4
      Konstantin Osipov authored
      * update comments
      * add a test case for altering a primary key on the fly
      * rename AddIndex to CreateIndex
      * factor out common code into a function
      7b1028a4
    • Georgy Kirichenko's avatar
      alter: introduce MoveIndex and RebuildIndex operations · 8c854d7f
      Georgy Kirichenko authored
      MoveIndex operation is used to move an existing index from the old space
      to the new one. Semantically it's a no-op.
      
      RebuildIndex is introduced for case when essential index properties are
      changed, so it is necessary to drop the old index and create a new one in
      its place in the new space.
      
      AlterSpaceOp::prepare() is removed: all checks are moved to
      on_replace trigger in _index system space from it.
      All checks are done before any alter operation is created.
      
      Necessary for gh-2074 and gh-1796.
      8c854d7f
    • alyapunov's avatar
      alter: move modify vs rebuild index check · 4c87d443
      alyapunov authored
      Move the check which decides on an alter strategy whenever
      a row in _index space is changed, from AlterSpaceOp::preapre()
      to on_replace trigger on _index space.
      
      The check chooses between two options: a heavy-weight index rebuild,
      invoked when index definition, such as key parts, is changed, vs.
      lightweight modify, invoked when index name or minor options are
      modified..
      
      Before this patch, index alteration creates a pair of operations
      (DropIndex + AddIndex) in all cases, but later
      replaces two operations with one at AlterSpaceOp::prepare() phase.
      
      This is bad by several reasons:
      
      - it's done while traversing of a linked list of operations,
        and it changes the list being traversed.
      
      - an order in the list of operations is required for this
      to work: drop must precede add.
      
      - needless allocation and deallocation of operations makes the logic
        unnecessarily complex.
      
      Necessary for gh-1796.
      4c87d443
Loading