-
Notifications
You must be signed in to change notification settings - Fork 101
feat: default enable multiplex session for all operations unless explicitly set to false #1394
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
2c80c1b
to
4878ff3
Compare
776b838
to
f224acb
Compare
85dddcf
to
311451a
Compare
3e87b78
to
e5993ff
Compare
eef951f
to
3ad9ce9
Compare
0798969
to
8741633
Compare
8741633
to
67ea777
Compare
3c5c5ad
to
6450b4d
Compare
eefc798
to
63bac62
Compare
@@ -21,7 +21,7 @@ jobs: | |||
- name: Setup Python | |||
uses: actions/setup-python@v5 | |||
with: | |||
python-version: 3.8 | |||
python-version: 3.12 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is because in followup PR we will be removing 3.8 runtime support
#1395
|
||
if is_multiplexed_enabled(transaction_type=TransactionType.READ_WRITE): | ||
pytest.skip( | ||
"Mutiplexed session can't be deleted and this test relies on session deletion." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
739a78e
@@ -1031,7 +1030,7 @@ def _update_for_transaction_pb(self, transaction_pb: Transaction) -> None: | |||
self._transaction_id = transaction_pb.id | |||
|
|||
if transaction_pb.precommit_token: | |||
self._update_for_precommit_token_pb(transaction_pb.precommit_token) | |||
self._update_for_precommit_token_pb_unsafe(transaction_pb.precommit_token) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason why we need two methods?
_update_for_precommit_token_pb
, _update_for_precommit_token_pb_unsafe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there was a deadlock happening, transaction was locked already when calling _update_for_transaction_pb, and in _update_for_precommit_token_pb we were again trying to lock it.
This was the issue from previous release which got uncovered once I tried making mux default enabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Read this comment The caller is responsible for locking until the transaction ID is updated.
And then when we were calling _update_for_precommit_token_pb we were taking the lock again
https://github.com/googleapis/python-spanner/blob/main/google/cloud/spanner_v1/snapshot.py#L1046
So we needed 2 methods which takes lock when updating precommit token from unlocked code, and one which is called from places which assume lock is already taken
Read-Only, Read-Write and Partition Ops transactions now use a single multiplexed session, instead of a session from the session pool. Multiplexed sessions can handle any number of queries and read-only, read-write and partition ops transactions transactions at the same time.
The use of multiplexed sessions can be disabled for read-only, read-write and partition-ops transactions by setting the environment variables.
GOOGLE_CLOUD_SPANNER_MULTIPLEXED_SESSIONS=false
GOOGLE_CLOUD_SPANNER_MULTIPLEXED_SESSIONS_FOR_RW=false.
GOOGLE_CLOUD_SPANNER_MULTIPLEXED_SESSIONS_PARTITIONED_OPS=false.
See https://cloud.google.com/spanner/docs/sessions#multiplexed_sessions for more background information about multiplexed sessions.