diff options
| author | Mason Sharp | 2014-12-21 15:31:36 +0000 |
|---|---|---|
| committer | Pavan Deolasee | 2015-04-15 05:46:43 +0000 |
| commit | 016817e5297e414a2cf4eae3c275f7ac3df78bd9 (patch) | |
| tree | 12e2ecadc52949637c8adadfc63bdaa597281865 /src | |
| parent | dac362024acb8bebdb9d508bc1d7f4818db82317 (diff) | |
Clean up freeing list of connections.
While hunting for a memory leak, found this smaller one.
Diffstat (limited to 'src')
| -rw-r--r-- | src/backend/pgxc/pool/execRemote.c | 38 | ||||
| -rw-r--r-- | src/backend/pgxc/pool/pgxcnode.c | 4 |
2 files changed, 26 insertions, 16 deletions
diff --git a/src/backend/pgxc/pool/execRemote.c b/src/backend/pgxc/pool/execRemote.c index a807dcfa7d..54405b397e 100644 --- a/src/backend/pgxc/pool/execRemote.c +++ b/src/backend/pgxc/pool/execRemote.c @@ -2856,6 +2856,7 @@ pgxc_node_remote_cleanup_all(void) pgxc_node_receive_responses(new_conn_count, new_connections, NULL, &combiner); CloseCombiner(&combiner); } + pfree_pgxc_all_handles(handles); } @@ -3073,6 +3074,7 @@ pgxc_node_remote_prepare(char *prepareGID, bool localNode) if (!isOK) goto prepare_err; + /* exit if nothing has been prepared */ if (conn_count > 0) { @@ -3211,6 +3213,9 @@ prepare_err: pgxc_node_receive_responses(conn_count, connections, NULL, &combiner2); CloseCombiner(&combiner2); } + + pfree_pgxc_all_handles(handles); + /* * If the flag is set we are here because combiner carries error message */ @@ -3356,6 +3361,8 @@ pgxc_node_remote_commit(void) pgxc_node_remote_cleanup_all(); release_handles(); } + + pfree_pgxc_all_handles(handles); } @@ -3456,6 +3463,8 @@ pgxc_node_remote_abort(void) (errcode(ERRCODE_INTERNAL_ERROR), errmsg("Failed to ROLLBACK the transaction on one or more nodes"))); } + + pfree_pgxc_all_handles(handles); } #else @@ -5859,7 +5868,10 @@ ExecRemoteUtility(RemoteQuery *node) #ifdef XCP /* exit right away if no nodes to run command on */ if (dn_conn_count == 0 && co_conn_count == 0) + { + pfree_pgxc_all_handles(pgxc_connections); return; + } #endif if (force_autocommit) @@ -6081,12 +6093,14 @@ ExecRemoteUtility(RemoteQuery *node) } } } + /* * 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. */ #ifdef XCP + pfree_pgxc_all_handles(pgxc_connections); pgxc_node_report_error(combiner); #else pgxc_node_report_error(remotestate); @@ -6631,8 +6645,6 @@ PreAbort_Remote(void) } } - pfree_pgxc_all_handles(all_handles); - /* * Now read and discard any data from the connections found "dirty" */ @@ -6665,6 +6677,8 @@ PreAbort_Remote(void) pgxc_node_remote_cleanup_all(); release_handles(); } + + pfree_pgxc_all_handles(all_handles); #else if (IS_PGXC_COORDINATOR && !IsConnFromCoord()) { @@ -7252,14 +7266,14 @@ pgxc_node_remote_finish(char *prepareGID, bool commit, CloseCombiner(&combiner); } - pfree_pgxc_all_handles(pgxc_handles); - if (!temp_object_included && !PersistentConnections) { /* Clean up remote sessions */ pgxc_node_remote_cleanup_all(); release_handles(); } + + pfree_pgxc_all_handles(pgxc_handles); #else /* * Now get handles for all the involved Datanodes and the Coordinators @@ -7404,6 +7418,7 @@ ExecRemoteQuery(RemoteQueryState *node) ResponseCombiner *combiner = (ResponseCombiner *) node; RemoteQuery *step = (RemoteQuery *) combiner->ss.ps.plan; TupleTableSlot *resultslot = combiner->ss.ps.ps_ResultTupleSlot; + if (!node->query_Done) { GlobalTransactionId gxid = InvalidGlobalTransactionId; @@ -7442,8 +7457,6 @@ ExecRemoteQuery(RemoteQueryState *node) if (primaryconnection) regular_conn_count--; - pfree(pgxc_connections); - /* * We save only regular connections, at the time we exit the function * we finish with the primary connection and deal only with regular @@ -7469,9 +7482,7 @@ ExecRemoteQuery(RemoteQueryState *node) if (!GlobalTransactionIdIsValid(gxid)) { - if (primaryconnection) - pfree(primaryconnection); - pfree(connections); + pfree_pgxc_all_handles(pgxc_connections); ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR), errmsg("Failed to get next transaction ID"))); @@ -7489,8 +7500,7 @@ ExecRemoteQuery(RemoteQueryState *node) /* If explicit transaction is needed gxid is already sent */ if (!pgxc_start_command_on_connection(primaryconnection, node, snapshot)) { - pfree(connections); - pfree(primaryconnection); + pfree_pgxc_all_handles(pgxc_connections); ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR), errmsg("Failed to send command to data nodes"))); @@ -7539,9 +7549,7 @@ ExecRemoteQuery(RemoteQueryState *node) /* If explicit transaction is needed gxid is already sent */ if (!pgxc_start_command_on_connection(connections[i], node, snapshot)) { - pfree(connections); - if (primaryconnection) - pfree(primaryconnection); + pfree_pgxc_all_handles(pgxc_connections); ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR), errmsg("Failed to send command to data nodes"))); @@ -9221,6 +9229,8 @@ pgxc_all_success_nodes(ExecNodes **d_nodes, ExecNodes **c_nodes, char **failedno *failednodes_msg = NULL; else *failednodes_msg = failednodes.data; + + pfree_pgxc_all_handles(connections); } diff --git a/src/backend/pgxc/pool/pgxcnode.c b/src/backend/pgxc/pool/pgxcnode.c index 7a01b18977..bef6c95b4c 100644 --- a/src/backend/pgxc/pool/pgxcnode.c +++ b/src/backend/pgxc/pool/pgxcnode.c @@ -2449,9 +2449,9 @@ pfree_pgxc_all_handles(PGXCNodeAllHandles *pgxc_handles) if (pgxc_handles->primary_handle) pfree(pgxc_handles->primary_handle); - if (pgxc_handles->datanode_handles && pgxc_handles->dn_conn_count != 0) + if (pgxc_handles->datanode_handles) pfree(pgxc_handles->datanode_handles); - if (pgxc_handles->coord_handles && pgxc_handles->co_conn_count != 0) + if (pgxc_handles->coord_handles) pfree(pgxc_handles->coord_handles); pfree(pgxc_handles); |
