|
|
@@ -2586,11 +2586,23 @@ uint64_t MemoryStore::evictOneChunk() {
|
|
|
};
|
|
|
std::vector<Candidate> candidates;
|
|
|
|
|
|
- const uint64_t now = currentTimeMs();
|
|
|
+ const uint64_t now_ms = currentTimeMs();
|
|
|
// hotWriteFloorMs may exceed `now` during the first seconds of a run; cap
|
|
|
// the subtraction so we don't underflow to a huge uint64_t.
|
|
|
- const uint64_t hotWriteFloor = (config_.hotWriteFloorMs < now)
|
|
|
- ? (now - config_.hotWriteFloorMs)
|
|
|
+ const uint64_t hotWriteFloor_ms = (config_.hotWriteFloorMs < now_ms)
|
|
|
+ ? (now_ms - config_.hotWriteFloorMs)
|
|
|
+ : 0;
|
|
|
+ // v2.3.1 — per-collection timestamp precision means doc.updatedAt may
|
|
|
+ // be ms or ns. Pre-compute both floors and pick per-doc using the
|
|
|
+ // 10^15 magnitude threshold (same heuristic the read path uses for
|
|
|
+ // mixed-precision rows). Pre-2.3.1 this comparison silently treated
|
|
|
+ // ns timestamps as "always > floor" and eviction never fired.
|
|
|
+ constexpr uint64_t kNsThreshold = 1'000'000'000'000'000ULL;
|
|
|
+ const uint64_t now_ns = now_ms * 1'000'000ULL;
|
|
|
+ const uint64_t hotWriteFloor_ns_offset =
|
|
|
+ static_cast<uint64_t>(config_.hotWriteFloorMs) * 1'000'000ULL;
|
|
|
+ const uint64_t hotWriteFloor_ns = (hotWriteFloor_ns_offset < now_ns)
|
|
|
+ ? (now_ns - hotWriteFloor_ns_offset)
|
|
|
: 0;
|
|
|
|
|
|
{
|
|
|
@@ -2603,7 +2615,11 @@ uint64_t MemoryStore::evictOneChunk() {
|
|
|
for (const auto& [docId, doc] : collPtr->documents) {
|
|
|
// Hot-write protection: a doc updated within the floor window
|
|
|
// is probably still being worked on by a writer. Skip it so
|
|
|
- // we don't race with a patch()/update() in flight.
|
|
|
+ // we don't race with a patch()/update() in flight. Pick the
|
|
|
+ // ms or ns floor based on the magnitude of this doc's stamp.
|
|
|
+ const uint64_t hotWriteFloor =
|
|
|
+ (doc.updatedAt >= kNsThreshold) ? hotWriteFloor_ns
|
|
|
+ : hotWriteFloor_ms;
|
|
|
if (doc.updatedAt > hotWriteFloor) continue;
|
|
|
|
|
|
// v1.7.0 T6 quiesce: skip docs with an outstanding write.
|