Skip to content

Commit 73763f1

Browse files
committed
1
1 parent 60e4eef commit 73763f1

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

be/src/cloud/cloud_tablet_mgr.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ class SingleFlight {
9292
std::unordered_map<Key, std::shared_ptr<Call>> _call_map;
9393
};
9494

95-
SingleFlight<int64_t /* tablet_id */, std::shared_ptr<CloudTablet>> s_singleflight_load_tablet;
95+
// tablet_id -> load tablet function
96+
SingleFlight<int64_t, Result<std::shared_ptr<CloudTablet>>> s_singleflight_load_tablet;
9697

9798
} // namespace
9899

@@ -192,7 +193,7 @@ Result<std::shared_ptr<CloudTablet>> CloudTabletMgr::get_tablet(int64_t tablet_i
192193
++sync_stats->tablet_meta_cache_miss;
193194
}
194195
auto load_tablet = [this, &key, warmup_data, sync_delete_bitmap,
195-
sync_stats](int64_t tablet_id) -> std::shared_ptr<CloudTablet> {
196+
sync_stats](int64_t tablet_id) -> Result<std::shared_ptr<CloudTablet>> {
196197
TabletMetaSharedPtr tablet_meta;
197198
auto start = std::chrono::steady_clock::now();
198199
auto st = _engine.meta_mgr().get_tablet_meta(tablet_id, &tablet_meta);
@@ -203,7 +204,7 @@ Result<std::shared_ptr<CloudTablet>> CloudTabletMgr::get_tablet(int64_t tablet_i
203204
}
204205
if (!st.ok()) {
205206
LOG(WARNING) << "failed to tablet " << tablet_id << ": " << st;
206-
return nullptr;
207+
return ResultError(st);
207208
}
208209

209210
auto tablet = std::make_shared<CloudTablet>(_engine, std::move(tablet_meta));
@@ -215,7 +216,7 @@ Result<std::shared_ptr<CloudTablet>> CloudTabletMgr::get_tablet(int64_t tablet_i
215216
st = _engine.meta_mgr().sync_tablet_rowsets(tablet.get(), options, sync_stats);
216217
if (!st.ok()) {
217218
LOG(WARNING) << "failed to sync tablet " << tablet_id << ": " << st;
218-
return nullptr;
219+
return ResultError(st);
219220
}
220221

221222
auto* handle = _cache->insert(key, value.release(), 1, sizeof(CloudTablet),
@@ -229,10 +230,12 @@ Result<std::shared_ptr<CloudTablet>> CloudTabletMgr::get_tablet(int64_t tablet_i
229230
return ret;
230231
};
231232

232-
auto tablet = s_singleflight_load_tablet.load(tablet_id, std::move(load_tablet));
233-
if (tablet == nullptr) {
234-
return ResultError(Status::InternalError("failed to get tablet {}", tablet_id));
233+
auto load_result = s_singleflight_load_tablet.load(tablet_id, std::move(load_tablet));
234+
if (!load_result.has_value()) {
235+
return ResultError(Status::InternalError("failed to get tablet {}, msg={}", tablet_id,
236+
load_result.error()));
235237
}
238+
auto tablet = load_result.value();
236239
set_tablet_access_time_ms(tablet.get());
237240
return tablet;
238241
}

0 commit comments

Comments
 (0)