mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-28 09:46:44 +08:00
Fix hard crash when aborting transaction
If something is wrong with a connection we would not be able to start a transaction on the remote node. So when abort happens we shoud not try to abort a transaction that hasn't started. We use xact_depth to check if transaction actually started. If we find one we remove it from our tx cache which should result in removing the invalid connection as well.
This commit is contained in:
parent
27f3effcb1
commit
b01cc6ef1b
@ -194,9 +194,10 @@ dist_txn_xact_callback_abort()
|
||||
testing_callback_call("pre-abort");
|
||||
remote_txn_store_foreach(state.store, remote_txn)
|
||||
{
|
||||
if (!remote_txn_abort(remote_txn))
|
||||
if (!remote_txn_is_ongoing(remote_txn) || !remote_txn_abort(remote_txn))
|
||||
{
|
||||
elog(WARNING, "failure aborting remote transaction during local abort");
|
||||
if (remote_txn_is_ongoing(remote_txn))
|
||||
elog(WARNING, "failure aborting remote transaction during local abort");
|
||||
remote_txn_store_remove(state.store, remote_txn_get_connection_id(remote_txn));
|
||||
}
|
||||
}
|
||||
|
@ -358,6 +358,14 @@ remote_txn_abort(RemoteTxn *entry)
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Check if there is ongoing transaction on the remote node */
|
||||
bool
|
||||
remote_txn_is_ongoing(RemoteTxn *entry)
|
||||
{
|
||||
Assert(entry->xact_depth >= 0);
|
||||
return entry->xact_depth != 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* If there were any errors in subtransactions, and we made prepared
|
||||
* statements, those prepared statements may not have been cleared
|
||||
|
@ -37,6 +37,7 @@ extern TSConnectionId remote_txn_get_connection_id(RemoteTxn *txn);
|
||||
extern bool remote_txn_is_still_in_progress(TransactionId frontend_xid);
|
||||
extern size_t remote_txn_size(void);
|
||||
extern bool remote_txn_is_at_sub_txn_level(RemoteTxn *entry, int curlevel);
|
||||
extern bool remote_txn_is_ongoing(RemoteTxn *entry);
|
||||
|
||||
/* Messages/communication */
|
||||
extern AsyncRequest *remote_txn_async_send_commit(RemoteTxn *entry);
|
||||
|
Loading…
x
Reference in New Issue
Block a user