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
Conversation
examples/stale-reads/main.go
Outdated
} | ||
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. |
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.
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 { |
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.
Just curious: why do we need to call Commit
on a read-only txn?
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.
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.
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.
LGTM.
Adds support for setting a read-only staleness for both single reads and multi-use read-only transactions.