Skip to content
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
4 changes: 4 additions & 0 deletions be/src/olap/data_dir.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ class DataDir {
return _id_generator->get_next_id(id);
}

OLAPStatus set_next_id(RowsetId new_rowset_id) {
return _id_generator->set_next_id(new_rowset_id);
}

// load data from meta and data files
OLAPStatus load();

Expand Down
18 changes: 17 additions & 1 deletion be/src/olap/rowset/rowset_id_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,23 @@ OLAPStatus RowsetIdGenerator::get_next_id(RowsetId* gen_rowset_id) {
return s;
}
}
*gen_rowset_id = _next_id++;
*gen_rowset_id = _next_id;
++_next_id;
return OLAP_SUCCESS;
}

OLAPStatus RowsetIdGenerator::set_next_id(RowsetId new_rowset_id) {
std::lock_guard<std::mutex> l(_lock);
// must be < not <=
if (new_rowset_id < _next_id) {
return OLAP_SUCCESS;
}
if (new_rowset_id >= _id_batch_end) {
_id_batch_end = new_rowset_id + k_batch_interval;
auto s = _meta->put(DEFAULT_COLUMN_FAMILY_INDEX, END_ROWSET_ID, std::to_string(_id_batch_end));
RETURN_NOT_OK(s);
}
_next_id = new_rowset_id + 1;
return OLAP_SUCCESS;
}

Expand Down
2 changes: 2 additions & 0 deletions be/src/olap/rowset/rowset_id_generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class RowsetIdGenerator {
// it saves the batch end id into meta env
OLAPStatus get_next_id(RowsetId* rowset_id);

OLAPStatus set_next_id(RowsetId new_rowset_id);

private:
OlapMeta* _meta = nullptr;

Expand Down
22 changes: 22 additions & 0 deletions be/src/olap/snapshot_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,28 @@ OLAPStatus SnapshotManager::convert_rowset_ids(DataDir& data_dir, const string&
new_tablet_meta_pb.set_schema_hash(schema_hash);
TabletSchema tablet_schema;
RETURN_NOT_OK(tablet_schema.init_from_pb(new_tablet_meta_pb.schema()));

RowsetId max_rowset_id = 0;
for (auto& visible_rowset : cloned_tablet_meta_pb.rs_metas()) {
if (visible_rowset.rowset_id() > max_rowset_id) {
max_rowset_id = visible_rowset.rowset_id();
}
}

for (auto& inc_rowset : cloned_tablet_meta_pb.inc_rs_metas()) {
if (inc_rowset.rowset_id() > max_rowset_id) {
max_rowset_id = inc_rowset.rowset_id();
}
}
RowsetId next_rowset_id = 0;
RETURN_NOT_OK(data_dir.next_id(&next_rowset_id));
if (next_rowset_id <= max_rowset_id) {
OLAPStatus set_id_st = data_dir.set_next_id(max_rowset_id + 1);
if (set_id_st != OLAP_SUCCESS) {
return set_id_st;
}
}

for (auto& visible_rowset : cloned_tablet_meta_pb.rs_metas()) {
RowsetMetaPB* rowset_meta = new_tablet_meta_pb.add_rs_metas();
RETURN_NOT_OK(_rename_rowset_id(visible_rowset, clone_dir, data_dir, tablet_schema, rowset_meta));
Expand Down
4 changes: 2 additions & 2 deletions be/src/olap/txn_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ OLAPStatus TxnManager::prepare_txn(
// case 2: loading txn from meta env
TabletTxnInfo load_info(load_id, nullptr);
_txn_tablet_map[key][tablet_info] = load_info;
VLOG(3) << "add transaction to engine successfully."
LOG(INFO) << "add transaction to engine successfully."
<< "partition_id: " << key.first
<< ", transaction_id: " << key.second
<< ", tablet: " << tablet_info.to_string();
Expand Down Expand Up @@ -189,7 +189,7 @@ OLAPStatus TxnManager::commit_txn(
WriteLock wrlock(&_txn_map_lock);
TabletTxnInfo load_info(load_id, rowset_ptr);
_txn_tablet_map[key][tablet_info] = load_info;
VLOG(3) << "add transaction to engine successfully."
LOG(INFO) << "add transaction to engine successfully."
<< "partition_id: " << key.first
<< ", transaction_id: " << key.second
<< ", tablet: " << tablet_info.to_string();
Expand Down