From 6dcc960665f474f0e899dae4fd9f9c24aec29c4f Mon Sep 17 00:00:00 2001 From: Onder Kalaci Date: Thu, 1 Sep 2022 09:34:38 +0300 Subject: [PATCH] Apply feedback --- .../connection/connection_management.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/backend/distributed/connection/connection_management.c b/src/backend/distributed/connection/connection_management.c index 3a9dcf0ca..20d0353b6 100644 --- a/src/backend/distributed/connection/connection_management.c +++ b/src/backend/distributed/connection/connection_management.c @@ -577,7 +577,19 @@ EnsureTxStateAndGetHealthyConnections(dlist_head *connections, { /* * If a connection is executing a critical transaction or accessed any - * placements, we should not continue the execution. + * placements, we should not skip this connection (or return as + * healthy connection). + * + * Critical transaction means that the caller -- or the initiator + * of the transaction -- cannot afford to handle any failures + * within the transaction, so better fail right now. + * + * If a placement is accessed inside a transaction and the + * transaction has failed, we cannot proceed. Otherwise, + * another connection in the same transaction might try + * to access the same placement over a different connection. + * That could cause self-deadlocks or break read-your-own-writes + * consistency. */ ReportConnectionError(connection, ERROR); } @@ -692,8 +704,7 @@ ProcessWaitEventsForSocketClose(WaitEvent *events, int eventCount, bool *socketC { *socketClosed = false; - int eventIndex = 0; - for (; eventIndex < eventCount; eventIndex++) + for (int eventIndex = 0; eventIndex < eventCount; eventIndex++) { WaitEvent *event = &events[eventIndex];