@@ -352,8 +352,9 @@ DtmGetNewTransactionId(bool isSubXact)
352
352
TransactionId xid ;
353
353
354
354
XTM_INFO ("%d: GetNewTransactionId\n" , getpid ());
355
- Assert (!DtmGlobalXidAssigned ); /* We should not assign new Xid if we do not use previous one */
356
-
355
+ if (DtmGlobalXidAssigned ) { /* We should not assign new Xid if we do not use previous one */
356
+ elog (ERROR , "dtm_begin/join_transaction should be called prior to begin of global transaction" );
357
+ }
357
358
/*
358
359
* Workers synchronize transaction state at the beginning of each parallel
359
360
* operation, so we can't account for new XIDs after that point.
@@ -856,12 +857,16 @@ dtm_get_current_snapshot_xcnt(PG_FUNCTION_ARGS)
856
857
Datum
857
858
dtm_begin_transaction (PG_FUNCTION_ARGS )
858
859
{
859
- Assert (!TransactionIdIsValid (DtmNextXid ));
860
+ if (TransactionIdIsValid (DtmNextXid )) {
861
+ elog (ERROR , "dtm_begin/join_transaction should be called only once for global transaction" );
862
+ }
860
863
if (dtm == NULL ) {
861
864
elog (ERROR , "DTM is not properly initialized, please check that pg_dtm plugin was added to shared_preload_libraries list in postgresql.conf" );
862
865
}
863
866
DtmNextXid = DtmGlobalStartTransaction (& DtmSnapshot , & dtm -> minXid );
864
- Assert (TransactionIdIsValid (DtmNextXid ));
867
+ if (!TransactionIdIsValid (DtmNextXid )) {
868
+ elog (ERROR , "Arbiter was not able to assign XID" );
869
+ }
865
870
XTM_INFO ("%d: Start global transaction %d, dtm->minXid=%d\n" , getpid (), DtmNextXid , dtm -> minXid );
866
871
867
872
DtmHasGlobalSnapshot = true;
@@ -873,9 +878,13 @@ dtm_begin_transaction(PG_FUNCTION_ARGS)
873
878
874
879
Datum dtm_join_transaction (PG_FUNCTION_ARGS )
875
880
{
876
- Assert (!TransactionIdIsValid (DtmNextXid ));
881
+ if (TransactionIdIsValid (DtmNextXid )) {
882
+ elog (ERROR , "dtm_begin/join_transaction should be called only once for global transaction" );
883
+ }
877
884
DtmNextXid = PG_GETARG_INT32 (0 );
878
- Assert (TransactionIdIsValid (DtmNextXid ));
885
+ if (!TransactionIdIsValid (DtmNextXid )) {
886
+ elog (ERROR , "Arbiter was not able to assign XID" );
887
+ }
879
888
880
889
DtmGlobalGetSnapshot (DtmNextXid , & DtmSnapshot , & dtm -> minXid );
881
890
XTM_INFO ("%d: Join global transaction %d, dtm->minXid=%d\n" , getpid (), DtmNextXid , dtm -> minXid );
0 commit comments