Skip to content

Commit

Permalink
[enhancement](tablet-meta) Avoid be coredump due to potential race co…
Browse files Browse the repository at this point in the history
…ndition when updating tablet cumu point (#45643)

Currently, when setting tablet's cumu point, aseert fail will happend if
new point is less than local value, resulting BE coredump.

This could happend when race condition happend:
1. thread A try to sync rowset
2. thread A fetch cumu point from ms 
3. thread B update cumu point(like sc/compaction),commit to ms after 2.
and set be tablet cumu point before 4.
4. thread A try to set cumu point seen before and meet the assertion,
coredump.
  • Loading branch information
TangSiyang2001 authored Dec 23, 2024
1 parent 014f84a commit cd916c6
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions be/src/cloud/cloud_tablet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "cloud/cloud_meta_mgr.h"
#include "cloud/cloud_storage_engine.h"
#include "cloud/cloud_tablet_mgr.h"
#include "common/logging.h"
#include "io/cache/block_file_cache_downloader.h"
#include "io/cache/block_file_cache_factory.h"
#include "olap/cumulative_compaction_time_series_policy.h"
Expand Down Expand Up @@ -657,11 +658,14 @@ void CloudTablet::get_compaction_status(std::string* json_result) {
}

void CloudTablet::set_cumulative_layer_point(int64_t new_point) {
if (new_point == Tablet::K_INVALID_CUMULATIVE_POINT || new_point >= _cumulative_point) {
_cumulative_point = new_point;
return;
}
// cumulative point should only be reset to -1, or be increased
CHECK(new_point == Tablet::K_INVALID_CUMULATIVE_POINT || new_point >= _cumulative_point)
<< "Unexpected cumulative point: " << new_point
<< ", origin: " << _cumulative_point.load();
_cumulative_point = new_point;
// FIXME: could happen in currently unresolved race conditions
LOG(WARNING) << "Unexpected cumulative point: " << new_point
<< ", origin: " << _cumulative_point.load();
}

std::vector<RowsetSharedPtr> CloudTablet::pick_candidate_rowsets_to_base_compaction() {
Expand Down

0 comments on commit cd916c6

Please sign in to comment.