8000 Fix bug in GetTableSegments() and more testunit in new_txn_replay.cpp by qinling0210 · Pull Request #2763 · infiniflow/infinity · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix bug in GetTableSegments() and more testunit in new_txn_replay.cpp #2763

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/storage/catalog/kv_utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,17 @@ import infinity_exception;

namespace infinity {

Vector<SegmentID> GetTableSegments(KVInstance *kv_instance, const String &db_id_str, const String &table_id_str, TxnTimeStamp begin_ts) {
Vector<SegmentID>
GetTableSegments(KVInstance *kv_instance, const String &db_id_str, const String &table_id_str, TxnTimeStamp begin_ts, TxnTimeStamp commit_ts) {
Vector<SegmentID> segment_ids;

String segment_id_prefix = KeyEncode::CatalogTableSegmentKeyPrefix(db_id_str, table_id_str);
auto iter = kv_instance->GetIterator();
iter->Seek(segment_id_prefix);
while (iter->Valid() && iter->Key().starts_with(segment_id_prefix)) {
TxnTimeStamp commit_ts = std::stoull(iter->Value().ToString());
if (commit_ts > begin_ts and commit_ts != std::numeric_limits<TxnTimeStamp>::max()) {
LOG_DEBUG(fmt::format("SKIP SEGMENT: {} {} {}", iter->Key().ToString(), commit_ts, begin_ts));
TxnTimeStamp segment_commit_ts = std::stoull(iter->Value().ToString());
if (segment_commit_ts > begin_ts and segment_commit_ts != std::numeric_limits<TxnTimeStamp>::max()) {
LOG_DEBUG(fmt::format("SKIP SEGMENT: {} {} {}", iter->Key().ToString(), segment_commit_ts, begin_ts));
iter->Next();
continue;
}
Expand All @@ -56,7 +57,7 @@ Vector<SegmentID> GetTableSegments(KVInstance *kv_instance, const String &db_id_
String drop_segment_ts{};
kv_instance->Get(KeyEncode::DropSegmentKey(db_id_str, table_id_str, segment_id), drop_segment_ts);

if (drop_segment_ts.empty() || std::stoull(drop_segment_ts) > begin_ts) {
if (drop_segment_ts.empty() || (std::stoull(drop_segment_ts) > begin_ts && std::stoull(drop_segment_ts) != commit_ts)) {
segment_ids.push_back(segment_id);
}
iter->Next();
Expand Down
2 changes: 1 addition & 1 deletion src/storage/catalog/kv_utility.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace infinity {
class KVInstance;
class IndexBase;

export Vector<SegmentID> GetTableSegments(KVInstance *kv_instance, const String &db_id_str, const String &table_id_str, TxnTimeStamp begin_ts);
export Vector<SegmentID> GetTableSegments(KVInstance *kv_instance, const String &db_id_str, const String &table_id_str, TxnTimeStamp begin_ts, TxnTimeStamp commit_ts);

export Vector<SegmentID> GetTableIndexSegments(KVInstance *kv_instance,
const String &db_id_str,
Expand Down
4 changes: 2 additions & 2 deletions src/storage/catalog/meta/table_meeta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ Status TableMeeta::LoadColumnDefs() {
// }

Status TableMeeta::LoadSegmentIDs1() {
segment_ids1_ = infinity::GetTableSegments(kv_instance_, db_id_str_, table_id_str_, begin_ts_);
segment_ids1_ = infinity::GetTableSegments(kv_instance_, db_id_str_, table_id_str_, begin_ts_, commit_ts_);
return Status::OK();
}

Expand Down Expand Up @@ -859,7 +859,7 @@ SharedPtr<String> TableMeeta::GetTableDir() { return {MakeShared<String>(table_i

Tuple<Vector<SegmentID> *, Status> TableMeeta::GetSegmentIDs1() {
if (!segment_ids1_) {
segment_ids1_ = infinity::GetTableSegments(kv_instance_, db_id_str_, table_id_str_, begin_ts_);
segment_ids1_ = infinity::GetTableSegments(kv_instance_, db_id_str_, table_id_str_, begin_ts_, commit_ts_);
}
return {&*segment_ids1_, Status::OK()};
}
Expand Down
Loading
0