Skip to content

Force-close max-autoconsume drains #5263

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions cdb2api/cdb2api.c
Original file line number Diff line number Diff line change
Expand Up @@ -2543,7 +2543,7 @@ static int newsql_connect(cdb2_hndl_tp *hndl, int node_indx)
return rc;
}

static void newsql_disconnect(cdb2_hndl_tp *hndl, SBUF2 *sb, int line)
static void newsql_disconnect_int(cdb2_hndl_tp *hndl, SBUF2 *sb, int line, int dontdonate)
{
if (sb == NULL)
return;
Expand All @@ -2553,13 +2553,10 @@ static void newsql_disconnect(cdb2_hndl_tp *hndl, SBUF2 *sb, int line)
int fd = sbuf2fileno(sb);

int timeoutms = 10 * 1000;
if (hndl->is_admin ||
if (hndl->is_admin || dontdonate ||
(hndl->firstresponse &&
(!hndl->lastresponse ||
(hndl->lastresponse->response_type != RESPONSE_TYPE__LAST_ROW))) ||
(!hndl->firstresponse) ||
(hndl->in_trans) ||
((hndl->flags & CDB2_TYPE_IS_FD) != 0)) {
(!hndl->lastresponse || (hndl->lastresponse->response_type != RESPONSE_TYPE__LAST_ROW))) ||
(!hndl->firstresponse) || (hndl->in_trans) || ((hndl->flags & CDB2_TYPE_IS_FD) != 0)) {
sbuf2close(sb);
} else if (sbuf2free(sb) == 0) {
cdb2_socket_pool_donate_ext(hndl->newsql_typestr, fd, timeoutms / 1000,
Expand All @@ -2570,9 +2567,13 @@ static void newsql_disconnect(cdb2_hndl_tp *hndl, SBUF2 *sb, int line)
return;
}

static void newsql_disconnect(cdb2_hndl_tp *hndl, SBUF2 *sb, int line)
{
return newsql_disconnect_int(hndl, sb, line, 0);
}

/* returns port number, or -1 for error*/
static int cdb2portmux_get(cdb2_hndl_tp *hndl, const char *type,
const char *remote_host, const char *app,
static int cdb2portmux_get(cdb2_hndl_tp *hndl, const char *type, const char *remote_host, const char *app,
const char *service, const char *instance)
{
char name[128]; /* app/service/dbname */
Expand Down Expand Up @@ -4457,7 +4458,7 @@ static inline void consume_previous_query(cdb2_hndl_tp *hndl)
while (cdb2_next_record_int(hndl, 0) == CDB2_OK) {
hardbound++;
if (hardbound > hndl->max_auto_consume_rows) {
newsql_disconnect(hndl, hndl->sb, __LINE__);
newsql_disconnect_int(hndl, hndl->sb, __LINE__, 1);
break;
}
}
Expand Down