@@ -295,7 +295,7 @@ static void DtmUpdateRecentXmin(Snapshot snapshot)
295
295
*/
296
296
static TransactionId DtmGetNextXid ()
297
297
{
298
- TransactionId xid ;
298
+ TransactionId xid = InvalidTransactionId ;
299
299
LWLockAcquire (dtm -> xidLock , LW_EXCLUSIVE );
300
300
if (TransactionIdIsValid (DtmNextXid ))
301
301
{
@@ -321,7 +321,12 @@ static TransactionId DtmGetNextXid()
321
321
if (dtm -> nReservedXids == 0 )
322
322
{
323
323
dtm -> nReservedXids = DtmGlobalReserve (ShmemVariableCache -> nextXid , DtmLocalXidReserve , & dtm -> nextXid );
324
- Assert (dtm -> nReservedXids > 0 );
324
+ if (dtm -> nReservedXids < 1 )
325
+ {
10000
code>
326
+ elog (WARNING , "failed to reserve a local range of xids on arbiter" );
327
+ goto end ;
328
+ }
329
+
325
330
Assert (TransactionIdFollowsOrEquals (dtm -> nextXid , ShmemVariableCache -> nextXid ));
326
331
327
332
/* Advance ShmemVariableCache->nextXid formward until new Xid */
@@ -339,6 +344,7 @@ static TransactionId DtmGetNextXid()
339
344
dtm -> nReservedXids -= 1 ;
340
345
XTM_INFO ("Obtain new local XID %d\n" , xid );
341
346
}
347
+ end :
342
348
LWLockRelease (dtm -> xidLock );
343
349
return xid ;
344
350
}
@@ -387,6 +393,8 @@ DtmGetNewTransactionId(bool isSubXact)
387
393
388
394
LWLockAcquire (XidGenLock , LW_EXCLUSIVE );
389
395
xid = DtmGetNextXid ();
396
+ if (!TransactionIdIsValid (xid ))
397
+ elog (ERROR , "failed to get next xid from XTM" );
390
398
391
399
/*----------
392
400
* Check to see if it's safe to assign another XID. This protects against
@@ -620,7 +628,11 @@ static void DtmSetTransactionStatus(TransactionId xid, int nsubxids, Transaction
620
628
if (status == TRANSACTION_STATUS_ABORTED )
621
629
{
622
630
PgTransactionIdSetTreeStatus (xid , nsubxids , subxids , status , lsn );
623
- DtmGlobalSetTransStatus (xid , status , false);
631
+ if (DtmGlobalSetTransStatus (xid , status , false) == -1 )
632
+ {
633
+ elog (WARNING , "failed to set 'aborted' transaction status on arbiter" );
634
+ return ; // FIXME: return bool
635
+ }
624
636
XTM_INFO ("Abort transaction %d\n" , xid );
625
637
return ;
626
638
}
@@ -631,7 +643,11 @@ static void DtmSetTransactionStatus(TransactionId xid, int nsubxids, Transaction
631
643
LWLockAcquire (dtm -> hashLock , LW_EXCLUSIVE );
632
644
hash_search (xid_in_doubt , & DtmNextXid , HASH_ENTER , NULL );
633
645
LWLockRelease (dtm -> hashLock );
634
- DtmGlobalSetTransStatus (xid , status , true);
646
+ if (DtmGlobalSetTransStatus (xid , status , true) == -1 )
647
+ {
648
+ elog (WARNING , "failed to set 'committed' transaction status on arbiter" );
649
+ return ; // FIXME: return bool
650
+ }
635
651
XTM_INFO ("Commit transaction %d\n" , xid );
636
652
}
637
653
}
@@ -648,6 +664,7 @@ static void DtmSetTransactionStatus(TransactionId xid, int nsubxids, Transaction
648
664
status = gs ;
649
665
}
650
666
PgTransactionIdSetTreeStatus (xid , nsubxids , subxids , status , lsn );
667
+ // FIXME: return bool
651
668
}
652
669
653
670
static uint32 dtm_xid_hash_fn (const void * key , Size keysize )
0 commit comments