diff options
author | Michael P | 2011-03-04 07:13:56 +0000 |
---|---|---|
committer | Pavan Deolasee | 2011-05-24 09:05:51 +0000 |
commit | cbd4f1b71dd935f3459e84678218870bc8bd6ab8 (patch) | |
tree | 017dd963536a6e913a035fea3e2593184c5ff02c | |
parent | 07a3dce533cd254d470ea1fbacfc1fe92d42e40d (diff) |
Fix for bug 3199029 GTM/GTM-proxy FATAL error handling
Fix to make the main thread of GTM to return a non-null value
when in error state.
Patch by Pavan Deolasee
-rw-r--r-- | src/gtm/common/elog.c | 5 | ||||
-rw-r--r-- | src/gtm/main/main.c | 6 | ||||
-rw-r--r-- | src/gtm/proxy/proxy_main.c | 5 | ||||
-rw-r--r-- | src/include/gtm/gtm.h | 2 | ||||
-rw-r--r-- | src/include/gtm/gtm_proxy.h | 1 |
5 files changed, 18 insertions, 1 deletions
diff --git a/src/gtm/common/elog.c b/src/gtm/common/elog.c index cc6a9a533b..3ca63558db 100644 --- a/src/gtm/common/elog.c +++ b/src/gtm/common/elog.c @@ -355,7 +355,10 @@ errfinish(int dummy,...) * FATAL termination. The postmaster may or may not consider this * worthy of panic, depending on which subprocess returns it. */ - pthread_exit(NULL); + if (IsMainThread()) + exit(1); + else + pthread_exit(NULL); } if (elevel >= PANIC) diff --git a/src/gtm/main/main.c b/src/gtm/main/main.c index ea6d5d2cbe..80f35b32ae 100644 --- a/src/gtm/main/main.c +++ b/src/gtm/main/main.c @@ -55,6 +55,8 @@ int GTMPortNumber; char GTMControlFile[GTM_MAX_PATH]; char *GTMDataDir; +GTM_ThreadID TopMostThreadID; + /* The socket(s) we're listening to. */ #define MAXLISTEN 64 static int ListenSocket[MAXLISTEN]; @@ -113,6 +115,7 @@ MainThreadInit() fprintf(stderr, "malloc failed: %d", errno); fflush(stdout); fflush(stderr); + exit(1); } if (SetMyThreadInfo(thrinfo)) @@ -120,8 +123,11 @@ MainThreadInit() fprintf(stderr, "SetMyThreadInfo failed: %d", errno); fflush(stdout); fflush(stderr); + exit(1); } + TopMostThreadID = pthread_self(); + return thrinfo; } diff --git a/src/gtm/proxy/proxy_main.c b/src/gtm/proxy/proxy_main.c index d892680f38..f1e8553dd6 100644 --- a/src/gtm/proxy/proxy_main.c +++ b/src/gtm/proxy/proxy_main.c @@ -61,6 +61,7 @@ char *GTMServerHost; int GTMServerPortNumber; GTM_PGXCNodeId GTMProxyID = 0; +GTM_ThreadID TopMostThreadID; /* The socket(s) we're listening to. */ #define MAXLISTEN 64 @@ -145,6 +146,7 @@ MainThreadInit() fprintf(stderr, "malloc failed: %d", errno); fflush(stdout); fflush(stderr); + exit(1); } if (SetMyThreadInfo(thrinfo)) @@ -152,8 +154,11 @@ MainThreadInit() fprintf(stderr, "SetMyThreadInfo failed: %d", errno); fflush(stdout); fflush(stderr); + exit(1); } + TopMostThreadID = pthread_self(); + return thrinfo; } diff --git a/src/include/gtm/gtm.h b/src/include/gtm/gtm.h index 5041b0e88c..91eff992fa 100644 --- a/src/include/gtm/gtm.h +++ b/src/include/gtm/gtm.h @@ -93,6 +93,7 @@ GTM_ThreadInfo * GTM_GetThreadInfo(GTM_ThreadID thrid); */ extern pthread_key_t threadinfo_key; extern MemoryContext TopMostMemoryContext; +extern GTM_ThreadID TopMostThreadID; #define SetMyThreadInfo(thrinfo) pthread_setspecific(threadinfo_key, (thrinfo)) #define GetMyThreadInfo ((GTM_ThreadInfo *)pthread_getspecific(threadinfo_key)) @@ -113,6 +114,7 @@ extern MemoryContext TopMostMemoryContext; GetMyThreadInfo->thr_conn->con_port : \ NULL) #define MyThreadID (GetMyThreadInfo->thr_id) +#define IsMainThread() (GetMyThreadInfo->thr_id == TopMostThreadID) #define GTM_CachedTransInfo (GetMyThreadInfo->thr_cached_txninfo) #define GTM_HaveFreeCachedTransInfo() (list_length(GTM_CachedTransInfo)) diff --git a/src/include/gtm/gtm_proxy.h b/src/include/gtm/gtm_proxy.h index 9b721e1de2..0031d6e83b 100644 --- a/src/include/gtm/gtm_proxy.h +++ b/src/include/gtm/gtm_proxy.h @@ -200,6 +200,7 @@ typedef struct GTMProxy_CommandInfo extern pthread_key_t threadinfo_key; extern MemoryContext TopMostMemoryContext; extern char *GTMLogFile; +extern GTM_ThreadID TopMostThreadID; #define SetMyThreadInfo(thrinfo) pthread_setspecific(threadinfo_key, (thrinfo)) #define GetMyThreadInfo ((GTMProxy_ThreadInfo *)pthread_getspecific(threadinfo_key)) |