-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
[Source-postgres] : Advance Postgres LSN for PG 14 & below #33605
Changes from all commits
f1be339
9e9ef8f
b172c28
0831318
ee1d7da
902e4f6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -172,6 +172,10 @@ public static List<AutoCloseableIterator<AirbyteMessage>> cdcCtidIteratorsCombin | |
|
||
// Gets the target position. | ||
final var targetPosition = PostgresCdcTargetPosition.targetPosition(database); | ||
// Attempt to advance LSN past the target position. For versions of Postgres before PG15, this | ||
// ensures that there is an event that debezium will | ||
// receive that is after the target LSN. | ||
PostgresUtils.advanceLsn(database); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With this there is no need to ever wait for a timeout as we know the WAL got past target lsn. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's true - however I did want to protect against cases where this query fails for whatever reason |
||
final AirbyteDebeziumHandler<Long> handler = new AirbyteDebeziumHandler<>(sourceConfig, | ||
targetPosition, false, firstRecordWaitTime, subsequentRecordWaitTime, queueSize); | ||
final PostgresCdcStateHandler postgresCdcStateHandler = new PostgresCdcStateHandler(stateManager); | ||
|
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.
should we make that only execute on postgres <15 ? That allows us to request less access right post 15, no?
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.
If we don't have the correct access, we'll just fail in the
advanceLsn
method and log that scenario. Success/failure of this advancement should not block the sync from proceeding.For PG14, the query that I've added in this PR requires no additional permissions. For PG15+, this same query will just fail because of permissions issues and move on.
Phase 2 hopes to address this with additional steps for the user to setup a heartbeat table
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.
Change will make things better for 14 and below.
But for 15 and above even if we can make this query, it will not be effective in bumping the LSN.
So maybe it makes sense to avoid a constant error or questions from customers about it.
We already have code doing "legacy" ctid for postgres <14.
You can utilize that function to do things <15
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.
See
CtidUtils.isTidRangeScanCapableDBServer()
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.
Added a check