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: return info on create slot of replication #1335

Merged
merged 1 commit into from Nov 22, 2018

Conversation

@jorsol
Copy link
Member

@jorsol jorsol commented Nov 7, 2018

The CREATE_REPLICATION_SLOT replication command returns the following info: slot_name, consistent_point, snapshot_name, output_plugin.

This info can be valuable, in particular, snapshot_name is exported on the logical slot creation to allow a consistent snapshot in some uses cases that require it.

A new class ReplicationSlotInfo is being returned now to have easy access to the values.

All Submissions:

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

New Feature Submissions:

  1. Does your submission pass tests?
  2. Does mvn checkstyle:check pass ?
@pbillen
Copy link
Contributor

@pbillen pbillen commented Nov 7, 2018

+1 for this feature. It is very useful for this flow:

  1. create replication slot
  2. get corresponding snapshot id
  3. start repeatable read/serializable transaction
  4. call SET TRANSACTION SNAPSHOT <snapshot id>

Now you can query the database to get a consistent view in your application, and consume the replication slow to update that view accordingly.

@pbillen
Copy link
Contributor

@pbillen pbillen commented Nov 7, 2018

Regarding the code, (imho) I believe it's cleaner to return a dedicated class with getters such as getSlotName(), getConsistentPoint(), ... instead of a rather typeless Map<String, String>.

@jorsol
Copy link
Member Author

@jorsol jorsol commented Nov 7, 2018

@pbillen it might be a good idea to return a dedicated class... I will try that.

@pbillen
Copy link
Contributor

@pbillen pbillen commented Nov 7, 2018

@jorsol You could use org.postgresql.replication.LogSequenceNumber as type of consistent point field.

@jorsol
Copy link
Member Author

@jorsol jorsol commented Nov 7, 2018

Do you have some sugestion on the class name?

@pbillen
Copy link
Contributor

@pbillen pbillen commented Nov 7, 2018

Maybe ReplicationSlotInfo?

Please note I am not a maintainer of this project, so you might want to wait for feedback from other reviewers. I just got excited :).

@davecramer
Copy link
Member

@davecramer davecramer commented Nov 7, 2018

ReplicationSlotInfo works for me

The CREATE_REPLICATION_SLOT replication command return the following
info: slot_name, consistent_point, snapshot_name, output_plugin.

This info can be valuable, in particular snapshot_name is exported
to allow a consistent snapshot in some uses cases that requires it.

A new class ReplicationSlotInfo is being returned now to have easy
access to the values.
@jorsol jorsol force-pushed the return-create-replication-info branch from 09a9531 to 3c6af90 Nov 7, 2018
@codecov-io
Copy link

@codecov-io codecov-io commented Nov 7, 2018

Codecov Report

Merging #1335 into master will increase coverage by 0.02%.
The diff coverage is 88.88%.

@@             Coverage Diff              @@
##             master    #1335      +/-   ##
============================================
+ Coverage     68.58%   68.61%   +0.02%     
- Complexity     3883     3888       +5     
============================================
  Files           178      179       +1     
  Lines         16205    16239      +34     
  Branches       2646     2650       +4     
============================================
+ Hits          11114    11142      +28     
- Misses         3860     3861       +1     
- Partials       1231     1236       +5

@jorsol
Copy link
Member Author

@jorsol jorsol commented Nov 7, 2018

Done, changed to ReplicationSlotInfo.

@davecramer
Copy link
Member

@davecramer davecramer commented Nov 8, 2018

LGTM

@davecramer davecramer merged commit 84e8d90 into pgjdbc:master Nov 22, 2018
2 checks passed
@jorsol jorsol deleted the return-create-replication-info branch Nov 22, 2018
@jorsol jorsol mentioned this pull request Jun 18, 2019
davecramer added a commit to davecramer/pgjdbc that referenced this issue Jul 5, 2021
The CREATE_REPLICATION_SLOT replication command returns the following
info: slot_name, consistent_point, snapshot_name, output_plugin.

This info can be valuable, in particular snapshot_name is exported
to allow a consistent snapshot in some uses cases that require it.

A new class ReplicationSlotInfo is being returned now to provide easy
access to the values.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants