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

[Source-postgres] : Advance Postgres LSN for PG 14 & below #33605

Merged
merged 6 commits into from
Dec 19, 2023

Conversation

akashkulk
Copy link
Contributor

@akashkulk akashkulk commented Dec 18, 2023

Copy link

vercel bot commented Dec 18, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
airbyte-docs ⬜️ Ignored (Inspect) Visit Preview Dec 19, 2023 0:15am

Copy link
Contributor

github-actions bot commented Dec 18, 2023

Before Merging a Connector Pull Request

Wow! What a great pull request you have here! 🎉

To merge this PR, ensure the following has been done/considered for each connector added or updated:

  • PR name follows PR naming conventions
  • Breaking changes are considered. If a Breaking Change is being introduced, ensure an Airbyte engineer has created a Breaking Change Plan.
  • Connector version has been incremented in the Dockerfile and metadata.yaml according to our Semantic Versioning for Connectors guidelines
  • You've updated the connector's metadata.yaml file any other relevant changes, including a breakingChanges entry for major version bumps. See metadata.yaml docs
  • Secrets in the connector's spec are annotated with airbyte_secret
  • All documentation files are up to date. (README.md, bootstrap.md, docs.md, etc...)
  • Changelog updated in docs/integrations/<source or destination>/<name>.md with an entry for the new version. See changelog example
  • Migration guide updated in docs/integrations/<source or destination>/<name>-migrations.md with an entry for the new version, if the version is a breaking change. See migration guide example
  • If set, you've ensured the icon is present in the platform-internal repo. (Docs)

If the checklist is complete, but the CI check is failing,

  1. Check for hidden checklists in your PR description

  2. Toggle the github label checklist-action-run on/off to re-run the checklist CI.

@octavia-squidington-iii octavia-squidington-iii added the area/documentation Improvements or additions to documentation label Dec 18, 2023
Copy link
Contributor

github-actions bot commented Dec 18, 2023

Coverage report for source-postgres

File Coverage [86.17%] 🍏
PostgresCdcCtidInitializer.java 89.15% 🍏
PostgresUtils.java 83.93% 🍏
Total Project Coverage 71.68% 🍏

// 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);
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor

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

Copy link
Contributor

Choose a reason for hiding this comment

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

See CtidUtils.isTidRangeScanCapableDBServer()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a check

// 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);
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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

@akashkulk akashkulk merged commit b05e985 into master Dec 19, 2023
18 checks passed
@akashkulk akashkulk deleted the akash/postgres-advance-lsn branch December 19, 2023 16:18
jatinyadav-cc pushed a commit to ollionorg/datapipes-airbyte that referenced this pull request Feb 26, 2024
jatinyadav-cc pushed a commit to ollionorg/datapipes-airbyte that referenced this pull request Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/connectors Connector related issues area/documentation Improvements or additions to documentation connectors/source/postgres
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Source Postgres] : Method to advance LSN in Postgres in PG-14 & below
4 participants