Method: googleapis.spanner.v1.projects.instances.databases.sessions.commit

Commits a transaction. The request includes the mutations to be applied to rows in the database. Commit might return an ABORTED error. This can occur at any time; commonly, the cause is conflicts with concurrent transactions. However, it can also happen for a variety of other reasons. If Commit returns ABORTED, the caller should re-attempt the transaction from the beginning, re-using the same session. On very rare occasions, Commit might return UNKNOWN. This can happen, for example, if the client job experiences a 1+ hour networking failure. At that point, Cloud Spanner has lost track of the transaction outcome and we recommend that you perform another read from the database to see the state of things as they are now.

Arguments

Parameters
session

string

Required. The session in which the transaction to be committed is running.

body

object (CommitRequest)

Required.

Raised exceptions

Exceptions
ConnectionError In case of a network problem (such as DNS failure or refused connection).
HttpError If the response status is >= 400 (excluding 429 and 503).
TimeoutError If a long-running operation takes longer to finish than the specified timeout limit.
TypeError If an operation or function receives an argument of the wrong type.
ValueError If an operation or function receives an argument of the right type but an inappropriate value. For example, a negative timeout.

Response

If successful, the response contains an instance of CommitResponse.

Subworkflow snippet

Some fields might be optional or required. To identify required fields, refer to the API documentation.

YAML

- commit:
    call: googleapis.spanner.v1.projects.instances.databases.sessions.commit
    args:
        session: ...
        body:
            mutations: ...
            requestOptions:
                priority: ...
                requestTag: ...
                transactionTag: ...
            returnCommitStats: ...
            singleUseTransaction:
                partitionedDml: ...
                readOnly:
                    exactStaleness: ...
                    maxStaleness: ...
                    minReadTimestamp: ...
                    readTimestamp: ...
                    returnReadTimestamp: ...
                    strong: ...
                readWrite:
                    readLockMode: ...
            transactionId: ...
    result: commitResult

JSON

[
  {
    "commit": {
      "call": "googleapis.spanner.v1.projects.instances.databases.sessions.commit",
      "args": {
        "session": "...",
        "body": {
          "mutations": "...",
          "requestOptions": {
            "priority": "...",
            "requestTag": "...",
            "transactionTag": "..."
          },
          "returnCommitStats": "...",
          "singleUseTransaction": {
            "partitionedDml": "...",
            "readOnly": {
              "exactStaleness": "...",
              "maxStaleness": "...",
              "minReadTimestamp": "...",
              "readTimestamp": "...",
              "returnReadTimestamp": "...",
              "strong": "..."
            },
            "readWrite": {
              "readLockMode": "..."
            }
          },
          "transactionId": "..."
        }
      },
      "result": "commitResult"
    }
  }
]