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

Recover from crash using undo log #549

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/bin/pgcopydb/copydb.c
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,10 @@ copydb_prepare_filepaths(CopyFilePaths *cfPaths,
"%s/lsn.json",
cfPaths->cdc.dir);

sformat(cfPaths->cdc.undofile, MAXPGPATH,
"%s/undo",
cfPaths->cdc.dir);

/*
* Now prepare the "compare" files we need to compare schema and data
* between the source and target instance.
Expand Down
1 change: 1 addition & 0 deletions src/bin/pgcopydb/copydb.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
{ "extra_float_digits", "3" }, \
{ "statement_timeout", "0" }, \
{ "default_transaction_read_only", "off" }

/*
* These parameters are added to the connection strings, unless the user has
* added them, allowing user-defined values to be taken into account.
Expand Down
1 change: 1 addition & 0 deletions src/bin/pgcopydb/copydb_paths.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ typedef struct CDCPaths
char tlifile[MAXPGPATH]; /* /tmp/pgcopydb/cdc/tli */
char tlihistfile[MAXPGPATH]; /* /tmp/pgcopydb/cdc/tli.history */
char lsntrackingfile[MAXPGPATH]; /* /tmp/pgcopydb/cdc/lsn.json */
char undofile[MAXPGPATH]; /* /tmp/pgcopydb/cdc/undo */
} CDCPaths;


Expand Down
16 changes: 16 additions & 0 deletions src/bin/pgcopydb/follow.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,22 @@ follow_get_sentinel(StreamSpecs *specs, CopyDBSentinel *sentinel, bool verbose)
bool
follow_main_loop(CopyDataSpec *copySpecs, StreamSpecs *streamSpecs)
{
/*
* Incase of a crash, execute recovery actions before starting the
* main loop.
*/
if (!recoverFromUndoLog(&streamSpecs->paths))
{
log_error("Failed to recover from undo log, see above for details");
return false;
}

if (!removeUndoLog(&streamSpecs->paths))
{
log_error("Failed to remove undo log, see above for details");
return false;
}

/*
* Remove the possibly still existing stream context files from
* previous round of operations (--resume, etc). We want to make
Expand Down
Loading
Loading