From 82317294ba82d4931e8f53037bad780153e6abc4 Mon Sep 17 00:00:00 2001 From: lihui Date: Thu, 9 Jan 2020 10:35:47 +0800 Subject: [PATCH] [#1102] --- src/client/inc/tsclient.h | 1 + src/client/src/tscParseInsert.c | 10 ++++++---- src/client/src/tscUtil.c | 1 + 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/client/inc/tsclient.h b/src/client/inc/tsclient.h index 6df78f6b7b..9116a7c60b 100644 --- a/src/client/inc/tsclient.h +++ b/src/client/inc/tsclient.h @@ -239,6 +239,7 @@ typedef struct STableDataBlocks { int32_t rowSize; // row size for current table uint32_t nAllocSize; + uint32_t headerSize; // header for metadata (submit metadata) uint32_t size; /* diff --git a/src/client/src/tscParseInsert.c b/src/client/src/tscParseInsert.c index f0824959b0..d9c86a955e 100644 --- a/src/client/src/tscParseInsert.c +++ b/src/client/src/tscParseInsert.c @@ -579,7 +579,8 @@ int32_t tscAllocateMemIfNeed(STableDataBlocks *pDataBlock, int32_t rowSize, int3 size_t remain = pDataBlock->nAllocSize - pDataBlock->size; const int factor = 5; uint32_t nAllocSizeOld = pDataBlock->nAllocSize; - + assert(pDataBlock->headerSize >= 0); + // expand the allocated size if (remain < rowSize * factor) { while (remain < rowSize * factor) { @@ -595,12 +596,12 @@ int32_t tscAllocateMemIfNeed(STableDataBlocks *pDataBlock, int32_t rowSize, int3 //assert(false); // do nothing pDataBlock->nAllocSize = nAllocSizeOld; - *numOfRows = (int32_t)(pDataBlock->nAllocSize) / rowSize; + *numOfRows = (int32_t)(pDataBlock->nAllocSize - pDataBlock->headerSize) / rowSize; return TSDB_CODE_CLI_OUT_OF_MEMORY; } } - *numOfRows = (int32_t)(pDataBlock->nAllocSize) / rowSize; + *numOfRows = (int32_t)(pDataBlock->nAllocSize - pDataBlock->headerSize) / rowSize; return TSDB_CODE_SUCCESS; } @@ -908,6 +909,7 @@ static int32_t tscParseSqlForCreateTableOnDemand(char **sqlstr, SSqlObj *pSql) { createTable = true; code = tscGetMeterMetaEx(pSql, pMeterMetaInfo->name, true); + if (TSDB_CODE_ACTION_IN_PROGRESS == code) return code; } else { if (cstart != NULL) { sql = cstart; @@ -1015,7 +1017,7 @@ int doParserInsertSql(SSqlObj *pSql, char *str) { tscTrace("async insert and waiting to get meter meta, then continue parse sql from offset: %" PRId64, pos); return code; } - tscTrace("async insert parse error, code:%d, %s", code, tsError[code]); + tscError("async insert parse error, code:%d, %s", code, tsError[code]); pSql->asyncTblPos = NULL; goto _error_clean; // TODO: should _clean or _error_clean to async flow ???? } else { diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index bc6c73aaae..5116b01418 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -598,6 +598,7 @@ int32_t tscCreateDataBlock(size_t initialSize, int32_t rowSize, int32_t startOff } dataBuf->nAllocSize = (uint32_t)initialSize; + dataBuf->headerSize = startOffset; // the header size will always be the startOffset value, reserved for the subumit block header dataBuf->pData = calloc(1, dataBuf->nAllocSize); dataBuf->ordered = true; dataBuf->prevTS = INT64_MIN; -- GitLab