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: log based replication #249

Merged
merged 20 commits into from
Oct 16, 2023
Merged

feat: log based replication #249

merged 20 commits into from
Oct 16, 2023

Conversation

sebastianswms
Copy link
Collaborator

No description provided.

@sebastianswms sebastianswms changed the title Initial setup for PostgresLogBasedStream feat: incremental replication Sep 27, 2023
@visch visch changed the title feat: incremental replication feat: log based replication Sep 29, 2023
tap_postgres/tap.py Outdated Show resolved Hide resolved
# TODO: escape special characters
return f"{schema_name}.{table_name}"

def standardize_lsn(self, lsn_string: str | None) -> int:
Copy link
Member

Choose a reason for hiding this comment

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

Can you point to the docs for what this is converting https://www.postgresql.org/docs/current/datatype-pg-lsn.html#:~:text=This%20type%20is%20a%20representation,for%20example%2C%2016%2FB374D848%20.

I'm surprised the wal2json plugin doesn't do this for you

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, there's a way around it. I refactored and removed the standardize_lsn() function entirely.

tap_postgres/client.py Show resolved Hide resolved
tap_postgres/client.py Outdated Show resolved Hide resolved
@sebastianswms sebastianswms marked this pull request as ready for review October 9, 2023 16:50
tap_postgres/tap.py Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
)
row.update({"_sdc_lsn": message.data_start})
elif message_payload["action"] in truncate_actions:
self.logger.warning(
Copy link
Member

Choose a reason for hiding this comment

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

This is going to flood our logs, and it's really not a warning as there's nothing to warn about, maybe a debug?

message.payload,
)
elif message_payload["action"] in transaction_actions:
self.logger.info(
Copy link
Member

Choose a reason for hiding this comment

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

This is going to flood our logs, and it's really not a warning as there's nothing to warn about, maybe a debug?

tap_postgres/client.py Show resolved Hide resolved
)
return psycopg2.connect(
connection_string,
application_name="tappostgres",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
application_name="tappostgres",
application_name="tap_postgres",

@@ -282,6 +291,16 @@ def __init__(
+ " configuration option determines where that file is created."
),
),
th.Property(
"replication_method",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"replication_method",
"default_replication_method",

tap_postgres/client.py Outdated Show resolved Hide resolved
tap_postgres/client.py Outdated Show resolved Hide resolved
schema = table_schema.to_dict()

replication_key = None
if replication_method == "LOG_BASED":
Copy link
Member

Choose a reason for hiding this comment

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

This shouldn't happen at discovery, this should happen after discovery in the LogBased Stream Class

jsonschema_type: dict = self.to_jsonschema_type(
typing.cast(sqlalchemy.types.TypeEngine, column_def["type"]),
)
table_schema.append(
Copy link
Member

@visch visch Oct 13, 2023

Choose a reason for hiding this comment

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

This should happen in the Log Based Stream class, not here.

@visch visch merged commit 7c4d8b8 into MeltanoLabs:main Oct 16, 2023
5 checks passed
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