Class ReadWrite (3.66.0)

ReadWrite(mapping=None, *, ignore_unknown_fields=False, **kwargs)

Message type to initiate a read-write transaction. Currently this transaction type has no options.

Attributes

Name Description
read_lock_mode google.cloud.spanner_v1.types.TransactionOptions.ReadWrite.ReadLockMode
Read lock mode for the transaction.
multiplexed_session_previous_transaction_id bytes
Optional. Clients should pass the transaction ID of the previous transaction attempt that was aborted if this transaction is being executed on a multiplexed session.

Classes

ReadLockMode

ReadLockMode(value)

ReadLockMode is used to set the read lock mode for read-write transactions.

    - If isolation level is
      `SERIALIZABLE][google.spanner.v1.TransactionOptions.IsolationLevel.SERIALIZABLE]`,
      locking semantics default to `PESSIMISTIC`.
    - If isolation level is
      `REPEATABLE_READ][google.spanner.v1.TransactionOptions.IsolationLevel.REPEATABLE_READ]`,
      locking semantics default to `OPTIMISTIC`.
    - See `Concurrency
      control <https://cloud.google.com/spanner/docs/concurrency-control>`__
      for more details.
PESSIMISTIC (1):
    Pessimistic lock mode.

    Lock acquisition behavior depends on the isolation level in
    use. In
    `SERIALIZABLE][google.spanner.v1.TransactionOptions.IsolationLevel.SERIALIZABLE]`
    isolation, reads and writes acquire necessary locks during
    transaction statement execution. In
    `REPEATABLE_READ][google.spanner.v1.TransactionOptions.IsolationLevel.REPEATABLE_READ]`
    isolation, reads that explicitly request to be locked and
    writes acquire locks. See `Concurrency
    control <https://cloud.google.com/spanner/docs/concurrency-control>`__
    for details on the types of locks acquired at each
    transaction step.
OPTIMISTIC (2):
    Optimistic lock mode.

    Lock acquisition behavior depends on the isolation level in
    use. In both
    `SERIALIZABLE][google.spanner.v1.TransactionOptions.IsolationLevel.SERIALIZABLE]`
    and
    `REPEATABLE_READ][google.spanner.v1.TransactionOptions.IsolationLevel.REPEATABLE_READ]`
    isolation, reads and writes do not acquire locks during
    transaction statement execution. See `Concurrency
    control <https://cloud.google.com/spanner/docs/concurrency-control>`__
    for details on how the guarantees of each isolation level
    are provided at commit time.