Skip to content
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

feat(spanner): add option for LastStatement in transaction #11638

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

olavloite
Copy link
Contributor

Adds an option to indicate that a statement is the last statement in a transaction. This allows Spanner to skip some validations during the execution of the statement, and instead rely on the validations during the Commit.

This option will also be used by the database/sql driver for statements that are executed directly on a connection instead of in a transaction.

This change also fixes a number of test cases so that the test time is reduced from 2 minutes to approx 5 seconds.

@olavloite olavloite requested review from a team as code owners February 22, 2025 18:16
@product-auto-label product-auto-label bot added the api: spanner Issues related to the Spanner API. label Feb 22, 2025
Adds an option to indicate that a statement is the last statement in a transaction.
This allows Spanner to skip some validations during the execution of the statement,
and instead rely on the validations during the Commit.

This option will also be used by the database/sql driver for statements that are
executed directly on a connection instead of in a transaction.

This change also fixes a number of test cases so that the test time is reduced
from 2 minutes to approx 5 seconds.
@@ -681,48 +681,57 @@ func (s *inMemSpannerServer) getStatementResult(sql string) (*StatementResult, e

func (s *inMemSpannerServer) simulateExecutionTime(method string, req interface{}) (interface{}, error) {
s.mu.Lock()
defer s.mu.Unlock()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping this lock here prevented the server from being shut down if there was a request still waiting for an execution time to finish (e.g. if an execution time of 1 minute had been set for an RPC, then keeping this lock would prevent the tests from stopping the server for 1 minute, which again would mean that the test would take 1 minute).

@olavloite olavloite requested a review from rahul2393 February 28, 2025 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the Spanner API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant