MCPcopy Create free account
hub / github.com/apple/foundationdb / action

Method action

fdbserver/KeyValueStoreRocksDB.actor.cpp:2036–2118  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2034};
2035
2036void RocksDBKeyValueStore::Writer::action(CheckpointAction& a) {
2037 TraceEvent("RocksDBServeCheckpointBegin", id)
2038 .detail("MinVersion", a.request.version)
2039 .detail("Range", a.request.range.toString())
2040 .detail("Format", static_cast<int>(a.request.format))
2041 .detail("CheckpointDir", a.request.checkpointDir);
2042
2043 rocksdb::Checkpoint* checkpoint = nullptr;
2044 rocksdb::Status s = rocksdb::Checkpoint::Create(db, &checkpoint);
2045 if (!s.ok()) {
2046 logRocksDBError(id, s, "Checkpoint");
2047 a.reply.sendError(statusToError(s));
2048 return;
2049 }
2050
2051 rocksdb::PinnableSlice value;
2052 rocksdb::ReadOptions& readOptions = sharedState->getReadOptions();
2053 s = db->Get(readOptions, cf, toSlice(persistVersion), &value);
2054
2055 if (!s.ok() && !s.IsNotFound()) {
2056 logRocksDBError(id, s, "Checkpoint");
2057 a.reply.sendError(statusToError(s));
2058 return;
2059 }
2060
2061 const Version version =
2062 s.IsNotFound() ? latestVersion : BinaryReader::fromStringRef<Version>(toStringRef(value), Unversioned());
2063
2064 ASSERT(a.request.version == version || a.request.version == latestVersion);
2065 TraceEvent(SevDebug, "RocksDBServeCheckpointVersion", id)
2066 .detail("CheckpointVersion", a.request.version)
2067 .detail("PersistVersion", version);
2068
2069 // TODO: set the range as the actual shard range.
2070 CheckpointMetaData res(version, a.request.range, a.request.format, a.request.checkpointID);
2071 const std::string& checkpointDir = abspath(a.request.checkpointDir);
2072
2073 if (a.request.format == RocksDBColumnFamily) {
2074 rocksdb::ExportImportFilesMetaData* pMetadata;
2075 platform::eraseDirectoryRecursive(checkpointDir);
2076 s = checkpoint->ExportColumnFamily(cf, checkpointDir, &pMetadata);
2077 if (!s.ok()) {
2078 logRocksDBError(id, s, "ExportColumnFamily");
2079 a.reply.sendError(statusToError(s));
2080 return;
2081 }
2082
2083 populateMetaData(&res, *pMetadata);
2084 delete pMetadata;
2085 TraceEvent("RocksDBServeCheckpointSuccess", id)
2086 .detail("CheckpointMetaData", res.toString())
2087 .detail("RocksDBCF", getRocksCF(res).toString());
2088 } else if (a.request.format == RocksDB) {
2089 platform::eraseDirectoryRecursive(checkpointDir);
2090 uint64_t debugCheckpointSeq = -1;
2091 s = checkpoint->CreateCheckpoint(checkpointDir, /*log_size_for_flush=*/0, &debugCheckpointSeq);
2092 if (!s.ok()) {
2093 logRocksDBError(id, s, "Checkpoint");

Callers

nothing calls this directly

Calls 15

TraceEventClass · 0.85
CreateFunction · 0.85
UnversionedFunction · 0.85
eraseDirectoryRecursiveFunction · 0.85
populateMetaDataFunction · 0.85
getRocksCFFunction · 0.85
listFilesFunction · 0.85
IncludeVersionFunction · 0.85
getMetaDataFunction · 0.85
getRocksCheckpointFunction · 0.85
detailMethod · 0.80
okMethod · 0.80

Tested by

no test coverage detected