Skip to content

Commit

Permalink
run debug
Browse files Browse the repository at this point in the history
  • Loading branch information
acelyc111 committed Mar 1, 2024
1 parent f98eb68 commit 8a4bd8c
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/shell/commands/local_partition_split.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ bool local_partition_split(command_executor *e, shell_context *sc, arguments arg
std::set<uint32_t> exist_app_ids;
// "1.0.pegasus"
static const std::string kAppInfo = ".app-info";
for (const auto &replica_dir : replica_dirs) {
std::set<std::string> ordered_replica_dirs(replica_dirs.begin(), replica_dirs.end());
for (const auto &replica_dir : ordered_replica_dirs) {
auto fname = dsn::utils::filesystem::get_file_name(replica_dir);
// TODO(yingchun): duplicate with code in replica_stub.cpp, refactor it!
if (fname.length() >= 4 && (fname.substr(fname.length() - 4) == ".err" ||
Expand Down Expand Up @@ -333,7 +334,7 @@ bool local_partition_split(command_executor *e, shell_context *sc, arguments arg
// 'fname' has a duplicate '/' when contact 'file.db_path' and 'file.name', it
// doesn't matter.
const auto fname = file.db_path + file.name;
fmt::print(stdout, "column family: {}, file: {}\n", file.column_family_name, fname);
// fmt::print(stdout, "column family: {}, file: {}\n", file.column_family_name, fname);
// Open reader.
// TODO(yingchun): options?
auto reader = std::make_unique<rocksdb::SstFileReader>(rocksdb::Options());
Expand Down Expand Up @@ -501,10 +502,11 @@ bool local_partition_split(command_executor *e, shell_context *sc, arguments arg
if (arg.external_files.empty()) {
fmt::print(stdout, "empty sub-files '{}', skipped\n", dst_tmp_rdb_dir);
continue;
} else {
fmt::print(stdout, "sub-files size: {}\n", arg.external_files.size());
}

// Ingest files.
// TODO(yingchun): any problem if they are in 2 CFs ?
auto iefs = _db->IngestExternalFiles({arg});
if (!iefs.ok()) {
fmt::print(stderr,
Expand All @@ -514,6 +516,14 @@ bool local_partition_split(command_executor *e, shell_context *sc, arguments arg
return false;
}

std::unique_ptr<rocksdb::Iterator> iter(
_db->NewIterator(rocksdb::ReadOptions()));
int new_total_count = 0;
for (iter->SeekToFirst(); iter->Valid(); iter->Next()) {
new_total_count++;
}
fmt::print(stdout, "new_total_count: {}\n", new_total_count);

// Full compact.
auto crs = _db->CompactRange(rocksdb::CompactRangeOptions(), nullptr, nullptr);
if (!crs.ok()) {
Expand Down Expand Up @@ -558,7 +568,7 @@ bool local_partition_split(command_executor *e, shell_context *sc, arguments arg
new_ai.app_name += "_new"; // TODO(yingchun): customize it.
new_ai.app_id = dst_app_id;
new_ai.partition_count = dst_partition_count;
new_ai.create_second = dsn_now_s();
// new_ai.create_second = dsn_now_s(); // TODO(yingchun): all partitions must be the same!
dsn::replication::replica_app_info rai(&new_ai);
const auto rai_path =
dsn::utils::filesystem::path_combine(new_data_dir_replica_dirs, kAppInfo);
Expand Down

0 comments on commit 8a4bd8c

Please sign in to comment.