-
Notifications
You must be signed in to change notification settings - Fork 82
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
compare: implement --snapshot option for source database #524
base: main
Are you sure you want to change the base?
Conversation
to compare a source snapshot to the target
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.
Thanks for your contribution!
Would you consider adding some coverage about your use case or even an example (with an actual snapshot and all) in the documentation too?
if (!pgsql_set_transaction(&src, ISOLATION_REPEATABLE_READ, false, true)) | ||
{ | ||
/* errors have already been logged */ | ||
(void) pgsql_finish(&src); | ||
return false; | ||
} | ||
|
||
if (!pgsql_set_snapshot(&src, copySpecs->sourceSnapshot.snapshot)) | ||
{ | ||
/* errors have already been logged */ | ||
(void) pgsql_finish(&src); | ||
return false; | ||
} |
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.
Can we just use copydb_set_snapshot
from snapshot.c?
/* unset sourceSnapshot snapshot for target */ | ||
targetSpecs->consistent = false; | ||
(void) memset(&(targetSpecs->sourceSnapshot.snapshot), 0, sizeof(targetSpecs->sourceSnapshot.snapshot)); | ||
|
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.
Why do we need to do this? can't we use copydb_close_snapshot
?
@@ -301,11 +312,23 @@ cli_compare_schema(int argc, char **argv) | |||
exit(EXIT_CODE_INTERNAL_ERROR); | |||
} | |||
|
|||
if (!IS_EMPTY_STRING_BUFFER(compareOptions.snapshot) && !copydb_set_snapshot(©Specs)) |
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.
nitpicking: please make it fit in two lines, or even with embedded if statements, for ease of maintenance and also to respect line length (does it fit within 80 chars, per project policy).
to compare a source snapshot to the target
usecase: to check and make sure that data on source and target has not diverged when CDC has been ongoing for a while
pgcopydb follow --resume
with endpos set to the position the snapshot is at (e.g. 11/11111110)pgcopydb compare --snapshot 00000000-00000000-0
can be used to compare