Try to validate the combiner only when a RESPONSE_COPY is received during
authorPavan Deolasee <[email protected]>
Mon, 3 Apr 2017 17:06:19 +0000 (22:36 +0530)
committerPavan Deolasee <[email protected]>
Fri, 5 May 2017 04:59:34 +0000 (10:29 +0530)
running COPY protocol.

We sometimes do see a 'M' message (command ID received from the remote node)
from the datanode and that breaks the combiner validation message. So we only
do that if we received a RESPONSE_COPY message during COPY IN protocol.

src/backend/pgxc/pool/execRemote.c

index 02bfb6c0d353207c54134498d94c56ced311ab99..9cf3541ac75d27c55a68ba7a0b6396ff75b64d5c 100644 (file)
@@ -2900,8 +2900,22 @@ DataNodeCopyIn(char *data_row, int len,
                                         * Make sure there are zeroes in unused fields
                                         */
                                        memset(&combiner, 0, sizeof(ScanState));
-                                       handle_response(handle, &combiner);
-                                       if (!ValidateAndCloseCombiner(&combiner))
+
+                                       /*
+                                        * Validate the combiner but only if we see a proper
+                                        * resposne for our COPY message. The problem is that
+                                        * sometimes we might receive async messages such as
+                                        * 'M' which is used to send back command ID generated and
+                                        * consumed by the datanode. While the message gets handled
+                                        * in handle_response(), we don't want to declare receipt
+                                        * of an invalid message below.
+                                        *
+                                        * If there is an actual error of some sort then the
+                                        * connection state is will be set appropriately and we
+                                        * shall catch that subsequently.
+                                        */
+                                       if (handle_response(handle, &combiner) == RESPONSE_COPY &&
+                                               !ValidateAndCloseCombiner(&combiner))
                                                return EOF;
                                }