-
Notifications
You must be signed in to change notification settings - Fork 24
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
Consider adding transaction keep-alives when using psql #1826
Comments
olavloite
added a commit
to googleapis/java-spanner
that referenced
this issue
Jun 10, 2024
Adds a property to the Connection API for keeping read/write transactions alive. This can be used in CLI-like applications that might wait a longer period of time for user input. The property is disabled by default, as enabling it can cause read/write transactions to hold on to locks for a longer period of time than intended. Updates GoogleCloudPlatform/pgadapter#1826
olavloite
added a commit
to googleapis/java-spanner
that referenced
this issue
Jul 3, 2024
* chore: add property for keep-transaction-alive Adds a property to the Connection API for keeping read/write transactions alive. This can be used in CLI-like applications that might wait a longer period of time for user input. The property is disabled by default, as enabling it can cause read/write transactions to hold on to locks for a longer period of time than intended. Updates GoogleCloudPlatform/pgadapter#1826 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
surbhigarg92
pushed a commit
to surbhigarg92/java-spanner
that referenced
this issue
Jul 3, 2024
* chore: add property for keep-transaction-alive Adds a property to the Connection API for keeping read/write transactions alive. This can be used in CLI-like applications that might wait a longer period of time for user input. The property is disabled by default, as enabling it can cause read/write transactions to hold on to locks for a longer period of time than intended. Updates GoogleCloudPlatform/pgadapter#1826 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I came across some unexpected behavior while using PGAdapter with psql. Here's the transaction example.
Transaction T1:
Transaction T2:
The unexpected behavior here is that because I grabbed an exclusive lock in T1 in step 3, I expected the
SELECT
in step 4 of T2 to block on T1 being committed. What I observed instead is that step 4 in T2 waiting a little bit and returned a result.It turns out this happens because PGAdapter doesn't send keep-alives to keep transactions active beyond 10 secs. So T1 internally gets aborted after 10 secs of inactivity. Then T2 is able to get a result after T1 has released the locks on those cells of the table.
The reason why PGAdapter doesn't send keep-alives to keep transactions active is to stop users from accidentally holding onto locks for longer than necessary. This makes sense for production apps.
But given that psql is a CLI where users might be trying to run long-running transactions on purpose, it would be nice to keep the transactions alive so you don't get unexpected behaviours like the example above.
The text was updated successfully, but these errors were encountered: