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: add support for stale reads #44

Merged
merged 28 commits into from Oct 11, 2021
Merged

feat: add support for stale reads #44

merged 28 commits into from Oct 11, 2021

Conversation

olavloite
Copy link
Collaborator

Adds support for setting a read-only staleness for both single reads and multi-use read-only transactions.

@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Oct 8, 2021
driver.go Show resolved Hide resolved
}
fmt.Printf("Singers count at timestamp %s was: %v\n", t.Format(time.RFC3339Nano), c)

// Commit the read-only transaction and close the connection to release the resources they areß using.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nits: remove the weird char in areß.

fmt.Printf("Singers count at timestamp %s was: %v\n", t.Format(time.RFC3339Nano), c)

// Commit the read-only transaction and close the connection to release the resources they areß using.
if err := tx.Commit(); err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just curious: why do we need to call Commit on a read-only txn?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We need to indicate when we are done with a read-only transaction so the underlying session can be returned to the session pool, and the go-sql Transaction interface does not have anything like a Close method. So both the Commit and Rollback methods of Transaction do the same for read-only transactions; they return the underlying session to the pool.

Copy link
Collaborator

@hengfengli hengfengli left a comment

Choose a reason for hiding this comment

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

LGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants