Skip to content
Snippets Groups Projects
  1. Mar 28, 2019
    • Konstantin Osipov's avatar
      Speed up txn_is_distributed() check · 1f5cc898
      Konstantin Osipov authored
      Speed up txn_is_distributed() check by keeping track of the number of
      local rows of the transaction.
      1f5cc898
    • Konstantin Osipov's avatar
      Rename txn->{n_local_rows,n_remote_rows} · 204b2384
      Konstantin Osipov authored
      We need to keep count of different kind of rows in a transaction:
      - rows which already exist in some WAL and are replayed locally.
        These used to be called n_remote_rows, and renamed to n_applier_rows
      - rows which were created locally, on this server (previously called
        n_local_rows, renamed to n_new_rows).
      
      Of the latter, we need to distinguish between GROUP_ID=LOCAL rows,
      i.e. rows which need not be replicated, and GROUP_ID=REPLICA rows,
      which need to be replicated. For example, a remote transaction can
      fire local triggers which generate local rows. If these triggers
      generate rows which need to be replicated, the transaction has to be
      aborted.
      
      In a subsequent patch I plan to add n_local_rows, which tracks the
      number of new rows with GROUP_ID=local and use it in
      txn_is_distributed() check.
      204b2384
    • Georgy Kirichenko's avatar
      Raise an error if remote transaction produces non-local changes · 94468210
      Georgy Kirichenko authored
      Disallow changes for non-local spaces during replication stream
      applying. As we do not support distributed transaction yet we could not
      provide a transactional replication for such side effects if there are
      not NOPed.
      
      Needed for: #2798
      Follow up for: 27283deb
      94468210
  2. Mar 27, 2019
  3. Mar 11, 2019
    • Georgy Kirichenko's avatar
      txn: move rows without lsn to the transaction tail · 27283deb
      Georgy Kirichenko authored
      Form a separate transaction with local changes in case of replication.
      This is important because we should be able to replicate such changes
      (e.g. made within an on_replace trigger) back. In the opposite case
      local changes will be incorporated into originating transaction and
      would be skipped by the originator replica.
      
      Needed for #2798
      27283deb
  4. Nov 09, 2018
    • Mergen Imeev's avatar
      sql: return all generated ids via IPROTO · ef67de41
      Mergen Imeev authored
      According to documentation some JDBC functions have an ability to
      return all ids that were generated in executed INSERT statement.
      This patch gives a way to implement such functionality. After
      this patch all ids autogenerated during VDBE execution will be
      saved and returned through IPROTO.
      
      Closes #2618
      ef67de41
  5. Aug 01, 2018
    • Vladimir Davydov's avatar
      txn: add helper to detect transaction boundaries · 13acfe47
      Vladimir Davydov authored
      Add txn_is_first_statement() function, which returns true if this is the
      first statement of the transaction. The function is supposed to be used
      from on_replace trigger to detect transaction boundaries.
      
      Needed for #2129
      13acfe47
  6. Jul 23, 2018
    • Vladimir Davydov's avatar
      tx: exclude sysview engine from transaction control · 0ecabde8
      Vladimir Davydov authored
      Sysview is a special engine that is used for filtering out objects that
      a user can't access due to lack of privileges. Since it's treated as a
      separate engine by the transaction manager, we can't query sysview
      spaces from a memtx/vinyl transaction. In particular, if called from a
      transaction space:format() will return
      
        error: A multi-statement transaction can not use multiple storage engines
      
      which is inconvenient.
      
      To fix this, let's mark sysview engine with a new ENGINE_BYPASS_TX flag
      and make the transaction manager skip binding a transaction to an engine
      in case this flag is set.
      
      Closes #3528
      0ecabde8
  7. Jul 03, 2018
    • Konstantin Osipov's avatar
      memtx: vocally abort a transaction in case of implicit yield · 131121c9
      Konstantin Osipov authored
      Before this patch, memtx would silently roll back a multi-statement
      transaction on yield, switching the session to autocommit mode.
      
      It would do nothing in case yield happened in a sub-statement
      in auto-commit mode.
      
      This could lead to nasty/painful to debug side-effects in
      malformed Lua programs.
      
      Fix by adding a special transaction state - aborted, and enter
      this state in case of implicit yield.
      
      Check for what happens when a sub-statement yields.
      Check that yield trigger is removed by a rollback.
      
      Fixes gh-2631
      Fixes gh-2528
      131121c9
  8. Jun 27, 2018
  9. Jun 14, 2018
    • Vladislav Shpilevoy's avatar
      fiber: remove fiber local storage · 766feac2
      Vladislav Shpilevoy authored
      Replace it with more specific structures and pointers in order to
      prepare to add `net` storage.
      
      This allows to make the code working with fiber storage simpler,
      remove useless wrappers and casts, and in the next patch - remove
      broken session.sync and add fiber sync.
      
      Note that under no circumstances fiber.h is allowed to include
      application-specific headers like session.h or txn.h. One only
      is allowed to announce a struct and add opaque pointer to it.
      766feac2
  10. May 11, 2018
    • Nikita Pettik's avatar
      sql: allow transitive Lua <-> SQL transactions · 27aaba6a
      Nikita Pettik authored
      This patch makes possible to start transaction in Lua and continue
      operations in SQL as well, and vice versa. Previously, such transactions
      result in assertion fault. To support them, it is required to hold deferred
      foreign keys constraints as attributes of transaction, not particular VDBE.
      Thus, deferred foreign keys counters have been completely removed from
      VDBE and transfered to sql_txn struct. In its turn, if there is at least
      one deferred foreign key violation, error will be raised alongside with
      rollback - that is what ANSI SQL says. Note that in SQLite rollback
      doesn't occur: transaction remains open untill explicit rollback or
      resolving all FK violations.
      
      Also, 'PRAGMA defer_foreign_keys' has been slightly changed: now it is not
      automatically turned off after trasaction's rollback or commit. It
      can be turned off by explicit PRAGMA statement only. It was made owing
      to the fact that execution of PRAGMA statement occurs in auto-commit
      mode, so it ends with COMMIT. Hence, it turns off right after turning on
      (outside the transaction).
      
      Closes #3237
      27aaba6a
  11. Jan 23, 2018
    • Vladimir Davydov's avatar
      txn: fix on_replace trigger chaining · 653cbcec
      Vladimir Davydov authored
      If there are multiple on_replace triggers installed for the same space
      and one of them creates a new statement (by issuing a DML request), then
      the trigger that is called next will get the statement created by the
      previous trigger instead of the original statement. To fix that, let's
      patch txn_current_stmt() so as to return the first statement at the
      current transaction level instead of the last statement and use it in
      txn_commit_stmt(). This will also allow us to issue DML requests from a
      before_replace trigger without disrupting the current statement.
      
      Needed for #2993
      Follow-up #3020
      653cbcec
    • Vladimir Davydov's avatar
      txn: fix rollback of sub-statements · 5ea035ba
      Vladimir Davydov authored
      If space.on_replace callback fails (throws), we must rollback all
      statements inserted by the callback before failing and the statement
      that triggered the callback while currently we only rollback the last
      statement on txn->stmts list. To fix this, let's remember the position
      to rollback to in case of failure for each sub statement, similarly to
      how we do with savepoints.
      
      Note, there's a comment to txn_rollback_stmt() that says that it doesn't
      remove the last statement from the txn->stmts list, just clears it:
      
              /**
               * Void all effects of the statement, but
               * keep it in the list - to maintain
               * limit on the number of statements in a
               * transaction.
               */
              void
              txn_rollback_stmt()
      
      It isn't going to hold after this patch, because this patch reuses the
      savepoint code to rollback statements on failure. Anyway, I haven't
      managed to figure out why we would ever need to keep statements on the
      list after rollback. The comment is clearly misleading as we don't have
      any limits on the number of statements, and even if we had, a statement
      counter would suffice. I guess the real reason why we don't delete
      statements from the list is that it is simply impossible to do in case
      of a singly linked list like stailq, but now it isn't going to be a
      problem. So remove the comment and the test case of engine/savepoint
      which relies on it.
      
      Needed for #2993
      Closes #3020
      5ea035ba
    • Vladimir Davydov's avatar
      txn: zap txn_savepoint->is_first flag · 2634306f
      Vladimir Davydov authored
      This flag isn't necessary as we can set txn_savepoint->stmt to NULL when
      a savepoint is created inside an empty transaction. Using a separate
      flag for this purpose obscures the code flow and complicates further
      progress so let's remove it.
      2634306f
  12. Jan 05, 2018
    • AKhatskevich's avatar
      sql: recover SQL savepoints & abort · c3d5944d
      AKhatskevich authored
      This comit introduces a number of changes:
      
      1. move a transaction state to fiber local struct
      
        This is important because the `sqlite3` is a shared structure and it was
      used to store data related to the transaction. However it was working because
      yield is called only on commit and it garanteed unique access. (With possible
      effects on ddl.)
      
      NOTE: `nDeferredCons` and `nDeferredImmCons` are stored in vdbe during vdbe
      execution and moved to sql_txn when it needs to be saved until execution of the
      next vdbe in the same transaction.
      
      2. support savepoints
      
      2.1. support abort (anonymous savepoints)
      
        Abort mechanism was simplified. Instead of storing track of all
      savepoints without name, this commit introduces `anonymous_savepoint`.
        `anonymous_savepoint` is a structure which is stored in Vdbe and represents
      the state of database on the beginning of the current statement. Tarantool
      disallow multistatement, so a vdbe can have one statement max. That is why
      having one savepoint is enough to perform abort.
      
      2.2. named savepoints
      
      Key points:
        - It uses Tarantool's savepoints
        - It allocates savepoints on the "region" (they are destroyed automatically)
        - There are some crutches around ddl (ddl should not be placed into a
      transaction)
      
      Closes #2989 #2931 #2964
      c3d5944d
  13. Oct 19, 2017
    • Vladimir Davydov's avatar
      txn: internal API: rollback on begin/commit failure · 84b7d542
      Vladimir Davydov authored
      Current internal tnx API is not particularly user-friendly in regards to
      error handling: if txn_begin_stmt(), txn_commit_stmt(), or txn_commit()
      fails, the txn state is undefined and the caller must rollback manually.
      To make the API easier to use, let's oblige these function rollback
      automatically in case of failure.
      
      Needed for #2776
      84b7d542
  14. Oct 15, 2017
  15. Oct 06, 2017
    • Vladimir Davydov's avatar
      Move Handler->engine to struct space · 29ed9210
      Vladimir Davydov authored
      space->handler->engine->... looks ugly. Since all Handler methods
      receive space as an argument anyway, let's move engine to struct space.
      
      This is a step towards converting class Handler to struct space_vtab.
      
      Needed for #2776
      29ed9210
  16. Sep 08, 2017
  17. Sep 05, 2017
    • Konstantin Osipov's avatar
      box: review fixes for gh-2025 (savepoints) · 09ba3ca3
      Konstantin Osipov authored
      * update error messages
      * rename variables
      * add a few comments
      09ba3ca3
    • Vladislav Shpilevoy's avatar
      Implement box.savepoint · ff0ff603
      Vladislav Shpilevoy authored
      Savepoint allows to partialy rollback a transaction. After
      savepoint creation a transaction owner can rollback all changes applied
      after the savepoint without rolling back the entire transaction.
      
      Multiple savepoints can be created in each transaction. Rollback to
      a savepoint cancels changes made after the savepoint, and deletes all
      newer savepoints.
      
      It is impossible to rollback to a savepoint from a substatements level,
      different from the savepoint's one. For example, a transaction can not
      rollback to a savepoint, created outside of a trigger, from a trigger body.
      
      Closes #2025
      ff0ff603
    • Vladislav Shpilevoy's avatar
      Make space bsize virtual · 0ddfedcb
      Vladislav Shpilevoy authored
      Vinyl can not calculate bsize during transaction execution
      because of DELETE and UPSERT in vinyl spaces with single index.
      
      Move space bsize into MemtxSpace, because Vinyl can not calculate
      it now.
      
      In a future, Vinyl bsize can be calculated after dumps and
      compactions, but never during transaction execution.
      0ddfedcb
  18. Aug 31, 2017
    • khatskevich's avatar
      sql: Enable warnings; fix warnings · 4e74627e
      khatskevich authored
           Warnings for box/sql were enabled, set as errors.
           All issues were resolved.
      
           Removed useless box/sql/backup.c
      
           Removed extensions infrastructure.
      
      Closes #2338
      4e74627e
  19. Jul 28, 2017
  20. Jul 27, 2017
  21. Jul 19, 2017
  22. Mar 29, 2017
  23. Dec 13, 2016
  24. Dec 08, 2016
  25. Dec 02, 2016
    • Konstantin Osipov's avatar
      gh-587: (nested statements): review fixes · edffdc00
      Konstantin Osipov authored
      Add test cases for transaction control statements
      invoked in a trigger.
      
      ABI change: box_txn_rollback() now may fail with error,
      if called from a nested stateent.
      edffdc00
    • Roman Tsisyk's avatar
      Allow DML requests from on_replace triggers · 519f1388
      Roman Tsisyk authored
      Touch txn a little bit to support multistatement transactions in
      autocommit mode.
      
      This patch allow to perform DML requests from space:on_replace()
      triggers. Trigerred requests are processed as a part of the original
      transaction and entire transaction is rolled back in case of error.
      Please note that there is still no support for nested transactions,
      therefore a call to box.begin() from on_replace() trigger is not
      allowed.
      
      Recursive invocation is not forbidden, but limited to the maximal
      depth of 4 to avoid stack overflow.
      
      Proudly fixes #587
      519f1388
  26. Aug 08, 2016
  27. May 20, 2016
  28. Nov 24, 2015
  29. Nov 09, 2015
Loading