|
@@ -1124,6 +1124,7 @@ void DatabaseService::auditMemoryDiskKeys() {
|
|
|
};
|
|
};
|
|
|
uint64_t diskOnlyTotal = 0, memOnlyTotal = 0, compared = 0;
|
|
uint64_t diskOnlyTotal = 0, memOnlyTotal = 0, compared = 0;
|
|
|
uint64_t adopted = 0, diskRemoved = 0, written = 0, memRemoved = 0, actionFailed = 0;
|
|
uint64_t adopted = 0, diskRemoved = 0, written = 0, memRemoved = 0, actionFailed = 0;
|
|
|
|
|
+ uint64_t notAdoptable = 0; // disk-only rows whose collection exists only on disk
|
|
|
|
|
|
|
|
for (const auto& project : projects_->listOpen()) {
|
|
for (const auto& project : projects_->listOpen()) {
|
|
|
auto* ds = docStore(project);
|
|
auto* ds = docStore(project);
|
|
@@ -1193,7 +1194,7 @@ void DatabaseService::auditMemoryDiskKeys() {
|
|
|
? qualified : namesIt->second.front();
|
|
? qualified : namesIt->second.front();
|
|
|
for (const auto& id : diskOnly) {
|
|
for (const auto& id : diskOnly) {
|
|
|
try {
|
|
try {
|
|
|
- (store_->adoptFromDocStore(target, id) ? done : failed).push_back(id);
|
|
|
|
|
|
|
+ (store_->adoptFromDocStore(target, id, /*quiet=*/true) ? done : failed).push_back(id);
|
|
|
} catch (const std::exception& e) {
|
|
} catch (const std::exception& e) {
|
|
|
spdlog::error("key audit: adopting {}/{} failed: {}", qualified, id, e.what());
|
|
spdlog::error("key audit: adopting {}/{} failed: {}", qualified, id, e.what());
|
|
|
failed.push_back(id);
|
|
failed.push_back(id);
|
|
@@ -1215,10 +1216,16 @@ void DatabaseService::auditMemoryDiskKeys() {
|
|
|
diskRemoved += done.size();
|
|
diskRemoved += done.size();
|
|
|
}
|
|
}
|
|
|
actionFailed += failed.size();
|
|
actionFailed += failed.size();
|
|
|
|
|
+ // Counted under every policy, so `report` can price `adopt`
|
|
|
|
|
+ // before anything acts (asked by smartbotic-vectorapi).
|
|
|
|
|
+ if (!inMemory) notAdoptable += diskOnly.size();
|
|
|
const std::string action =
|
|
const std::string action =
|
|
|
- diskPolicy == "report" ? "reported" :
|
|
|
|
|
- (diskPolicy == "adopt" && !inMemory) ? "reported (collection not in memory)" :
|
|
|
|
|
- diskPolicy == "adopt" ? "adopted into memory" : "removed from disk";
|
|
|
|
|
|
|
+ diskPolicy == "report"
|
|
|
|
|
+ ? (inMemory ? "reported (adopt would load them)"
|
|
|
|
|
+ : "reported (not adoptable: the collection exists only on disk)") :
|
|
|
|
|
+ (diskPolicy == "adopt" && !inMemory)
|
|
|
|
|
+ ? "reported (not adoptable: the collection exists only on disk)" :
|
|
|
|
|
+ diskPolicy == "adopt" ? "adopted into memory (loaded unchanged)" : "removed from disk";
|
|
|
spdlog::warn("key audit: {}: {} row(s) on disk but not in memory (reads find them; "
|
|
spdlog::warn("key audit: {}: {} row(s) on disk but not in memory (reads find them; "
|
|
|
"2.20.2+ loads one when it is written) - {}{}{}. ids: {}",
|
|
"2.20.2+ loads one when it is written) - {}{}{}. ids: {}",
|
|
|
qualified, diskOnly.size(), action,
|
|
qualified, diskOnly.size(), action,
|
|
@@ -1227,7 +1234,8 @@ void DatabaseService::auditMemoryDiskKeys() {
|
|
|
: "",
|
|
: "",
|
|
|
failed.empty() ? "" : fmt::format("; {} FAILED", failed.size()),
|
|
failed.empty() ? "" : fmt::format("; {} FAILED", failed.size()),
|
|
|
samples(diskOnly));
|
|
samples(diskOnly));
|
|
|
- entry["disk_only"] = {{"action", action}, {"ids", diskOnly}, {"failed", failed}};
|
|
|
|
|
|
|
+ entry["disk_only"] = {{"action", action}, {"collection_in_memory", inMemory},
|
|
|
|
|
+ {"ids", diskOnly}, {"failed", failed}};
|
|
|
}
|
|
}
|
|
|
if (!memOnly.empty()) {
|
|
if (!memOnly.empty()) {
|
|
|
memOnlyTotal += memOnly.size();
|
|
memOnlyTotal += memOnly.size();
|
|
@@ -1277,6 +1285,8 @@ void DatabaseService::auditMemoryDiskKeys() {
|
|
|
report["compared"] = compared;
|
|
report["compared"] = compared;
|
|
|
report["disk_only"] = diskOnlyTotal;
|
|
report["disk_only"] = diskOnlyTotal;
|
|
|
report["memory_only"] = memOnlyTotal;
|
|
report["memory_only"] = memOnlyTotal;
|
|
|
|
|
+ report["adopted"] = adopted;
|
|
|
|
|
+ report["not_adoptable"] = notAdoptable;
|
|
|
report["milliseconds"] = ms;
|
|
report["milliseconds"] = ms;
|
|
|
try {
|
|
try {
|
|
|
const auto path = std::filesystem::path(config_.dataDirectory) / "consistency-report.json";
|
|
const auto path = std::filesystem::path(config_.dataDirectory) / "consistency-report.json";
|
|
@@ -1296,10 +1306,12 @@ void DatabaseService::auditMemoryDiskKeys() {
|
|
|
spdlog::log(actionFailed > 0 ? spdlog::level::err : spdlog::level::warn,
|
|
spdlog::log(actionFailed > 0 ? spdlog::level::err : spdlog::level::warn,
|
|
|
"key audit: {} collection(s) compared, {} row(s) on disk only, {} in "
|
|
"key audit: {} collection(s) compared, {} row(s) on disk only, {} in "
|
|
|
"memory only ({} ms). Policy disk_only={} memory_only={}: {} adopted, {} "
|
|
"memory only ({} ms). Policy disk_only={} memory_only={}: {} adopted, {} "
|
|
|
- "removed from disk, {} written to disk, {} removed from memory, {} failed. "
|
|
|
|
|
|
|
+ "not adoptable (their collection exists only on disk; counted under any "
|
|
|
|
|
+ "policy), {} removed from "
|
|
|
|
|
+ "disk, {} written to disk, {} removed from memory, {} failed. "
|
|
|
"Full lists: consistency-report.json in the data directory.",
|
|
"Full lists: consistency-report.json in the data directory.",
|
|
|
compared, diskOnlyTotal, memOnlyTotal, ms, diskPolicy, memPolicy,
|
|
compared, diskOnlyTotal, memOnlyTotal, ms, diskPolicy, memPolicy,
|
|
|
- adopted, diskRemoved, written, memRemoved, actionFailed);
|
|
|
|
|
|
|
+ adopted, notAdoptable, diskRemoved, written, memRemoved, actionFailed);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|