adding optimistic locking#16124
Conversation
There was a problem hiding this comment.
Code Review
This pull request modifies the SpannerTransactionRunner to enable optimistic locking for all read-write transactions. A review comment identifies that this global change in concurrency semantics could lead to increased transaction aborts and retries in high-contention scenarios, recommending that the behavior be made configurable or verified for compatibility with existing workloads.
| public void run(TxRunnable runnable) throws TransactionException { | ||
| try { | ||
| admin.getDatabaseClient().readWriteTransaction().allowNestedTransaction().run(context -> { | ||
| admin.getDatabaseClient().readWriteTransaction(Options.optimisticLock()).allowNestedTransaction().run(context -> { |
There was a problem hiding this comment.
Enabling optimistic locking globally for all transactions is a significant change in concurrency semantics. While it can improve performance for low-contention workloads by avoiding read locks, it may lead to a high rate of transaction aborts and retries in high-contention scenarios. This can result in increased latency and CPU usage on the Spanner nodes. It is recommended to make this behavior configurable or to verify that all existing workloads using this runner are compatible with optimistic concurrency control, as Cloud Spanner defaults to pessimistic locking for a reason.
No description provided.