[Postgres-xl-developers] [patch]catch and report error when init connection on coord

Jov amutu at amutu.com
Thu Dec 18 20:53:41 PST 2014


problem desc:
pgxl init datanode connection with set global_session,this set stmt can be
failed on datanode(for example:if the datanode do not have the coord info
on it's pgxc_node,it will report error such as ""node ""coord1_2118"" does
not exist"" when running the set cmd),but the error on datanode do not
catch on the coord.So if you run a insert stmt on the coord,it will not
report error,but the data do in the table.

this patch fix it by catch and report error:

> postgres=# insert into kv values(11,'3_11');
> ERROR:  Could not begin transaction on data node.


diff --git a/src/backend/pgxc/pool/pgxcnode.c
b/src/backend/pgxc/pool/pgxcnode.c
index 7a01b18..7b816bb 100644
--- a/src/backend/pgxc/pool/pgxcnode.c
+++ b/src/backend/pgxc/pool/pgxcnode.c
@@ -2885,9 +2885,18 @@ pgxc_node_set_query(PGXCNodeHandle *handle, const
char *set_query)
                        continue;
                }
                msgtype = get_message(handle, &msglen, &msg);
+
                /*
-                * Ignore any response except ReadyForQuery, it allows to
go on.
+                * Ignore any response except ErrorResponse and
ReadyForQuery, it allows to go on.
                 */
+
+               if (msgtype == 'E')         /* ErrorResponse */
+               {
+                   handle->error = pstrdup(msg);
+                   handle->state = DN_CONNECTION_STATE_ERROR_FATAL;
+                   break;
+               }
+
                if (msgtype == 'Z') /* ReadyForQuery */
                {
                        handle->transaction_status = msg[0];

Jov
blog: http:amutu.com/blog <http://amutu.com/blog>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.postgres-xl.org/private.cgi/postgres-xl-developers-postgres-xl.org/attachments/20141219/6ad3d112/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: catch_init_error.patch
Type: application/octet-stream
Size: 772 bytes
Desc: not available
URL: <http://lists.postgres-xl.org/private.cgi/postgres-xl-developers-postgres-xl.org/attachments/20141219/6ad3d112/attachment.obj>


More information about the Postgres-xl-developers mailing list