Make ResetRemoteTransaction more robust

There's a second issue with ResetRemoteTransaction. The check to remove
the transaction only took into account the state, and not if the
connection was actually part of a list.
fix-valgrind-problem-v2-test2
Jelte Fennema 2023-02-02 10:51:11 +01:00
parent 820119c859
commit db19cb8048
2 changed files with 9 additions and 2 deletions

View File

@ -80,6 +80,7 @@ StartRemoteTransactionBegin(struct MultiConnection *connection)
/* remember transaction as being in-progress */ /* remember transaction as being in-progress */
dlist_push_tail(&InProgressTransactions, &connection->transactionNode); dlist_push_tail(&InProgressTransactions, &connection->transactionNode);
connection->transactionInProgress = true;
transaction->transactionState = REMOTE_TRANS_STARTING; transaction->transactionState = REMOTE_TRANS_STARTING;
@ -865,11 +866,13 @@ ResetRemoteTransaction(struct MultiConnection *connection)
RemoteTransaction *transaction = &connection->remoteTransaction; RemoteTransaction *transaction = &connection->remoteTransaction;
/* unlink from list of open transactions, if necessary */ /* unlink from list of open transactions, if necessary */
if (transaction->transactionState != REMOTE_TRANS_NOT_STARTED) if (connection->transactionInProgress)
{ {
/* XXX: Should we error out for a critical transaction? */ /* XXX: Should we error out for a critical transaction? */
dlist_delete(&connection->transactionNode); dlist_delete(&connection->transactionNode);
connection->transactionInProgress = false;
memset(&connection->transactionNode, 0, sizeof(connection->transactionNode));
} }
/* just reset the entire state, relying on 0 being invalid/false */ /* just reset the entire state, relying on 0 being invalid/false */

View File

@ -189,8 +189,12 @@ typedef struct MultiConnection
/* information about the associated remote transaction */ /* information about the associated remote transaction */
RemoteTransaction remoteTransaction; RemoteTransaction remoteTransaction;
/* membership in list of in-progress transactions */ /*
* membership in list of in-progress transactions and a flag to indicate
* that the connection was added to this list
*/
dlist_node transactionNode; dlist_node transactionNode;
bool transactionInProgress;
/* list of all placements referenced by this connection */ /* list of all placements referenced by this connection */
dlist_head referencedPlacements; dlist_head referencedPlacements;