Repository navigation
Conversation
2 of 19 tasks
Memory eviction picked one reclaimer among three: the OpLog under HA, otherwise the offloading one with offload_on_evict, otherwise immediate removal. With HA on, the OpLog won, so an object whose only copy was a memory replica was dropped without the LOCAL_DISK copy offload_on_evict asks for, and PutEnd does not offload early in that mode either. This dates from kvcache-ai#2826 for memory-pressure eviction; the cutover brought tenant-quota eviction onto the same Evictor, which on main offloaded there but did not go through the OpLog. Whether to offload first and how a replica comes off are separate choices. MemoryEviction now holds the removal, the OpLog under HA and immediate otherwise, and offload_on_evict wraps it in the OffloadingReclaimer instead of standing in for it. Under HA an evicted object's offload is queued and its source kept until the offload lands, as without HA, and the next round removes the memory replica through the OpLog. The managed-weight cold path reuses the same removal.
An UpsertStart that takes over an unfinished write with no completed replica erases the old object and allocates the replacement under the same key lock. The account still held the old write's reservation, which was settled only when the lock was released, so the replacement's growth was charged on top of it: with a 100-byte quota, PutStart(K, 100) followed by UpsertStart(K, 100) failed with TENANT_QUOTA_EXCEEDED. A torn-down key owes nothing, so OnTearDown now settles what the account holds for it to zero on the spot. OnWriteRelease keeps settling against the object as before, through the same Settle. A size-changing upsert replaces rather than tears down, so the old object's charge still stays until the replacement settles, and the write stays begun until the lock is released, so a tenant delete is still held off.
Aionw
force-pushed
the
store/cutover-followups
branch
from
October 26, 2026 12:28
0f7ee57 to
2b8b22b
Compare
Aionw
marked this pull request as ready for review
October 26, 2026 12:33
Aionw
requested review from
00fish0,
Icedcoco,
Libotry,
XucSh,
YiXR,
stmatengss and
ykwd
as code owners
October 26, 2026 12:33
5 tasks done
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Follow-up to #4887, fixing the two P2 findings from its review. Stacked on #4887: only the last two commits are new (
d9c738601,0f7ee57ec); I'll rebase onto main once #4887 merges.1. Offload before evicting through the OpLog under HA. Memory eviction picked one reclaimer among three: the OpLog under HA, otherwise
OffloadingReclaimerwithoffload_on_evict, otherwise immediate removal. With HA on, the OpLog won, so an object whose only copy was in memory was dropped without the LOCAL_DISK copyoffload_on_evictasks for. PutEnd does not offload early in that mode either, so nothing ever reached disk. Memory-pressure eviction has behaved this way since #2826 (reported as #4830). #4887 put tenant-quota eviction on the same Evictor; on main that path offloaded but wrote no OpLog record.Whether to offload first and how a replica comes off are separate choices.
MemoryEvictionnow holds the removal (the OpLog under HA, immediate otherwise), andoffload_on_evictwraps it inOffloadingReclaimerinstead of replacing it. The managed-weight cold path reuses the same removal.#4868 fixes the same bug in main's
BatchEvict, which #4887 deletes; this is the equivalent on the Evictor.2. Settle a torn-down object's quota charge at teardown. An
UpsertStartthat takes over an unfinished write with no completed replica erases the old object and allocates the replacement under the same key lock. The account still held the old write's reservation until the lock was released, so the replacement was charged on top of it: with a 100-byte quota,PutStart(K, 100)thenUpsertStart(K, 100)failed withTENANT_QUOTA_EXCEEDED. A torn-down key owes nothing, soOnTearDownnow settles the key's charge to zero on the spot. A size-changing upsert replaces rather than tears down, so it still carries the old charge until the replacement settles. The write stays begun until the lock is released, so tenant deletion is still held off.Behavior change for HA deployments with
offload_on_evict. Eviction now queues the offload and keeps the source replica until it lands; the memory is freed on a later round, through the OpLog. One round therefore frees less memory than before. Deployments that prefer freeing memory fast should enableoffload_force_evictand sizeoffloading_queue_limit/offload_cap_ratio. HA deployments withoutoffload_on_evictare unaffected.Known gap, not addressed here. When an eviction-queued offload completes,
NotifyOffloadSuccessadds the LOCAL_DISK replica without an OpLog record. The standby learns of it only from the next eviction'sPUT_END, which lists the remaining replicas. A failover in between loses only the standby's knowledge of the disk copy; the memory replica is still recorded.Suggested Merge Priority
Module
mooncake-transfer-engine)mooncake-store)mooncake-conductor)mooncake-reshard)mooncake-ep)mooncake-pg)mooncake-integration)mooncake-p2p-store)mooncake-wheel)mooncake-common)mooncake-rl)Type of Change
How Has This Been Tested?
Test commands:
make tenant_quota_policy_test master_service_tenant_quota_test master_service_ha_test offload_on_evict_test \ master_service_evict_scenario_test evictor_test metadata_namespace_test master_service_test # each binary run in parallelTest results:
MasterServiceHATest.OffloadOnEvictOffloadsBeforeEvictingThroughOpLogMasterServiceTenantQuotaTest.UpsertTakingOverAnUnfinishedWriteIsNotChargedForIt(the reviewer's sequence)TenantQuotaPolicyTest.ATornDownObjectIsNotChargedAgainstItsSuccessorChecklist
./scripts/code_format.shAI Assistance Disclosure
Claude Code helped trace the eviction and quota paths, write the fix and tests. I reviewed every changed line.