From 75cb0f686d1d5d8e2a348b159d08e4cefcebbcfb Mon Sep 17 00:00:00 2001 From: freemandealer Date: Sun, 5 Mar 2023 19:02:15 +0800 Subject: [PATCH] [fix](segcompaction) core when doing segcompaction for cancelling load(#16731) segcompaction is async and in parallel with load job. If the load job is canncelling, memory structures will be destroyed and cause segcompaction crash. This commit will wait segcompaction finished before destruction. --- be/src/olap/rowset/beta_rowset_writer.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/be/src/olap/rowset/beta_rowset_writer.cpp b/be/src/olap/rowset/beta_rowset_writer.cpp index 91a97745605e01..684d42a1f829ef 100644 --- a/be/src/olap/rowset/beta_rowset_writer.cpp +++ b/be/src/olap/rowset/beta_rowset_writer.cpp @@ -62,7 +62,11 @@ BetaRowsetWriter::BetaRowsetWriter() } BetaRowsetWriter::~BetaRowsetWriter() { - // OLAP_UNUSED_ARG(_wait_flying_segcompaction()); + /* Note that segcompaction is async and in parallel with load job. So we should handle carefully + * when the job is cancelled. Although it is meaningless to continue segcompaction when the job + * is cancelled, the objects involved in the job should be preserved during segcompaction to + * avoid crashs for memory issues. */ + OLAP_UNUSED_ARG(_wait_flying_segcompaction()); // TODO(lingbin): Should wrapper exception logic, no need to know file ops directly. if (!_already_built) { // abnormal exit, remove all files generated