Skip to content

Add full support for protocol.LAST_COMMIT_INFO (#45) #179

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

madscientist
Copy link
Contributor

Previously the LAST_COMMIT_INFO feature was only supported at the protocol level: the driver always reported there was no information available about the last commit.

Last commit ensures "read your own writes" capability for committed transactions, even when connections are using different TEs.

Implement an internal structure to store last commit information:

  • The information is saved as a process-wide set of data
  • Allows the same process to connect to different databases, and to connect to the same database multiple times (to the same or to different TEs).

In order to support Python clients that may use threading with different connections, use a Lock() to access the last commit details. Python threading doesn't provide reader/writer locks; rather than write one we'll use a simple mutex and assume this won't be a performance bottleneck.

Previously the LAST_COMMIT_INFO feature was only supported at the
protocol level: the driver always reported there was no information
available about the last commit.

Last commit ensures "read your own writes" capability for committed
transactions, even when connections are using different TEs.

Implement an internal structure to store last commit information:
- The information is saved as a process-wide set of data
- Allows the same process to connect to different databases, and to
  connect to the same database multiple times (to the same or to
  different TEs).

In order to support Python clients that may use threading with different
connections, use a Lock() to access the last commit details.  Python
threading doesn't provide reader/writer locks; rather than write one
we'll use a simple mutex and assume this won't be a performance
bottleneck.
@madscientist madscientist marked this pull request as ready for review May 19, 2025 22:27
Copy link

@alampe3ds alampe3ds left a comment

Choose a reason for hiding this comment

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

LGTM. Seems to handle LastCommitInfo properly.

I don't really understand why threading issues need to be addressed now but not before. But that might be because I never used threading in python so far. So I give that part the benefit of doubt and assume you tested it properly.

@madscientist madscientist requested review from pflynnnuodb and removed request for TheDistributor May 20, 2025 19:51
@madscientist
Copy link
Contributor Author

@pflynnnuodb Martin is N/A this week so offering this to you for review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants