Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
Yukang-Lian committed Aug 14, 2023
1 parent d371101 commit d439cae
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions be/src/service/backend_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#include "olap/rowset/rowset_meta.h"
#include "olap/storage_engine.h"
#include "olap/tablet_manager.h"
#include "olap/tablet_meta.h"
#include "olap/txn_manager.h"
#include "runtime/exec_env.h"
#include "runtime/external_scan_context_mgr.h"
Expand Down Expand Up @@ -629,7 +630,7 @@ void BackendService::ingest_binlog(TIngestBinlogResult& result,
}
}

// Step 6: create rowset && commit
// Step 6: create rowset && calculate delete bitmap && commit
// Step 6.1: create rowset
RowsetSharedPtr rowset;
status = RowsetFactory::create_rowset(local_tablet->tablet_schema(),
Expand All @@ -645,7 +646,29 @@ void BackendService::ingest_binlog(TIngestBinlogResult& result,
return;
}

// Step 6.2: commit txn
// Step 6.2 calculate delete bitmap before commit
auto calc_delete_bitmap_token =
StorageEngine::instance()->calc_delete_bitmap_executor()->create_token();
DeleteBitmapPtr delete_bitmap = std::make_shared<DeleteBitmap>(local_tablet_id);
auto pre_rowset_ids = local_tablet->all_rs_id(local_tablet->max_version_unlocked().second);
if (local_tablet->enable_unique_key_merge_on_write()) {
auto beta_rowset = reinterpret_cast<BetaRowset*>(rowset.get());
std::vector<segment_v2::SegmentSharedPtr> segments;
RETURN_IF_ERROR(beta_rowset->load_segments(&segments));
if (segments.size() > 1) {
// calculate delete bitmap between segments
RETURN_IF_ERROR(local_tablet->calc_delete_bitmap_between_segments(rowset, segments,
delete_bitmap));
}

local_tablet->commit_phase_update_delete_bitmap(rowset, pre_rowset_ids, delete_bitmap,
segments, txn_id,
calc_delete_bitmap_token.get(), nullptr);
calc_delete_bitmap_token->wait();
calc_delete_bitmap_token->get_delete_bitmap(delete_bitmap);
}

// Step 6.3: commit txn
Status commit_txn_status = StorageEngine::instance()->txn_manager()->commit_txn(
local_tablet->data_dir()->get_meta(), rowset_meta->partition_id(),
rowset_meta->txn_id(), rowset_meta->tablet_id(), rowset_meta->tablet_schema_hash(),
Expand All @@ -661,6 +684,12 @@ void BackendService::ingest_binlog(TIngestBinlogResult& result,
return;
}

if (local_tablet->enable_unique_key_merge_on_write()) {
StorageEngine::instance()->txn_manager()->set_txn_related_delete_bitmap(
partition_id, txn_id, local_tablet_id, local_tablet->schema_hash(),
local_tablet->tablet_uid(), true, delete_bitmap, pre_rowset_ids);
}

tstatus.__set_status_code(TStatusCode::OK);
}
} // namespace doris

0 comments on commit d439cae

Please sign in to comment.