From: Pavan Deolasee Date: Mon, 1 Feb 2016 09:19:37 +0000 (+0100) Subject: Exponetially increase the sleep before retrying commit on the GTM. X-Git-Tag: XL9_5_R1BETA1~45 X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=e57dd0ecab330bd556aa880c8ce07dcfb94d423b;p=postgres-xl.git Exponetially increase the sleep before retrying commit on the GTM. When a transaction waits for another transaction to complete, we enforce the same ordering on the same GTM by making the former transaction wait on the latter. We do this by a simple retry logic. While the latter transaction should ideally finish soon because it has already finished on the datanode, the retry loop now waits exponentially, starting at 1000usec but limited by 1s. Patch by Mason Sharp --- diff --git a/src/gtm/client/gtm_client.c b/src/gtm/client/gtm_client.c index 1ac19f4c6f..be1f6b27cd 100644 --- a/src/gtm/client/gtm_client.c +++ b/src/gtm/client/gtm_client.c @@ -26,6 +26,7 @@ #define CLIENT_GTM_TIMEOUT 20 #endif #endif +#define MAX_RETRY_SLEEP_MICRO 1000000 #include #include "gtm/gtm_c.h" @@ -652,6 +653,7 @@ commit_transaction_internal(GTM_Conn *conn, GlobalTransactionId gxid, { GTM_Result *res = NULL; time_t finish_time; + long retry_sleep = 1000; retry: /* Start the message. */ @@ -712,7 +714,13 @@ retry: * might make sense to flash a warning and proceed after * certain number of retries */ - pg_usleep(1000); + if (retry_sleep <= MAX_RETRY_SLEEP_MICRO) + { + retry_sleep = retry_sleep * 2; + if (retry_sleep > MAX_RETRY_SLEEP_MICRO) + retry_sleep = MAX_RETRY_SLEEP_MICRO; + } + pg_usleep(retry_sleep); goto retry; } } @@ -757,6 +765,7 @@ commit_prepared_transaction_internal(GTM_Conn *conn, { GTM_Result *res = NULL; time_t finish_time; + long retry_sleep = 1000; retry: /* Start the message */ @@ -800,7 +809,13 @@ retry: if (res->gr_resdata.grd_eof_txn.status == STATUS_DELAYED) { /* See comments in commit_transaction_internal() */ - pg_usleep(1000); + if (retry_sleep <= MAX_RETRY_SLEEP_MICRO) + { + retry_sleep = retry_sleep * 2; + if (retry_sleep > MAX_RETRY_SLEEP_MICRO) + retry_sleep = MAX_RETRY_SLEEP_MICRO; + } + pg_usleep(retry_sleep); goto retry; } }