8000 Fix incorrect xid and timestamp for continued txn COMMIT SQL. by shubhamdhama · Pull Request #302 · dimitri/pgcopydb · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix incorrect xid and timestamp for continued txn COMMIT SQL. #302

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

Merged
merged 2 commits into from
May 30, 2023
Merged
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
33 changes: 5 additions & 28 deletions src/bin/pgcopydb/ld_transform.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,20 +219,6 @@ stream_transform_line(void *ctx, const char *line, bool *stop)
new.isTransaction = true;
new.action = STREAM_ACTION_BEGIN;

LogicalTransactionStatement *stmt = NULL;

stmt = (LogicalTransactionStatement *)
calloc(1,
sizeof(LogicalTransactionStatement));

if (stmt == NULL)
{
log_error(ALLOCATION_FAILED_ERROR);
return false;
}

stmt->action = STREAM_ACTION_BEGIN;

LogicalTransaction *old = &(currentMsg->command.tx);
LogicalTransaction *txn = &(new.command.tx);

Expand Down Expand Up @@ -718,22 +704,9 @@ stream_transform_file(char *jsonfilename, char *sqlfilename)
new.isTransaction = true;
new.action = STREAM_ACTION_BEGIN;

LogicalTransactionStatement *stmt = NULL;

stmt = (LogicalTransactionStatement *)
calloc(1,
sizeof(LogicalTransactionStatement));

if (stmt == NULL)
{
log_error(ALLOCATION_FAILED_ERROR);
return false;
}

stmt->action = STREAM_ACTION_BEGIN;

LogicalTransaction *txn = &(new.command.tx);
txn->continued = true;
txn->xid = metadata->xid;
txn->first = NULL;

*currentMsg = new;
Expand Down Expand Up @@ -1000,6 +973,8 @@ parseMessage(LogicalMessage *mesg,

txn->xid = metadata->xid;
txn->beginLSN = metadata->lsn;

/* this should be overwritten in COMMIT action as that's what we need for origin */
strlcpy(txn->timestamp, metadata->timestamp, sizeof(txn->timestamp));
txn->first = NULL;

Expand All @@ -1022,6 +997,8 @@ parseMessage(LogicalMessage *mesg,
return false;
}

/* update the timestamp for tracking in replication origin */
strlcpy(txn->timestamp, metadata->timestamp, sizeof(txn->timestamp));
txn->commitLSN = metadata->lsn;
txn->commit = true;

Expand Down
0