Skip to content

Commit 9e62e97

Browse files
committed
Modify test_memindex, fix lock-order-inversion
1 parent 7316618 commit 9e62e97

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

python/restart_test/test_memidx.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ def part1(infinity_obj):
539539
table_obj2.insert([{"c1": 4, "c2": [0.2, 0.1, 0.3, 0.4]} for i in range(6)])
540540

541541
# wait for mem index dump
542-
time.sleep(3)
542+
time.sleep(10)
543543

544544
# 2 chunk indexes for each index
545545
db1_dir = data_dir + "/db_2"
@@ -554,7 +554,7 @@ def part1(infinity_obj):
554554
@decorator2
555555
def part2(infinity_obj):
556556
# wait for optimize
557-
time.sleep(3)
557+
time.sleep(20)
558558

559559
# new chunk index is generated after optimize for each index
560560
db1_dir = data_dir + "/db_2"

src/storage/catalog/meta/block_meta_impl.cpp

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -268,19 +268,24 @@ std::string BlockMeta::GetBlockTag(const std::string &tag) const {
268268
}
269269

270270
std::tuple<size_t, Status> BlockMeta::GetRowCnt1() {
271-
std::lock_guard<std::mutex> lock(mtx_);
272-
if (row_cnt_) {
273-
return {*row_cnt_, Status::OK()};
271+
{
272+
std::lock_guard<std::mutex> lock(mtx_);
273+
if (row_cnt_) {
274+
return {*row_cnt_, Status::OK()};
275+
}
274276
}
275277
#if 1
276278
TableMeeta &table_meta = segment_meta_.table_meta();
277-
row_cnt_ = infinity::GetBlockRowCount(&kv_instance_,
278-
table_meta.db_id_str(),
279-
table_meta.table_id_str(),
280-
segment_meta_.segment_id(),
281-
block_id_,
282-
begin_ts_,
283-
commit_ts_);
279+
auto row_cnt = infinity::GetBlockRowCount(&kv_instance_,
280+
table_meta.db_id_str(),
281+
table_meta.table_id_str(),
282+
segment_meta_.segment_id(),
283+
block_id_,
284+
begin_ts_,
285+
commit_ts_);
286+
287+
std::lock_guard<std::mutex> lock(mtx_);
288+
row_cnt_ = row_cnt;
284289
return {*row_cnt_, Status::OK()};
285290
#else
286291
Status status;

0 commit comments

Comments
 (0)