You can subscribe to this list here.
2010 |
Jan
|
Feb
|
Mar
|
Apr
(4) |
May
(28) |
Jun
(12) |
Jul
(11) |
Aug
(12) |
Sep
(5) |
Oct
(19) |
Nov
(14) |
Dec
(12) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2011 |
Jan
(18) |
Feb
(30) |
Mar
(115) |
Apr
(89) |
May
(50) |
Jun
(44) |
Jul
(22) |
Aug
(13) |
Sep
(11) |
Oct
(30) |
Nov
(28) |
Dec
(39) |
2012 |
Jan
(38) |
Feb
(18) |
Mar
(43) |
Apr
(91) |
May
(108) |
Jun
(46) |
Jul
(37) |
Aug
(44) |
Sep
(33) |
Oct
(29) |
Nov
(36) |
Dec
(15) |
2013 |
Jan
(35) |
Feb
(611) |
Mar
(5) |
Apr
(55) |
May
(30) |
Jun
(28) |
Jul
(458) |
Aug
(34) |
Sep
(9) |
Oct
(39) |
Nov
(22) |
Dec
(32) |
2014 |
Jan
(16) |
Feb
(16) |
Mar
(42) |
Apr
(179) |
May
(7) |
Jun
(6) |
Jul
(9) |
Aug
|
Sep
(4) |
Oct
|
Nov
(3) |
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
(2) |
May
(4) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
|
|
1
(3) |
2
(5) |
3
|
4
(4) |
5
|
6
|
7
(7) |
8
(10) |
9
(6) |
10
(5) |
11
(1) |
12
|
13
|
14
|
15
|
16
|
17
(4) |
18
(1) |
19
|
20
|
21
(5) |
22
(15) |
23
(18) |
24
(7) |
25
(4) |
26
|
27
|
28
(3) |
29
(2) |
30
(11) |
31
(4) |
|
|
From: Michael P. <mic...@us...> - 2011-03-07 00:31:45
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via 9ecde28ad6b6ed00b7588928480bf0bd8a741421 (commit) via fbb0afd7b8858b13dc1f1f212742ffafcf4b7d8f (commit) from 062ecec9ab0e36f17f31624307470b8662dcfd80 (commit) - Log ----------------------------------------------------------------- commit 9ecde28ad6b6ed00b7588928480bf0bd8a741421 Merge: 062ecec fbb0afd Author: Michael P <mic...@us...> Date: Mon Mar 7 09:31:27 2011 +0900 Merge branch 'master' into merge_postgres_9_0_3 ----------------------------------------------------------------------- Summary of changes: src/backend/pgxc/pool/execRemote.c | 37 +++++++++++------------------------ 1 files changed, 12 insertions(+), 25 deletions(-) hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-07 00:30:18
|
Project "Postgres-XC". The branch, ha_support has been updated via 6ee7a8fb4ca7ca60504b443da95c0c3314b1c88d (commit) via fbb0afd7b8858b13dc1f1f212742ffafcf4b7d8f (commit) from 2876389f146b01bba0654c63e4d5eb635ffa8d8b (commit) - Log ----------------------------------------------------------------- commit 6ee7a8fb4ca7ca60504b443da95c0c3314b1c88d Merge: 2876389 fbb0afd Author: Michael P <mic...@us...> Date: Mon Mar 7 09:30:00 2011 +0900 Merge branch 'master' into ha_support ----------------------------------------------------------------------- Summary of changes: src/backend/pgxc/pool/execRemote.c | 37 +++++++++++------------------------ 1 files changed, 12 insertions(+), 25 deletions(-) hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-07 00:20:59
|
Project "Postgres-XC". The branch, master has been updated via fbb0afd7b8858b13dc1f1f212742ffafcf4b7d8f (commit) from 2e8115a86a7660fbb43a1cae72b8e406c7f82054 (commit) - Log ----------------------------------------------------------------- commit fbb0afd7b8858b13dc1f1f212742ffafcf4b7d8f Author: Michael P <mic...@us...> Date: Mon Mar 7 09:17:21 2011 +0900 Improve error handling when launching DDL or utilities This commit corrects a problem with error handling of ExecRemoteUtility in execRemote.c. When an error occurred on a Datanode during a DDL or utility process, connections were sent back to pooler when checking error message in remote state. This assumes that all the connections are clean. However, Coordinator connections whose messages have not been treated were also sent back to pooler. This could have resulted in data inconsistency of dirty coordinator-coordinator connections. Patch written by Benny Wang. diff --git a/src/backend/pgxc/pool/execRemote.c b/src/backend/pgxc/pool/execRemote.c index dc1d68c..711cd1f 100644 --- a/src/backend/pgxc/pool/execRemote.c +++ b/src/backend/pgxc/pool/execRemote.c @@ -4242,19 +4242,6 @@ ExecRemoteUtility(RemoteQuery *node) } } } - - /* - * We have processed all responses from the data nodes and if we have - * error message pending we can report it. All connections should be in - * consistent state now and can be released to the pool after rollback. - */ - if (remotestate->errorMessage) - { - char *code = remotestate->errorCode; - ereport(ERROR, - (errcode(MAKE_SQLSTATE(code[0], code[1], code[2], code[3], code[4])), - errmsg("%s", remotestate->errorMessage))); - } } /* Make the same for Coordinators */ @@ -4295,18 +4282,18 @@ ExecRemoteUtility(RemoteQuery *node) } } } - /* - * We have processed all responses from the data nodes and if we have - * error message pending we can report it. All connections should be in - * consistent state now and can be released to the pool after rollback. - */ - if (remotestate->errorMessage) - { - char *code = remotestate->errorCode; - ereport(ERROR, - (errcode(MAKE_SQLSTATE(code[0], code[1], code[2], code[3], code[4])), - errmsg("%s", remotestate->errorMessage))); - } + } + /* + * We have processed all responses from nodes and if we have + * error message pending we can report it. All connections should be in + * consistent state now and so they can be released to the pool after ROLLBACK. + */ + if (remotestate->errorMessage) + { + char *code = remotestate->errorCode; + ereport(ERROR, + (errcode(MAKE_SQLSTATE(code[0], code[1], code[2], code[3], code[4])), + errmsg("%s", remotestate->errorMessage))); } } ----------------------------------------------------------------------- Summary of changes: src/backend/pgxc/pool/execRemote.c | 37 +++++++++++------------------------ 1 files changed, 12 insertions(+), 25 deletions(-) hooks/post-receive -- Postgres-XC |
From: Koichi S. <koi...@us...> - 2011-03-04 09:08:22
|
Project "Postgres-XC". The branch, ha_support has been updated via 2876389f146b01bba0654c63e4d5eb635ffa8d8b (commit) from 481225ce8dc621e258c872fed33f85fcbc4cbf31 (commit) - Log ----------------------------------------------------------------- commit 2876389f146b01bba0654c63e4d5eb635ffa8d8b Author: Koichi Suzuki <koi...@gm...> Date: Fri Mar 4 18:08:24 2011 +0900 This is to fix the bug 3199366, to remove shared memory when xcm_initmember finds fatal configuration error to continue. diff --git a/src/pgxc/xcm/xcm_initmember.c b/src/pgxc/xcm/xcm_initmember.c index 2e71542..ffa05f1 100644 --- a/src/pgxc/xcm/xcm_initmember.c +++ b/src/pgxc/xcm/xcm_initmember.c @@ -505,11 +505,6 @@ int main(int argc, char *argv[]) dump_datanodes(n_datanode, datanode); #endif /* DEBUG_INITMEMBER */ } - /* - * Dump all the info if specified - */ - - /* ... TBS ... */ /* * Calculate the total size of shared memory @@ -607,7 +602,19 @@ int main(int argc, char *argv[]) rv = check_components(shm_top); if (rv != 0) { - xcm_destroy_shm(); /* Shmem is detatched here */ + char shmid_name[MAXPATH]; + char shmad_name[MAXPATH]; + struct shmid_ds buf; + /* + * Because shared memroy has been already attatched, we should not use + * xcm_destroy_shm(); + */ + rv = shmdt(shm_top); + shmctl(shm_id, IPC_RMID, &buf); + snprintf(shmid_name, MAXPATH, "%s/%s", get_xcmhome(), "shmid"); + unlink(shmid_name); + snprintf(shmad_name, MAXPATH, "%s/%s", get_xcmhome(), "shmad"); + unlink(shmad_name); exit(1); } shm_top->size = totalsize; ----------------------------------------------------------------------- Summary of changes: src/pgxc/xcm/xcm_initmember.c | 19 +++++++++++++------ 1 files changed, 13 insertions(+), 6 deletions(-) hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-04 07:19:11
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via 062ecec9ab0e36f17f31624307470b8662dcfd80 (commit) via 2e8115a86a7660fbb43a1cae72b8e406c7f82054 (commit) from 7eb3c73d3750b900c2a8d1ce446c97f2db425ca1 (commit) - Log ----------------------------------------------------------------- commit 062ecec9ab0e36f17f31624307470b8662dcfd80 Merge: 7eb3c73 2e8115a Author: Michael P <mic...@us...> Date: Fri Mar 4 16:18:54 2011 +0900 Merge branch 'master' into merge_postgres_9_0_3 ----------------------------------------------------------------------- Summary of changes: src/gtm/common/elog.c | 5 ++++- src/gtm/main/main.c | 6 ++++++ src/gtm/proxy/proxy_main.c | 5 +++++ src/include/gtm/gtm.h | 2 ++ src/include/gtm/gtm_proxy.h | 1 + 5 files changed, 18 insertions(+), 1 deletions(-) hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-04 07:18:31
|
Project "Postgres-XC". The branch, ha_support has been updated via 481225ce8dc621e258c872fed33f85fcbc4cbf31 (commit) via 2e8115a86a7660fbb43a1cae72b8e406c7f82054 (commit) from 29ea460de8f7e66093c7b38cd49e238aed2ba129 (commit) - Log ----------------------------------------------------------------- commit 481225ce8dc621e258c872fed33f85fcbc4cbf31 Merge: 29ea460 2e8115a Author: Michael P <mic...@us...> Date: Fri Mar 4 16:17:57 2011 +0900 Merge branch 'master' into ha_support ----------------------------------------------------------------------- Summary of changes: src/gtm/common/elog.c | 5 ++++- src/gtm/main/main.c | 6 ++++++ src/gtm/proxy/proxy_main.c | 5 +++++ src/include/gtm/gtm.h | 2 ++ src/include/gtm/gtm_proxy.h | 1 + 5 files changed, 18 insertions(+), 1 deletions(-) hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-04 07:16:53
|
Project "Postgres-XC". The branch, master has been updated via 2e8115a86a7660fbb43a1cae72b8e406c7f82054 (commit) from 3ba29c3723ed6a31b0faa8fea0b9a7e57ca0c25d (commit) - Log ----------------------------------------------------------------- commit 2e8115a86a7660fbb43a1cae72b8e406c7f82054 Author: Michael P <mic...@us...> Date: Fri Mar 4 16:13:56 2011 +0900 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 diff --git a/src/gtm/common/elog.c b/src/gtm/common/elog.c index cc6a9a5..3ca6355 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 ea6d5d2..80f35b3 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 d892680..f1e8553 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 5041b0e..91eff99 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 9b721e1..0031d6e 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)) ----------------------------------------------------------------------- Summary of changes: src/gtm/common/elog.c | 5 ++++- src/gtm/main/main.c | 6 ++++++ src/gtm/proxy/proxy_main.c | 5 +++++ src/include/gtm/gtm.h | 2 ++ src/include/gtm/gtm_proxy.h | 1 + 5 files changed, 18 insertions(+), 1 deletions(-) hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-02 08:17:51
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been created at 3ba29c3723ed6a31b0faa8fea0b9a7e57ca0c25d (commit) - Log ----------------------------------------------------------------- ----------------------------------------------------------------------- hooks/post-receive -- Postgres-XC |
From: Koichi S. <koi...@us...> - 2011-03-02 03:58:48
|
Project "Postgres-XC". The branch, ha_support has been updated via 29ea460de8f7e66093c7b38cd49e238aed2ba129 (commit) via b0075708ecefd2a5aadbc2ed6d52ea7172ce1a34 (commit) from 0cb897c8fb3c0948ab75951f33d8d105d25d0912 (commit) - Log ----------------------------------------------------------------- commit 29ea460de8f7e66093c7b38cd49e238aed2ba129 Merge: b007570 0cb897c Author: Koichi Suzuki <koi...@gm...> Date: Wed Mar 2 13:00:49 2011 +0900 Merge branch 'ha_support' of ssh://postgres-xc.git.sourceforge.net/gitroot/postgres-xc/postgres-xc into ha_support commit b0075708ecefd2a5aadbc2ed6d52ea7172ce1a34 Author: Koichi Suzuki <koi...@gm...> Date: Wed Mar 2 12:53:16 2011 +0900 This commit is to fix two issues. 1. Changed assigment of xcm_xxxx() return value so that caller can check error by testing if the returned value is negative. 2. Changed the use of random number to determine the delay time when spin lock was not acquired. Now this is based upon nrand48. The seed and internal status is stored in a separate area so it does not influence coordinator/datanode. diff --git a/src/include/pgxc/xcm/node_membership_struct.h b/src/include/pgxc/xcm/node_membership_struct.h index a39ee3d..baefa00 100644 --- a/src/include/pgxc/xcm/node_membership_struct.h +++ b/src/include/pgxc/xcm/node_membership_struct.h @@ -416,14 +416,14 @@ typedef struct xcm_fault_comps { * of such component, these calls will return XCM_ERR_STATUS. */ #define XCM_OK 0 /* Successful */ +#define XCM_OTHER_UPDATE 1 /* Shared memory updated for some reason */ #define XCM_ERR_NOT_INITIALIZED -1 /* Shared memory not built yet */ #define XCM_ERR_OUT_OF_RANGE -2 /* Specified component does not exist */ #define XCM_ERR_COMP_FAILED -3 /* Specified component is not running */ -#define XCM_OTHER_UPDATE -4 /* Shared memory updated for some reason */ -#define XCM_ERR_MISC -5 /* Other system call error */ -#define XCM_ERR_PARM -6 /* Invalid parameters specified */ -#define XCM_ERR_STATUS -7 /* Cluster status cannot accept the operation */ -#define XCM_NOT_FOUND -8 /* Indicates that the specified object not found */ +#define XCM_ERR_MISC -4 /* Other system call error */ +#define XCM_ERR_PARM -5 /* Invalid parameters specified */ +#define XCM_ERR_STATUS -6 /* Cluster status cannot accept the operation */ +#define XCM_NOT_FOUND -7 /* Indicates that the specified object not found */ /* * Misc. magic numbers/values. diff --git a/src/pgxc/xcm/node_membership.c b/src/pgxc/xcm/node_membership.c index 18a6f5f..aac05db 100644 --- a/src/pgxc/xcm/node_membership.c +++ b/src/pgxc/xcm/node_membership.c @@ -96,6 +96,7 @@ static int check_init(void); static xcm_components *init_shm(void); static xcm_connPoint *copy_connPoints(xcm_connPoint *conn, int n_conn); static xcm_fault_comps *alloc_fault_comps(int num_comps); +static void init_random(void); /* * Internal one ... comes from @@ -194,13 +195,39 @@ int xcm_destroy_shm() /* * Check if the shared memory is attached. If not, try to attach it. + * Also reinitializa the random number series used in the wait of slock + * using pid. */ + +/* + * This is just to be used in spinlock wait. + */ +unsigned short xcm_rand_seed[3]; +#define MY_MAXSHORT (int)(0x7fff) + +/* + * Setup the seed of the random number using my PID + */ +static void init_random() +{ + pid_t mypid; + mypid = getpid(); + if (sizeof(pid_t) > 4) { + mypid &= 0x7fffffff; + } + xcm_rand_seed[0] = 0; + xcm_rand_seed[1] = mypid/MY_MAXSHORT; + xcm_rand_seed[2] = mypid%MY_MAXSHORT; +} + static int check_init() { xcm_components *checkv; - if (shm_top == NULL) + if (shm_top == NULL) { + init_random(); checkv = init_shm(); + } else return(0); if (checkv == NULL) diff --git a/src/pgxc/xcm/xcm_s_lock.c b/src/pgxc/xcm/xcm_s_lock.c index 5ccf1df..eea9ab2 100644 --- a/src/pgxc/xcm/xcm_s_lock.c +++ b/src/pgxc/xcm/xcm_s_lock.c @@ -66,6 +66,12 @@ xcm_s_lock_stuck(volatile xcm_slock_t *lock, const char *file, int line) /* * xcm_s_lock(lock) - platform-independent portion of waiting for a spinlock. */ +/* + * Seed for the random number used to determine wait time. + * Defined in node_membership.c. + */ +extern unsigned short *xcm_rand_seed; + void xcm_s_lock(volatile xcm_slock_t *lock, const char *file, int line) { @@ -140,7 +146,7 @@ xcm_s_lock(volatile xcm_slock_t *lock, const char *file, int line) /* increase delay by a random fraction between 1X and 2X */ cur_delay += (int) (cur_delay * - ((double) random() / (double) MAX_RANDOM_VALUE) + 0.5); + ((double) nrand48(xcm_rand_seed) / (double) MAX_RANDOM_VALUE) + 0.5); /* wrap back to minimum delay when max is exceeded */ if (cur_delay > MAX_DELAY_MSEC) cur_delay = MIN_DELAY_MSEC; ----------------------------------------------------------------------- Summary of changes: src/include/pgxc/xcm/node_membership_struct.h | 10 ++++---- src/pgxc/xcm/node_membership.c | 29 ++++++++++++++++++++++++- src/pgxc/xcm/xcm_s_lock.c | 8 ++++++- 3 files changed, 40 insertions(+), 7 deletions(-) hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-02 03:01:52
|
Project "Postgres-XC". The branch, ha_support has been updated via 0cb897c8fb3c0948ab75951f33d8d105d25d0912 (commit) from c2fdec2ef8f70e118bd66d26996689190268845d (commit) - Log ----------------------------------------------------------------- commit 0cb897c8fb3c0948ab75951f33d8d105d25d0912 Author: Michael P <mic...@us...> Date: Wed Mar 2 11:59:31 2011 +0900 Support mirror numbering in 2PC Data for pg_prepared_xact() function This support was still lacking because the node list was set with the list of global IDs used on pooler. Node list is written with the following format: Dn1/Mir1,Dn1/Mir2,..,DnN/MirN Ex: 1/1,1/2,3/1 diff --git a/src/backend/pgxc/pool/execRemote.c b/src/backend/pgxc/pool/execRemote.c index 809d08f..af70052 100644 --- a/src/backend/pgxc/pool/execRemote.c +++ b/src/backend/pgxc/pool/execRemote.c @@ -4640,13 +4640,26 @@ PGXCNode_Build2PCData(bool isimplicit) datanodes = collect_pgxcnode_numbers(dn_conn_count, pgxc_handles->datanode_handles, REMOTE_CONN_DATANODE); - sprintf(buffer, "%d", datanodes[0]); - - for (i = 1; i < dn_conn_count; i++) + if (IsPGXCMirrorMode) { - sprintf(buffer, "%s,%d", buffer, datanodes[i]); + int datanode_id, mirror_id; + + datanode_id = PGXCMirror_GetMirrorIDAndDatanodeID(datanodes[0], &mirror_id); + sprintf(buffer, "%d/%d", datanode_id, mirror_id); + + for (i = 1; i < dn_conn_count; i++) + { + datanode_id = PGXCMirror_GetMirrorIDAndDatanodeID(datanodes[i], &mirror_id); + sprintf(buffer, "%s,%d/%d", buffer, datanode_id, mirror_id); + } } + else + { + sprintf(buffer, "%d", datanodes[0]); + for (i = 1; i < dn_conn_count; i++) + sprintf(buffer, "%s,%d", buffer, datanodes[i]); + } PGXC_2PCData->nodelist = (char *) malloc(strlen(buffer) + 1); memcpy(PGXC_2PCData->nodelist, buffer, strlen(buffer) + 1); } ----------------------------------------------------------------------- Summary of changes: src/backend/pgxc/pool/execRemote.c | 21 +++++++++++++++++---- 1 files changed, 17 insertions(+), 4 deletions(-) hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-02 00:57:30
|
Project "Postgres-XC". The branch, ha_support has been updated via c2fdec2ef8f70e118bd66d26996689190268845d (commit) via 3ba29c3723ed6a31b0faa8fea0b9a7e57ca0c25d (commit) from 482825deb075f295fc349fa3bb3fda8ca46d92df (commit) - Log ----------------------------------------------------------------- commit c2fdec2ef8f70e118bd66d26996689190268845d Merge: 482825d 3ba29c3 Author: Michael P <mic...@us...> Date: Wed Mar 2 10:02:06 2011 +0900 Merge branch 'master' into ha_support diff --cc src/backend/access/transam/xact.c index 082431c,4ef1edd..1f3c09f --- a/src/backend/access/transam/xact.c +++ b/src/backend/access/transam/xact.c @@@ -2092,11 -2083,9 +2091,11 @@@ CommitTransaction(bool contact_gtm * an application can use this special prepare. * If PrepareTransaction is called during an implicit 2PC, do not release ressources, * this is made by CommitTransaction when transaction has been committed on Nodes. + * + * In case of an explicit 2PC, 2PC Data of PGXC is set when PGXCNodePrepare is called. */ static void - PrepareTransaction(bool write_2pc_file, bool is_implicit) + PrepareTransaction(bool is_implicit) #else static void PrepareTransaction(void) diff --cc src/include/access/twophase.h index 06b219c,94df1ad..4a5e712 --- a/src/include/access/twophase.h +++ b/src/include/access/twophase.h @@@ -48,15 -37,8 +48,9 @@@ extern GlobalTransaction MarkAsPreparin extern GlobalTransaction MarkAsPreparing(TransactionId xid, const char *gid, TimestampTz prepared_at, Oid owner, Oid databaseid); +#endif - #ifdef PGXC - extern void RemoveGXactCoord(GlobalTransaction gxact); - extern void EndPrepare(GlobalTransaction gxact, bool write_2pc_file); - #else extern void EndPrepare(GlobalTransaction gxact); - #endif - extern void StartPrepare(GlobalTransaction gxact); extern TransactionId PrescanPreparedTransactions(void); ----------------------------------------------------------------------- Summary of changes: src/backend/access/transam/twophase.c | 40 ------- src/backend/access/transam/xact.c | 184 ++++++++++++++++----------------- src/backend/tcop/utility.c | 25 ++++- src/include/access/twophase.h | 6 - src/include/access/xact.h | 6 +- 5 files changed, 112 insertions(+), 149 deletions(-) hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-02 00:47:59
|
Project "Postgres-XC". The branch, master has been updated via 3ba29c3723ed6a31b0faa8fea0b9a7e57ca0c25d (commit) from 51cabe99e820989af4634ef7113a294563e8820c (commit) - Log ----------------------------------------------------------------- commit 3ba29c3723ed6a31b0faa8fea0b9a7e57ca0c25d Author: Michael P <mic...@us...> Date: Wed Mar 2 09:46:21 2011 +0900 Fix for bug 3134395, 3086422, 3136230: 2PC locks When a PREPARE was being made on Coordinator for a transaction not using DDL, 2PC file was bypassed so as to make a fake COMMIT on Coordinator. The problem was that locks hold at PREPARE state were not released at COMMIT PREPARED on Coordinator because lock information was obtained from 2PC, which indeed did not exist on Coordinator for non-DDL transactions. With this fix, instead of a fake PREPARE, XC does a Commit on Coordinator without contacting GTM, this permits to release correctly all the locks held by transaction. PrepareTransaction is simplified in xact.c, but CommitTransaction needs an additional parameter to decide if GTM is called at COMMIT or not. diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c index af15e79..1531d44 100644 --- a/src/backend/access/transam/twophase.c +++ b/src/backend/access/transam/twophase.c @@ -892,13 +892,8 @@ StartPrepare(GlobalTransaction gxact) * * Calculates CRC and writes state file to WAL and in pg_twophase directory. */ -#ifdef PGXC -void -EndPrepare(GlobalTransaction gxact, bool write_2pc_file) -#else void EndPrepare(GlobalTransaction gxact) -#endif { TransactionId xid = gxact->proc.xid; TwoPhaseFileHeader *hdr; @@ -935,11 +930,6 @@ EndPrepare(GlobalTransaction gxact) * PANIC anyway. */ -#ifdef PGXC - /* Write 2PC state file on Coordinator side if a DDL is involved in transaction */ - if (write_2pc_file) - { -#endif TwoPhaseFilePath(path, xid); fd = BasicOpenFile(path, @@ -1012,9 +1002,6 @@ EndPrepare(GlobalTransaction gxact) * We save the PREPARE record's location in the gxact for later use by * CheckPointTwoPhase. */ -#ifdef PGXC - } -#endif START_CRIT_SECTION(); @@ -1026,15 +1013,6 @@ EndPrepare(GlobalTransaction gxact) /* If we crash now, we have prepared: WAL replay will fix things */ -#ifdef PGXC - /* - * Just write 2PC state file on Datanodes - * or on Coordinators if DDL queries are involved. - */ - if (write_2pc_file) - { -#endif - /* write correct CRC and close file */ if ((write(fd, &statefile_crc, sizeof(pg_crc32))) != sizeof(pg_crc32)) { @@ -1049,10 +1027,6 @@ EndPrepare(GlobalTransaction gxact) (errcode_for_file_access(), errmsg("could not close two-phase state file: %m"))); -#ifdef PGXC - } -#endif - /* * Mark the prepared transaction as valid. As soon as xact.c marks MyProc * as not running our XID (which it will do immediately after this @@ -1903,17 +1877,3 @@ RecordTransactionAbortPrepared(TransactionId xid, END_CRIT_SECTION(); } - - -#ifdef PGXC -/* - * Remove a gxact on a Coordinator, - * this is used to be able to prepare a commit transaction on another coordinator than the one - * who prepared the transaction, for a transaction that does not include DDLs - */ -void -RemoveGXactCoord(GlobalTransaction gxact) -{ - RemoveGXact(gxact); -} -#endif diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c index 0fa83fa..4ef1edd 100644 --- a/src/backend/access/transam/xact.c +++ b/src/backend/access/transam/xact.c @@ -112,14 +112,13 @@ typedef enum TBlockState TBLOCK_BEGIN, /* starting transaction block */ TBLOCK_INPROGRESS, /* live transaction */ TBLOCK_END, /* COMMIT received */ +#ifdef PGXC + TBLOCK_END_NOT_GTM, /* COMMIT received but do not commit on GTM */ +#endif TBLOCK_ABORT, /* failed xact, awaiting ROLLBACK */ TBLOCK_ABORT_END, /* failed xact, ROLLBACK received */ TBLOCK_ABORT_PENDING, /* live xact, ROLLBACK received */ TBLOCK_PREPARE, /* live xact, PREPARE received */ -#ifdef PGXC - TBLOCK_PREPARE_NO_2PC_FILE, /* PREPARE receive but skip 2PC file creation - * and Commit gxact */ -#endif /* subtransaction states */ TBLOCK_SUBBEGIN, /* starting a subtransaction */ TBLOCK_SUBINPROGRESS, /* live subtransaction */ @@ -287,7 +286,7 @@ static void CallSubXactCallbacks(SubXactEvent event, SubTransactionId mySubid, SubTransactionId parentSubid); static void CleanupTransaction(void); -static void CommitTransaction(void); +static void CommitTransaction(bool contact_gtm); static TransactionId RecordTransactionAbort(bool isSubXact); static void StartTransaction(void); @@ -312,7 +311,7 @@ static const char *TransStateAsString(TransState state); #ifdef PGXC /* PGXC_COORD */ static GlobalTransactionId GetGlobalTransactionId(TransactionState s); -static void PrepareTransaction(bool write_2pc_file, bool is_implicit); +static void PrepareTransaction(bool is_implicit); /* ---------------------------------------------------------------- * PG-XC Functions @@ -1744,7 +1743,7 @@ StartTransaction(void) * NB: if you change this routine, better look at PrepareTransaction too! */ static void -CommitTransaction(void) +CommitTransaction(bool contact_gtm) { TransactionState s = CurrentTransactionState; TransactionId latestXid; @@ -1754,7 +1753,7 @@ CommitTransaction(void) char implicitgid[256]; TransactionId xid = GetCurrentTransactionId(); - if (IS_PGXC_COORDINATOR && !IsConnFromCoord()) + if (IS_PGXC_COORDINATOR && !IsConnFromCoord() && contact_gtm) PreparePGXCNodes = PGXCNodeIsImplicit2PC(&PrepareLocalCoord); if (PrepareLocalCoord || PreparePGXCNodes) @@ -1768,7 +1767,7 @@ CommitTransaction(void) * If current transaction has a DDL, and involves more than 1 Coordinator, * PREPARE first on local Coordinator. */ - PrepareTransaction(true, true); + PrepareTransaction(true); } else { @@ -1865,7 +1864,7 @@ CommitTransaction(void) * * This is called only if it is not necessary to prepare the nodes. */ - if (IS_PGXC_COORDINATOR && !IsConnFromCoord() && !PreparePGXCNodes) + if (IS_PGXC_COORDINATOR && !IsConnFromCoord() && !PreparePGXCNodes && contact_gtm) PGXCNodeCommit(); #endif @@ -1892,12 +1891,12 @@ CommitTransaction(void) * * Also do not commit a transaction that has already been prepared on Datanodes */ - if (IS_PGXC_COORDINATOR && !IsConnFromCoord() && !PreparePGXCNodes) + if (IS_PGXC_COORDINATOR && !IsConnFromCoord() && !PreparePGXCNodes && contact_gtm) { CommitTranGTM(s->globalTransactionId); latestXid = s->globalTransactionId; } - else if (IS_PGXC_DATANODE || IsConnFromCoord()) + else if ((IS_PGXC_DATANODE || IsConnFromCoord()) && contact_gtm) { /* If we are autovacuum, commit on GTM */ if ((IsAutoVacuumWorkerProcess() || GetForceXidFromGTM()) @@ -2086,7 +2085,7 @@ CommitTransaction(void) * this is made by CommitTransaction when transaction has been committed on Nodes. */ static void -PrepareTransaction(bool write_2pc_file, bool is_implicit) +PrepareTransaction(bool is_implicit) #else static void PrepareTransaction(void) @@ -2222,7 +2221,7 @@ PrepareTransaction(void) * updates, because the transaction manager might get confused if we lose * a global transaction. */ - EndPrepare(gxact, write_2pc_file); + EndPrepare(gxact); /* * Now we clean up backend-internal state and release internal resources. @@ -2273,17 +2272,6 @@ PrepareTransaction(void) #ifdef PGXC /* - * We want to be able to commit a prepared transaction from another coordinator, - * so clean up the gxact in shared memory also. - */ - if (!write_2pc_file) - { - RemoveGXactCoord(gxact); - } -#endif - -#ifdef PGXC - /* * In case of an implicit 2PC, ressources are released by CommitTransaction() */ if (!is_implicit) @@ -2665,6 +2653,9 @@ StartTransactionCommand(void) case TBLOCK_BEGIN: case TBLOCK_SUBBEGIN: case TBLOCK_END: +#ifdef PGXC + case TBLOCK_END_NOT_GTM: +#endif case TBLOCK_SUBEND: case TBLOCK_ABORT_END: case TBLOCK_SUBABORT_END: @@ -2673,9 +2664,6 @@ StartTransactionCommand(void) case TBLOCK_SUBRESTART: case TBLOCK_SUBABORT_RESTART: case TBLOCK_PREPARE: -#ifdef PGXC - case TBLOCK_PREPARE_NO_2PC_FILE: -#endif elog(ERROR, "StartTransactionCommand: unexpected state %s", BlockStateAsString(s->blockState)); break; @@ -2714,7 +2702,11 @@ CommitTransactionCommand(void) * transaction commit, and return to the idle state. */ case TBLOCK_STARTED: +#ifdef PGXC + CommitTransaction(true); +#else CommitTransaction(); +#endif s->blockState = TBLOCK_DEFAULT; break; @@ -2743,10 +2735,20 @@ CommitTransactionCommand(void) * idle state. */ case TBLOCK_END: +#ifdef PGXC + CommitTransaction(true); +#else CommitTransaction(); +#endif s->blockState = TBLOCK_DEFAULT; break; +#ifdef PGXC + case TBLOCK_END_NOT_GTM: + CommitTransaction(false); + s->blockState = TBLOCK_DEFAULT; + break; +#endif /* * Here we are in the middle of a transaction block but one of the * commands caused an abort so we do nothing but remain in the @@ -2782,20 +2784,13 @@ CommitTransactionCommand(void) * return to the idle state. */ case TBLOCK_PREPARE: - PrepareTransaction(true, false); - s->blockState = TBLOCK_DEFAULT; - break; - #ifdef PGXC - /* - * We are complieting a PREPARE TRANSACTION for a pgxc transaction - * that involved DDLs on a Coordinator. - */ - case TBLOCK_PREPARE_NO_2PC_FILE: - PrepareTransaction(false, false); + PrepareTransaction(false); +#else + PrepareTransaction(); +#endif s->blockState = TBLOCK_DEFAULT; break; -#endif /* * We were just issued a SAVEPOINT inside a transaction block. @@ -2824,23 +2819,21 @@ CommitTransactionCommand(void) if (s->blockState == TBLOCK_END) { Assert(s->parent == NULL); +#ifdef PGXC + CommitTransaction(true); +#else CommitTransaction(); +#endif s->blockState = TBLOCK_DEFAULT; } else if (s->blockState == TBLOCK_PREPARE) { Assert(s->parent == NULL); - PrepareTransaction(true, false); - s->blockState = TBLOCK_DEFAULT; - } #ifdef PGXC - else if (s->blockState == TBLOCK_PREPARE_NO_2PC_FILE) - { - Assert(s->parent == NULL); - PrepareTransaction(false, false); + PrepareTransaction(false); +#endif s->blockState = TBLOCK_DEFAULT; } -#endif else { Assert(s->blockState == TBLOCK_INPROGRESS || @@ -2998,6 +2991,9 @@ AbortCurrentTransaction(void) * the transaction). */ case TBLOCK_END: +#ifdef PGXC + case TBLOCK_END_NOT_GTM: +#endif AbortTransaction(); CleanupTransaction(); s->blockState = TBLOCK_DEFAULT; @@ -3038,9 +3034,6 @@ AbortCurrentTransaction(void) * the transaction). */ case TBLOCK_PREPARE: -#ifdef PGXC - case TBLOCK_PREPARE_NO_2PC_FILE: -#endif AbortTransaction(); CleanupTransaction(); s->blockState = TBLOCK_DEFAULT; @@ -3384,6 +3377,9 @@ BeginTransactionBlock(void) case TBLOCK_BEGIN: case TBLOCK_SUBBEGIN: case TBLOCK_END: +#ifdef PGXC + case TBLOCK_END_NOT_GTM: +#endif case TBLOCK_SUBEND: case TBLOCK_ABORT_END: case TBLOCK_SUBABORT_END: @@ -3392,9 +3388,6 @@ BeginTransactionBlock(void) case TBLOCK_SUBRESTART: case TBLOCK_SUBABORT_RESTART: case TBLOCK_PREPARE: -#ifdef PGXC - case TBLOCK_PREPARE_NO_2PC_FILE: -#endif elog(FATAL, "BeginTransactionBlock: unexpected state %s", BlockStateAsString(s->blockState)); break; @@ -3413,19 +3406,18 @@ BeginTransactionBlock(void) * We do it this way because it's not convenient to change memory context, * resource owner, etc while executing inside a Portal. */ -#ifdef PGXC -bool -PrepareTransactionBlock(char *gid, bool write_2pc_file) -#else bool PrepareTransactionBlock(char *gid) -#endif { TransactionState s; bool result; /* Set up to commit the current transaction */ +#ifdef PGXC + result = EndTransactionBlock(true); +#else result = EndTransactionBlock(); +#endif /* If successful, change outer tblock state to PREPARE */ if (result) @@ -3440,16 +3432,6 @@ PrepareTransactionBlock(char *gid) /* Save GID where PrepareTransaction can find it again */ prepareGID = MemoryContextStrdup(TopTransactionContext, gid); -#ifdef PGXC - /* - * For a Postgres-XC Coordinator, prepare is done for a transaction - * if and only if a DDL was involved in the transaction. - * If not, it is enough to prepare it on Datanodes involved only. - */ - if (!write_2pc_file) - s->blockState = TBLOCK_PREPARE_NO_2PC_FILE; - else -#endif s->blockState = TBLOCK_PREPARE; } else @@ -3480,7 +3462,11 @@ PrepareTransactionBlock(char *gid) * resource owner, etc while executing inside a Portal. */ bool +#ifdef PGXC +EndTransactionBlock(bool contact_gtm) +#else EndTransactionBlock(void) +#endif { TransactionState s = CurrentTransactionState; bool result = false; @@ -3492,6 +3478,11 @@ EndTransactionBlock(void) * to COMMIT. */ case TBLOCK_INPROGRESS: +#ifdef PGXC + if (!contact_gtm) + s->blockState = TBLOCK_END_NOT_GTM; + else +#endif s->blockState = TBLOCK_END; result = true; break; @@ -3570,6 +3561,9 @@ EndTransactionBlock(void) case TBLOCK_BEGIN: case TBLOCK_SUBBEGIN: case TBLOCK_END: +#ifdef PGXC + case TBLOCK_END_NOT_GTM: +#endif case TBLOCK_SUBEND: case TBLOCK_ABORT_END: case TBLOCK_SUBABORT_END: @@ -3578,9 +3572,6 @@ EndTransactionBlock(void) case TBLOCK_SUBRESTART: case TBLOCK_SUBABORT_RESTART: case TBLOCK_PREPARE: -#ifdef PGXC - case TBLOCK_PREPARE_NO_2PC_FILE: -#endif elog(FATAL, "EndTransactionBlock: unexpected state %s", BlockStateAsString(s->blockState)); break; @@ -3665,6 +3656,9 @@ UserAbortTransactionBlock(void) case TBLOCK_BEGIN: case TBLOCK_SUBBEGIN: case TBLOCK_END: +#ifdef PGXC + case TBLOCK_END_NOT_GTM: +#endif case TBLOCK_SUBEND: case TBLOCK_ABORT_END: case TBLOCK_SUBABORT_END: @@ -3673,9 +3667,6 @@ UserAbortTransactionBlock(void) case TBLOCK_SUBRESTART: case TBLOCK_SUBABORT_RESTART: case TBLOCK_PREPARE: -#ifdef PGXC - case TBLOCK_PREPARE_NO_2PC_FILE: -#endif elog(FATAL, "UserAbortTransactionBlock: unexpected state %s", BlockStateAsString(s->blockState)); break; @@ -3713,6 +3704,9 @@ DefineSavepoint(char *name) case TBLOCK_BEGIN: case TBLOCK_SUBBEGIN: case TBLOCK_END: +#ifdef PGXC + case TBLOCK_END_NOT_GTM: +#endif case TBLOCK_SUBEND: case TBLOCK_ABORT: case TBLOCK_SUBABORT: @@ -3723,9 +3717,6 @@ DefineSavepoint(char *name) case TBLOCK_SUBRESTART: case TBLOCK_SUBABORT_RESTART: case TBLOCK_PREPARE: -#ifdef PGXC - case TBLOCK_PREPARE_NO_2PC_FILE: -#endif elog(FATAL, "DefineSavepoint: unexpected state %s", BlockStateAsString(s->blockState)); break; @@ -3772,6 +3763,9 @@ ReleaseSavepoint(List *options) case TBLOCK_BEGIN: case TBLOCK_SUBBEGIN: case TBLOCK_END: +#ifdef PGXC + case TBLOCK_END_NOT_GTM: +#endif case TBLOCK_SUBEND: case TBLOCK_ABORT: case TBLOCK_SUBABORT: @@ -3782,9 +3776,6 @@ ReleaseSavepoint(List *options) case TBLOCK_SUBRESTART: case TBLOCK_SUBABORT_RESTART: case TBLOCK_PREPARE: -#ifdef PGXC - case TBLOCK_PREPARE_NO_2PC_FILE: -#endif elog(FATAL, "ReleaseSavepoint: unexpected state %s", BlockStateAsString(s->blockState)); break; @@ -3875,6 +3866,9 @@ RollbackToSavepoint(List *options) case TBLOCK_BEGIN: case TBLOCK_SUBBEGIN: case TBLOCK_END: +#ifdef PGXC + case TBLOCK_END_NOT_GTM: +#endif case TBLOCK_SUBEND: case TBLOCK_ABORT_END: case TBLOCK_SUBABORT_END: @@ -3883,9 +3877,6 @@ RollbackToSavepoint(List *options) case TBLOCK_SUBRESTART: case TBLOCK_SUBABORT_RESTART: case TBLOCK_PREPARE: -#ifdef PGXC - case TBLOCK_PREPARE_NO_2PC_FILE: -#endif elog(FATAL, "RollbackToSavepoint: unexpected state %s", BlockStateAsString(s->blockState)); break; @@ -3968,10 +3959,10 @@ BeginInternalSubTransaction(char *name) case TBLOCK_STARTED: case TBLOCK_INPROGRESS: case TBLOCK_END: - case TBLOCK_PREPARE: #ifdef PGXC - case TBLOCK_PREPARE_NO_2PC_FILE: + case TBLOCK_END_NOT_GTM: #endif + case TBLOCK_PREPARE: case TBLOCK_SUBINPROGRESS: /* Normal subtransaction start */ PushTransaction(); @@ -3984,7 +3975,6 @@ BeginInternalSubTransaction(char *name) if (name) s->name = MemoryContextStrdup(TopTransactionContext, name); break; - /* These cases are invalid. */ case TBLOCK_DEFAULT: case TBLOCK_BEGIN: @@ -4055,6 +4045,9 @@ RollbackAndReleaseCurrentSubTransaction(void) case TBLOCK_SUBBEGIN: case TBLOCK_INPROGRESS: case TBLOCK_END: +#ifdef PGXC + case TBLOCK_END_NOT_GTM: +#endif case TBLOCK_SUBEND: case TBLOCK_ABORT: case TBLOCK_ABORT_END: @@ -4064,9 +4057,6 @@ RollbackAndReleaseCurrentSubTransaction(void) case TBLOCK_SUBRESTART: case TBLOCK_SUBABORT_RESTART: case TBLOCK_PREPARE: -#ifdef PGXC - case TBLOCK_PREPARE_NO_2PC_FILE: -#endif elog(FATAL, "RollbackAndReleaseCurrentSubTransaction: unexpected state %s", BlockStateAsString(s->blockState)); break; @@ -4113,11 +4103,11 @@ AbortOutOfAnyTransaction(void) case TBLOCK_BEGIN: case TBLOCK_INPROGRESS: case TBLOCK_END: - case TBLOCK_ABORT_PENDING: - case TBLOCK_PREPARE: #ifdef PGXC - case TBLOCK_PREPARE_NO_2PC_FILE: + case TBLOCK_END_NOT_GTM: #endif + case TBLOCK_ABORT_PENDING: + case TBLOCK_PREPARE: /* In a transaction, so clean up */ AbortTransaction(); CleanupTransaction(); @@ -4207,11 +4197,11 @@ TransactionBlockStatusCode(void) case TBLOCK_INPROGRESS: case TBLOCK_SUBINPROGRESS: case TBLOCK_END: - case TBLOCK_SUBEND: - case TBLOCK_PREPARE: #ifdef PGXC - case TBLOCK_PREPARE_NO_2PC_FILE: + case TBLOCK_END_NOT_GTM: #endif + case TBLOCK_SUBEND: + case TBLOCK_PREPARE: return 'T'; /* in transaction */ case TBLOCK_ABORT: case TBLOCK_SUBABORT: @@ -4707,10 +4697,10 @@ BlockStateAsString(TBlockState blockState) return "ABORT END"; case TBLOCK_ABORT_PENDING: return "ABORT PEND"; + case TBLOCK_PREPARE: #ifdef PGXC - case TBLOCK_PREPARE_NO_2PC_FILE: + case TBLOCK_END_NOT_GTM: #endif - case TBLOCK_PREPARE: return "PREPARE"; case TBLOCK_SUBBEGIN: return "SUB BEGIN"; diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c index 90c1f81..065d880 100644 --- a/src/backend/tcop/utility.c +++ b/src/backend/tcop/utility.c @@ -335,7 +335,11 @@ ProcessUtility(Node *parsetree, break; case TRANS_STMT_COMMIT: +#ifdef PGXC + if (!EndTransactionBlock(true)) +#else if (!EndTransactionBlock()) +#endif { /* report unsuccessful commit in completionTag */ if (completionTag) @@ -361,16 +365,31 @@ ProcessUtility(Node *parsetree, if (IsConnFromCoord()) operation_local = true; - if (!PrepareTransactionBlock(stmt->gid, operation_local)) + if (operation_local) { -#else +#endif if (!PrepareTransactionBlock(stmt->gid)) { -#endif /* report unsuccessful commit in completionTag */ if (completionTag) strcpy(completionTag, "ROLLBACK"); } +#ifdef PGXC + } + else + { + /* + * In this case commit locally to erase the transaction traces + * but do not contact GTM + */ + if (!EndTransactionBlock(false)) + { + /* report unsuccessful commit in completionTag */ + if (completionTag) + strcpy(completionTag, "ROLLBACK"); + } + } +#endif break; case TRANS_STMT_COMMIT_PREPARED: diff --git a/src/include/access/twophase.h b/src/include/access/twophase.h index 7b78a6d..94df1ad 100644 --- a/src/include/access/twophase.h +++ b/src/include/access/twophase.h @@ -38,13 +38,7 @@ extern GlobalTransaction MarkAsPreparing(TransactionId xid, const char *gid, TimestampTz prepared_at, Oid owner, Oid databaseid); -#ifdef PGXC -extern void RemoveGXactCoord(GlobalTransaction gxact); -extern void EndPrepare(GlobalTransaction gxact, bool write_2pc_file); -#else extern void EndPrepare(GlobalTransaction gxact); -#endif - extern void StartPrepare(GlobalTransaction gxact); extern TransactionId PrescanPreparedTransactions(void); diff --git a/src/include/access/xact.h b/src/include/access/xact.h index 9b2be9f..e7f1089 100644 --- a/src/include/access/xact.h +++ b/src/include/access/xact.h @@ -172,12 +172,12 @@ extern void AbortCurrentTransactionOnce(void); #endif extern void AbortCurrentTransaction(void); extern void BeginTransactionBlock(void); -extern bool EndTransactionBlock(void); #ifdef PGXC -extern bool PrepareTransactionBlock(char *gid, bool write_2pc_file); +extern bool EndTransactionBlock(bool contact_gtm); #else -extern bool PrepareTransactionBlock(char *gid); +extern bool EndTransactionBlock(void); #endif +extern bool PrepareTransactionBlock(char *gid); extern void UserAbortTransactionBlock(void); extern void ReleaseSavepoint(List *options); extern void DefineSavepoint(char *name); ----------------------------------------------------------------------- Summary of changes: src/backend/access/transam/twophase.c | 40 ------- src/backend/access/transam/xact.c | 184 ++++++++++++++++----------------- src/backend/tcop/utility.c | 25 ++++- src/include/access/twophase.h | 6 - src/include/access/xact.h | 6 +- 5 files changed, 112 insertions(+), 149 deletions(-) hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-01 23:27:10
|
Project "Postgres-XC". The branch, ha_support has been updated via 482825deb075f295fc349fa3bb3fda8ca46d92df (commit) from 0941c9d8ff92110c176f8c2a01011b473c2b7951 (commit) - Log ----------------------------------------------------------------- commit 482825deb075f295fc349fa3bb3fda8ca46d92df Author: Michael P <mic...@us...> Date: Wed Mar 2 08:31:27 2011 +0900 Correction of error messages for XCM interface. diff --git a/src/backend/pgxc/pool/mirror.c b/src/backend/pgxc/pool/mirror.c index b7bfbc5..9b22747 100644 --- a/src/backend/pgxc/pool/mirror.c +++ b/src/backend/pgxc/pool/mirror.c @@ -2,10 +2,10 @@ * * mirror.c * - * File containing API to interact with Fault Sync module + * File containing API to interact with XCM module * It is necessary to activate the GUC parameter mirror_mode * to call the APIs of this file. - * Only this file is authorized to call APIs of Fault Sync + * Only this file is authorized to call APIs of XCM * * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group * Portions Copyright (c) 2010-2011 Nippon Telegraph and Telephone Corporation @@ -90,7 +90,7 @@ PGXCMirror_GetPrimaryDatanodeID(void) { int primary_id = 0; /* - * Get the primary node parameters from Fault Sync module + * Get the primary node parameters from XCM module * In other cases GUC params have all the necessary data. */ if (IsXCM) @@ -98,7 +98,7 @@ PGXCMirror_GetPrimaryDatanodeID(void) if (get_xcm_primary_datanode(&primary_id) < 0) ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR), - errmsg("Fault Sync ERROR: could not get primary node ID"))); + errmsg("XCM ERROR: could not get primary node ID"))); } return primary_id; @@ -123,7 +123,7 @@ PGXCMirror_GetPrimaryMirrorID(void) if (get_xcm_primary_mirror(datanode_id, &mirror_id) < 0) ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR), - errmsg("Fault Sync ERROR: could not get primary mirror ID"))); + errmsg("XCM ERROR: could not get primary mirror ID"))); Assert(datanode_id <= NumDataNodes && datanode_id > 0); Assert(mirror_id < PGXCMirror_GetMirrorCount(datanode_id)); @@ -148,7 +148,7 @@ PGXCMirror_GetPreferredNodeID(bool is_datanode) if (get_xcm_preferred_mirror(PGXCNodeId, &datanode_id, &mirror_id) < 0) ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR), - errmsg("Fault Sync ERROR: could not get primary mirror ID"))); + errmsg("XCM ERROR: could not get primary mirror ID"))); Assert(datanode_id <= NumDataNodes && datanode_id > 0); Assert(mirror_id < PGXCMirror_GetMirrorCount(datanode_id)); @@ -191,7 +191,7 @@ PGXCMirror_SetMirrorCountList(void) if (get_xcm_mirror_count(i + 1, &mirror_count) < 0) ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR), - errmsg("Fault Sync ERROR: could not get Mirror count"))); + errmsg("XCM ERROR: could not get Mirror count"))); PGXCNodeMirrorCount[i] = mirror_count; MirrorTotalCount += PGXCNodeMirrorCount[i]; } @@ -683,7 +683,7 @@ PGXCMirror_GetLocalGTMHost(void) if (err < 0) ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR), - errmsg("Fault Sync ERROR: could not get GTM information"))); + errmsg("XCM ERROR: could not get GTM information"))); /* Need Connection points for GTM or Proxy */ if (gtm_id > 0) @@ -720,7 +720,7 @@ PGXCMirror_GetLocalGTMPort(void) if (err < 0) ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR), - errmsg("Fault Sync ERROR: could not get GTM information"))); + errmsg("XCM ERROR: could not get GTM information"))); /* Need Connection points for GTM or Proxy */ if (gtm_id > 0) @@ -778,7 +778,7 @@ PGXCMirror_ReportCoordFail(int pgxc_node_id) if (PGXCMirror_ReportFail(REMOTE_CONN_COORD, pgxc_node_id, 0) < 0) ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR), - errmsg("Fault Sync ERROR: could not report failed Coordinator"))); + errmsg("XCM ERROR: could not report failed Coordinator"))); } void @@ -790,7 +790,7 @@ PGXCMirror_ReportDataNodeFail(int pgxc_node_id, int mirror_id) if (PGXCMirror_ReportFail(REMOTE_CONN_DATANODE, pgxc_node_id, mirror_id) < 0) ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR), - errmsg("Fault Sync ERROR: could not report failed Datanode"))); + errmsg("XCM ERROR: could not report failed Datanode"))); } /* @@ -824,7 +824,7 @@ report_error: if (err < 0) ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR), - errmsg("Fault Sync ERROR: could not report failed GTM"))); + errmsg("XCM ERROR: could not report failed GTM"))); } /* @@ -860,7 +860,7 @@ PGXCMirror_CheckStatus(RemoteConnTypes conn_type, int pgxc_node_id, int mirror_i if (err < 0) ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR), - errmsg("Fault Sync ERROR: could not get Node Status"))); + errmsg("XCM ERROR: could not get Node Status"))); return status; } @@ -1065,7 +1065,7 @@ PGXCMirror_GetConnPoint(RemoteConnTypes conn_type, if (err < 0) ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR), - errmsg("Fault Sync ERROR: could not get Node Host data"))); + errmsg("XCM ERROR: could not get Node Host data"))); return conn_pts; } ----------------------------------------------------------------------- Summary of changes: src/backend/pgxc/pool/mirror.c | 28 ++++++++++++++-------------- 1 files changed, 14 insertions(+), 14 deletions(-) hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-01 07:51:07
|
Project "Postgres-XC". The branch, ha_support has been updated via 0941c9d8ff92110c176f8c2a01011b473c2b7951 (commit) via 21639943c3c4402d029261e143b27733e39c7c07 (commit) from 180e27c030b192a782dc5312420b38caf83abcb8 (commit) - Log ----------------------------------------------------------------- commit 0941c9d8ff92110c176f8c2a01011b473c2b7951 Author: Michael P <mic...@us...> Date: Tue Mar 1 16:53:42 2011 +0900 Fix for XCM used without mirror mode In Normal mode, the static array holding mirror count for each datanode is not set, causing problems a crash on pooler side when XCM is used to build the host and port arrays for Datanodes. diff --git a/src/backend/pgxc/pool/mirror.c b/src/backend/pgxc/pool/mirror.c index fd51b4d..b7bfbc5 100644 --- a/src/backend/pgxc/pool/mirror.c +++ b/src/backend/pgxc/pool/mirror.c @@ -534,12 +534,17 @@ PGXCMirror_GetHostTotalString(RemoteConnTypes conn_type) } else if (conn_type == REMOTE_CONN_DATANODE) { + /* + * If mirror mode is not active, it means that there is only + * 1 single mirror for a datanode, which is the normal mode... + */ + int num_mirrors = IsPGXCMirrorMode ? PGXCNodeMirrorCount[i] : 1; int count; /* Build Datanode Host string */ - Assert(PGXCNodeMirrorCount[i] > 0); + Assert(num_mirrors > 0); - for (count = 0; count < PGXCNodeMirrorCount[i]; count++) + for (count = 0; count < num_mirrors; count++) { int local_len; char *buf; @@ -614,12 +619,17 @@ PGXCMirror_GetPortTotalString(RemoteConnTypes conn_type) } else if (conn_type == REMOTE_CONN_DATANODE) { + /* + * If mirror mode is not active, it means that there is only + * 1 single mirror for a datanode, which is the normal mode... + */ + int num_mirrors = IsPGXCMirrorMode ? PGXCNodeMirrorCount[i] : 1; int count; /* Build Datanode Host string */ - Assert(PGXCNodeMirrorCount[i] > 0); + Assert(num_mirrors > 0); - for (count = 0; count < PGXCNodeMirrorCount[i]; count++) + for (count = 0; count < num_mirrors; count++) { int local_len; char *buf; commit 21639943c3c4402d029261e143b27733e39c7c07 Author: Michael P <mic...@us...> Date: Tue Mar 1 16:43:20 2011 +0900 Fix to avoid Datanodes to unregister if they are not primary diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index 71da4c2..984b3be 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -2215,7 +2215,7 @@ pmdie(SIGNAL_ARGS) /* Unregister Node on GTM */ if (IS_PGXC_COORDINATOR) UnregisterGTM(PGXC_NODE_COORDINATOR); - else if (IS_PGXC_DATANODE) + else if (IS_PGXC_DATANODE && IsPrimaryMirror) UnregisterGTM(PGXC_NODE_DATANODE); #endif pmState = PM_WAIT_BACKUP; @@ -2273,7 +2273,7 @@ pmdie(SIGNAL_ARGS) /* Unregister Node on GTM */ if (IS_PGXC_COORDINATOR) UnregisterGTM(PGXC_NODE_COORDINATOR); - else if (IS_PGXC_DATANODE) + else if (IS_PGXC_DATANODE && IsPrimaryMirror) UnregisterGTM(PGXC_NODE_DATANODE); #endif pmState = PM_WAIT_BACKENDS; ----------------------------------------------------------------------- Summary of changes: src/backend/pgxc/pool/mirror.c | 18 ++++++++++++++---- src/backend/postmaster/postmaster.c | 4 ++-- 2 files changed, 16 insertions(+), 6 deletions(-) hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-01 01:44:56
|
Project "Postgres-XC". The branch, ha_support has been updated via 180e27c030b192a782dc5312420b38caf83abcb8 (commit) via 162d967054136baf6bc9cc35f286c771197af71b (commit) via 51cabe99e820989af4634ef7113a294563e8820c (commit) from bd357d3c92dcd3d7bb82ba63d942ba3841cff751 (commit) - Log ----------------------------------------------------------------- commit 180e27c030b192a782dc5312420b38caf83abcb8 Merge: 162d967 51cabe9 Author: Michael P <mic...@us...> Date: Tue Mar 1 10:49:45 2011 +0900 Merge branch 'master' into ha_support Conflicts: src/backend/pgxc/pool/execRemote.c diff --cc src/backend/pgxc/pool/execRemote.c index 4570bdf,dc1d68c..809d08f --- a/src/backend/pgxc/pool/execRemote.c +++ b/src/backend/pgxc/pool/execRemote.c @@@ -4607,93 -4572,54 +4607,146 @@@ PGXCNodeGetNodeList(PGXC_NodeId **datan } /* + * Build 2PC Data. + * This is made by a remote Coordinator that is preparing in PrepareTransaction() + * or in CommitTransaction for a Coordinator not preparing. + * + * Data has to be built before sending it to backend nodes. + */ +void +PGXCNode_Build2PCData(bool isimplicit) +{ + PGXCNodeAllHandles *pgxc_handles = pgxc_get_all_transaction_nodes(false); + int co_conn_count = pgxc_handles->co_conn_count; + int dn_conn_count = pgxc_handles->dn_conn_count; + PGXC_NodeId *datanodes = NULL; + int i; + + PGXC_2PCData = (Remote2PCData *) malloc(sizeof(Remote2PCData)); + + PGXC_2PCData->isddl = co_conn_count > 0; + PGXC_2PCData->isimplicit = isimplicit; + PGXC_2PCData->coordnum = PGXCNodeId; + PGXC_2PCData->nodelist = NULL; + + /* + * Build the node list string. + * Format is guc based nodenum1,nodenum2,...,nodenumN + */ + if (dn_conn_count != 0) + { + char buffer[NODELISTSIZE]; + + datanodes = collect_pgxcnode_numbers(dn_conn_count, + pgxc_handles->datanode_handles, REMOTE_CONN_DATANODE); + + sprintf(buffer, "%d", datanodes[0]); + + for (i = 1; i < dn_conn_count; i++) + { + sprintf(buffer, "%s,%d", buffer, datanodes[i]); + } + + PGXC_2PCData->nodelist = (char *) malloc(strlen(buffer) + 1); + memcpy(PGXC_2PCData->nodelist, buffer, strlen(buffer) + 1); + } + else + { + /* This case corresponds to Sequence DDL where only Coordinators are prepared */ + PGXC_2PCData->nodelist = (char *) malloc(2); + sprintf(PGXC_2PCData->nodelist,"n"); + PGXC_2PCData->nodelist[1] = '\0'; + } +} + +/* + * Set 2PC Data received from remote Coordinator. + * This can just be called by a backend node. + */ +void +PGXCNode_Set2PCData(bool isddl, bool isimplicit, int coordnum, const char *nodelist) +{ + PGXC_2PCData = (Remote2PCData *) malloc(sizeof(Remote2PCData)); + + /* Fill in 2PC Data received from other node */ + PGXC_2PCData->isddl = isddl; + PGXC_2PCData->isimplicit = isimplicit; + PGXC_2PCData->coordnum = coordnum; + + PGXC_2PCData->nodelist = (char *) malloc(strlen(nodelist) + 1); + memcpy(PGXC_2PCData->nodelist, nodelist, strlen(nodelist) + 1); +} + +void +PGXCNode_Unset2PCData(void) +{ + if (PGXC_2PCData) + { + if (PGXC_2PCData->nodelist) + free(PGXC_2PCData->nodelist); + free(PGXC_2PCData); + } +} + +/* + * Return 2PC Data necessary to mark the transaction as preparing + * This data is saved in the static list of prepared xacts when marked as preparing. + */ +Remote2PCData* +PGXCNode_Get2PCData(void) +{ + return PGXC_2PCData; +} ++ ++/* + * DataNodeCopyInBinaryForAll + * + * In a COPY TO, send to all datanodes PG_HEADER for a COPY TO in binary mode. + */ + int DataNodeCopyInBinaryForAll(char *msg_buf, int len, PGXCNodeHandle** copy_connections) + { + int i; + int conn_count = 0; + PGXCNodeHandle *connections[NumDataNodes]; + int msgLen = 4 + len + 1; + int nLen = htonl(msgLen); + + for (i = 0; i < NumDataNodes; i++) + { + PGXCNodeHandle *handle = copy_connections[i]; + + if (!handle) + continue; + + connections[conn_count++] = handle; + } + + for (i = 0; i < conn_count; i++) + { + PGXCNodeHandle *handle = connections[i]; + if (handle->state == DN_CONNECTION_STATE_COPY_IN) + { + /* msgType + msgLen */ + if (ensure_out_buffer_capacity(handle->outEnd + 1 + msgLen, handle) != 0) + { + ereport(ERROR, + (errcode(ERRCODE_OUT_OF_MEMORY), + errmsg("out of memory"))); + } + + handle->outBuffer[handle->outEnd++] = 'd'; + memcpy(handle->outBuffer + handle->outEnd, &nLen, 4); + handle->outEnd += 4; + memcpy(handle->outBuffer + handle->outEnd, msg_buf, len); + handle->outEnd += len; + handle->outBuffer[handle->outEnd++] = '\n'; + } + else + { + add_error_message(handle, "Invalid data node connection"); + return EOF; + } + } + + return 0; + } commit 162d967054136baf6bc9cc35f286c771197af71b Author: Michael P <mic...@us...> Date: Tue Mar 1 10:41:40 2011 +0900 Correction for EXECUTE DIRECT For an EXECUTE DIRECT on a backend Coordinator, the node list was not set correctly, causing XCM to return an error due to an incorrect node number. There is also a fix for utility statements on backend mirrors so as to launch the utility on all the mirrors when not choosing a node number. diff --git a/src/backend/parser/analyze.c b/src/backend/parser/analyze.c index 9cd45a1..ca715e0 100644 --- a/src/backend/parser/analyze.c +++ b/src/backend/parser/analyze.c @@ -2115,12 +2115,14 @@ transformExecDirectStmt(ParseState *pstate, ExecDirectStmt *stmt) (errcode(ERRCODE_INTERNAL_ERROR), errmsg("Cannot use Mirror ID format for Coordinator"))); - if (node->data_node_id > NumDataNodes) + if (node->data_node_id > NumDataNodes || + node->data_node_id < 1) ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR), errmsg("Node Number %d is incorrect", node->data_node_id))); - if (node->mirror_id > PGXCMirror_GetMirrorCount(node->data_node_id)) + if (node->mirror_id > PGXCMirror_GetMirrorCount(node->data_node_id) || + node->mirror_id < 1) ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR), errmsg("Mirror Number %d is incorrect", node->mirror_id))); @@ -2144,6 +2146,7 @@ transformExecDirectStmt(ParseState *pstate, ExecDirectStmt *stmt) else { int nodenum = intVal(lfirst(nodeitem)); + if (nodenum < 1 || (!is_coordinator && nodenum > total_num_nodes) || (is_coordinator && nodenum > total_num_nodes)) @@ -2266,14 +2269,17 @@ transformExecDirectStmt(ParseState *pstate, ExecDirectStmt *stmt) * for a SELECT command pick up only one node in the subset * for a UTILITY command pick up the whole subset * If node number is mirror format dn_id/mirror_id, keep it as it is. + * For a Coordinator, just use the node number. */ - if (step->exec_direct_type == EXEC_DIRECT_LOCAL_UTILITY && + if (step->exec_direct_type == EXEC_DIRECT_UTILITY && IsPGXCMirrorMode && - !nodenum_defined) + !nodenum_defined && + !is_coordinator) step->exec_nodes->nodelist = PGXCMirror_GetSubsetMirrors(nodenum, true); else if (step->exec_direct_type == EXEC_DIRECT_SELECT && IsPGXCMirrorMode && - !nodenum_defined) + !nodenum_defined && + !is_coordinator) step->exec_nodes->nodelist = PGXCMirror_GetSubsetMirrors(nodenum, false); else if (nodenum_defined) /* Node Number where to run has already been calculated */ step->exec_nodes->nodelist = lappend_int(step->exec_nodes->nodelist, nodenum_real); ----------------------------------------------------------------------- Summary of changes: src/backend/commands/copy.c | 90 ++++++++++++++++++++++++++++++++++++ src/backend/parser/analyze.c | 16 ++++-- src/backend/pgxc/pool/execRemote.c | 53 +++++++++++++++++++++ src/include/pgxc/execRemote.h | 1 + 4 files changed, 155 insertions(+), 5 deletions(-) hooks/post-receive -- Postgres-XC |