diff --git a/source/libs/function/src/builtinsimpl.c b/source/libs/function/src/builtinsimpl.c index 76be8a05c549ee19cee1e647b1ae3387fa613e98..a69d2924a98a93c669c8bac3fa7cda8c60c1b5da 100644 --- a/source/libs/function/src/builtinsimpl.c +++ b/source/libs/function/src/builtinsimpl.c @@ -2529,6 +2529,9 @@ int32_t apercentileFunction(SqlFunctionCtx* pCtx) { qDebug("%s before add %d elements into histogram, total:%d, numOfEntry:%d, pHisto:%p, elems: %p", __FUNCTION__, numOfElems, pInfo->pHisto->numOfElems, pInfo->pHisto->numOfEntries, pInfo->pHisto, pInfo->pHisto->elems); + // might be a race condition here that pHisto can be overwritten or setup function + // has not been called, need to relink the buffer pHisto points to. + buildHistogramInfo(pInfo); for (int32_t i = start; i < pInput->numOfRows + start; ++i) { if (colDataIsNull_f(pCol->nullbitmap, i)) { continue;