eggsdbtools: remove fix-name-hash-mismatch as fix deployed

This commit is contained in:
Miroslav Crnic
2024-07-29 15:12:44 +00:00
parent 95a2681121
commit 5acdd2c6dc
3 changed files with 0 additions and 70 deletions

View File

@@ -445,69 +445,3 @@ void ShardDBTools::fsck(const std::string& dbPath) {
#undef ERROR
}
void ShardDBTools::fixNameHashMismatch(const std::string& dbPath) {
Logger logger(LogLevel::LOG_INFO, STDERR_FILENO, false, false);
std::shared_ptr<XmonAgent> xmon;
Env env(logger, xmon, "ShardDBTools");
SharedRocksDB sharedDb(logger, xmon, dbPath, "");
sharedDb.registerCFDescriptors(ShardDB::getColumnFamilyDescriptors());
sharedDb.registerCFDescriptors(LogsDB::getColumnFamilyDescriptors());
sharedDb.registerCFDescriptors(BlockServicesCacheDB::getColumnFamilyDescriptors());
rocksdb::Options rocksDBOptions;
rocksDBOptions.compression = rocksdb::kLZ4Compression;
rocksDBOptions.bottommost_compression = rocksdb::kZSTD;
sharedDb.open(rocksDBOptions);
auto db = sharedDb.db();
{
auto edgesCf = sharedDb.getCF("edges");
const rocksdb::ReadOptions options;
std::vector<std::string> keysToDelete;
std::vector<std::pair<std::string,std::string>> keyValuesToInsert;
std::unique_ptr<rocksdb::Iterator> it(db->NewIterator(options, edgesCf));
for (it->SeekToFirst(); it->Valid(); it->Next()) {
auto edgeK = ExternalValue<EdgeKey>::FromSlice(it->key());
if (!edgeK().current()) {
continue;
}
auto nameHash = edgeK().nameHash();
std::string name(edgeK().name().data(), edgeK().name().size());
auto computedHash = EdgeKey::computeNameHash(HashMode::XXH3_63, BincodeBytesRef(edgeK().name().data(), edgeK().name().size()));
if (nameHash == computedHash) {
continue;
}
const std::string suffix = ".resurrected";
if (name.compare(name.size() - suffix.size(), suffix.size(), suffix) != 0) {
LOG_ERROR(env, "found an edge with name hash mismatch not ending in '.ressurected': %s", edgeK());
continue;
}
keysToDelete.emplace_back(it->key().ToString());
StaticValue<EdgeKey> newEdgeKey;
newEdgeKey().setDirIdWithCurrentU64(edgeK().dirIdWithCurrentU64());
newEdgeKey().setName(edgeK().name());
newEdgeKey().setNameHash(computedHash);
keyValuesToInsert.emplace_back(newEdgeKey.toSlice().ToString(),it->value().ToString());
}
ROCKS_DB_CHECKED(it->status());
if (keysToDelete.size() != keyValuesToInsert.size()) {
LOG_ERROR(env, "bug keys to delete different than keys to insert");
return;
}
if (keysToDelete.size() != 105) {
LOG_ERROR(env, "unexpected number of keys to delete %s", keysToDelete.size());
return;
}
rocksdb::WriteBatch batch;
for (const auto& key : keysToDelete) {
batch.Delete(edgesCf, key);
}
for (const auto& [key, value] : keyValuesToInsert) {
batch.Put(edgesCf, key, value);
}
ROCKS_DB_CHECKED(db->Write(rocksdb::WriteOptions(), &batch));
}
sharedDb.close();
}

View File

@@ -7,5 +7,4 @@ public:
static void verifyEqual(const std::string& db1Path, const std::string& db2Path);
static void outputUnreleasedState(const std::string& dbPath);
static void fsck(const std::string& dbPath);
static void fixNameHashMismatch(const std::string& dbPath);
};

View File

@@ -49,9 +49,6 @@ int main(int argc, char** argv) {
} else if (arg == "fsck") {
std::string dbPath = getNextArg();
ShardDBTools::fsck(dbPath);
} else if (arg == "fix-name-hash-mismatch") {
std::string dbPath = getNextArg();
ShardDBTools::fixNameHashMismatch(dbPath);
} else {
dieWithUsage();
}