diff --git a/src/inc/tglobalcfg.h b/src/inc/tglobalcfg.h index 16cb4898d50a6a77f9f6cc9f7f5829dfebf6fb17..fdfdb0104fc690d43461e52b24802dd3c0884d1c 100644 --- a/src/inc/tglobalcfg.h +++ b/src/inc/tglobalcfg.h @@ -110,6 +110,7 @@ extern int tsMgmtEqualVnodeNum; extern int tsEnableHttpModule; extern int tsEnableMonitorModule; +extern int tsRestRowLimit; extern int tsTimePrecision; extern int tsMinSlidingTime; diff --git a/src/modules/http/src/restJson.c b/src/modules/http/src/restJson.c index d03045ad1a0af4f1fd67278127beaa10bb06a0da..865e862b0f387b4ab4029cf232e5661ed55abd5b 100644 --- a/src/modules/http/src/restJson.c +++ b/src/modules/http/src/restJson.c @@ -148,9 +148,23 @@ bool restBuildSqlJson(HttpContext *pContext, HttpSqlCmd *cmd, TAOS_RES *result, httpJsonToken(jsonBuf, JsonArrEnd); } - httpTrace("context:%p, fd:%d, ip:%s, user:%s, total rows:%lld retrieved", pContext, pContext->fd, pContext->ipstr, - pContext->user, cmd->numOfRows); - return true; + if (cmd->numOfRows >= tsRestRowLimit) { + httpTrace("context:%p, fd:%d, ip:%s, user:%s, retrieve rows:%lld larger than limit:%d, abort retrieve", pContext, + pContext->fd, pContext->ipstr, pContext->user, cmd->numOfRows, tsRestRowLimit); + return false; + } + else { + if (pContext->fd <= 0) { + httpError("context:%p, fd:%d, ip:%s, user:%s, connection is closed, abort retrieve", pContext, pContext->fd, + pContext->ipstr, pContext->user); + return false; + } + else { + httpTrace("context:%p, fd:%d, ip:%s, user:%s, total rows:%lld retrieved", pContext, pContext->fd, pContext->ipstr, + pContext->user, cmd->numOfRows); + return true; + } + } } bool restBuildSqlTimeJson(HttpContext *pContext, HttpSqlCmd *cmd, TAOS_RES *result, int numOfRows) { diff --git a/src/util/src/tglobalcfg.c b/src/util/src/tglobalcfg.c index dddadfb7b3c79001b024f7eb657e62965de78361..abebe475f9f5768290b4d5f4586718883c3fceeb 100644 --- a/src/util/src/tglobalcfg.c +++ b/src/util/src/tglobalcfg.c @@ -98,6 +98,7 @@ int tsMaxVnodeConnections = 10000; int tsEnableHttpModule = 1; int tsEnableMonitorModule = 1; +int tsRestRowLimit = 10240; int tsTimePrecision = TSDB_TIME_PRECISION_MILLI; // time precision, millisecond by default int tsMinSlidingTime = 10; // 10 ms for sliding time, the value will changed in