Transactions and Transaction Operators
SciDB transactions allow users to:
Create a transaction apart from any query
Arbitrarily roll back (abort) a transaction
Commit a transaction explicitly
Users do not need to know beforehand all queries they'd like to execute in the transaction, so users can interactively explore their data in new and flexible ways.
Transactions cannot be nested. Many SciDB operators are disallowed inside a transaction because they have effects (especially on metadata) which cannot easily be rolled back. A disallowed operator will result in an error and an aborted transaction. See Operators disallowed in a transaction for a list of disallowed operators.
Changes to arrays modified by a user’s transaction are protected by array locks held by that transaction. Array locks are acquired incrementally as operators within the transaction reference additional arrays. The array locks won’t be released until the transaction either commits or rolls back. This prevents a transaction from removing an array or removing array versions out from underneath another transaction.
If a transaction has modified an array and another session (whether in a transaction or not) attempts to use that array in a query, the query in that other session will block until the transaction modifying the array is committed or rolled back, or the configurable lock-timeout
is reached. If two transactions attempt to lock arrays in an order that would cause a deadlock, SciDB detects the deadlock and raises an exception in the query causing the deadlock.
Transactions are automatically rolled back when the user disconnects (iquery) or when the user session expires (HTTP API).
If a query results in an error while in a transaction, the transaction is not rolled back automatically. Instead, the transaction becomes invalid and is said to be in “pending rollback” state: all queries in this state are forbidden and result in an error with error code SCIDB_LE_PENDING_ROLLBACK
. The only way to proceed out of this state is to issue a rollback()
, which ends the transaction and undoes any work that was performed in the transaction. Requiring a rollback()
in this manner prevents the session from getting into a state where the user thinks the transaction is still active but the transaction has actually ended.
SciDB transactions provide Read Committed isolation [SQL 1992]. Arrays created, removed, or altered by a new version will be visible to other queries and transactions only after the transaction commits. Once committed, the change immediately becomes visible within other transactions since the isolation is not Read Repeatable or Serializable [SQL 1992].
Transaction error messages
Long error message code | Meaning |
---|---|
| The query contains an operator that can only be used within a transaction, but your session is not in a transaction. For example: You tried to |
| The query contains an operator that isn’t allowed in a transaction. Most operators that affect metadata aren’t allowed in transactions. See Operators disallowed in a transaction for a list of such operators. In general, the only metadata operation you can perform in a transaction is to create a new array. This error invalidates the transaction; to continue, you must |
| The transaction was invalidated due to a previous error. No operations can be performed until you issue a |
| The transaction tried to lock an array that was already locked by another transaction, while that other transaction was waiting for an array locked by this transaction. SciDB has invalidated your transaction and released its locks so that the other transaction can proceed. This error invalidates the transaction; to continue, you must |
| This message indicates that a Most SciDB clients, such as the iquery command-line tool and all tools provided by Paradigm4 customer service, will handle this message internally and will not expose it to users. However, if you are writing a client that communicates directly with a SciDB server, you might need to detect this message and present an appropriate “success” message to the user. |