Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit eff8852

Browse files
committed
handle aborted tx state in MtmExplicitPrepare
1 parent 982566d commit eff8852

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

expected/multimaster.out

+4
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,10 @@ commit prepared 'y';
349349
ERROR: COMMIT PREPARED cannot run inside a transaction block
350350
rollback;
351351
commit prepared 'y';
352+
begin;
353+
select 1/0;
354+
ERROR: division by zero
355+
prepare transaction 'noprep';
352356
table twopc_test;
353357
i
354358
---

sql/multimaster.sql

+4
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,10 @@ rollback;
251251

252252
commit prepared 'y';
253253

254+
begin;
255+
select 1/0;
256+
prepare transaction 'noprep';
257+
254258
table twopc_test;
255259
table twopc_test2;
256260

src/commit.c

+11
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,17 @@ MtmExplicitPrepare(char *gid)
483483
int n_messages;
484484
int i;
485485

486+
/*
487+
* GetTopTransactionId() will fail for aborted tx, but we still need to
488+
* finish it, so handle that manually.
489+
*/
490+
if (IsAbortedTransactionBlockState())
491+
{
492+
ret = PrepareTransactionBlock(gid);
493+
Assert(!ret);
494+
return false;
495+
}
496+
486497
xid = GetTopTransactionId();
487498
sprintf(stream, "xid" XID_FMT, xid);
488499
dmq_stream_subscribe(stream);

0 commit comments

Comments
 (0)