Skip to content

[Store] Prevent object_already_exists log storm - #4285

Merged
ykwd merged 3 commits into
kvcache-ai:mainfrom
riZZZhik:fix/master-already-exists-metric
Sep 23, 2026
Merged

ykwd merged 3 commits into
kvcache-ai:mainfrom
riZZZhik:fix/master-already-exists-metric

Conversation

@riZZZhik

@riZZZhik riZZZhik commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Description

Repeated writes to existing objects can flood the master logs with object_already_exists messages. For example, when SGLang resumes using Mooncake as its L3 backend after temporarily unavailability.

Replace the per-key INFO logs and duplicate-specific batch VLOG messages with separate Prometheus counters for PutStart requests and BatchPutStart items. Display both counters in existing Grafana panels.

Module

  • Transfer Engine (mooncake-transfer-engine)
  • Mooncake Store (mooncake-store)
  • Mooncake Conductor (mooncake-conductor)
  • Reshard (mooncake-reshard)
  • Mooncake EP (mooncake-ep)
  • Mooncake PG (mooncake-pg)
  • Integration (mooncake-integration)
  • P2P Store (mooncake-p2p-store)
  • Python Wheel (mooncake-wheel)
  • Common (mooncake-common)
  • Mooncake RL (mooncake-rl)
  • CI/CD
  • Docs
  • Other

Type of Change

  • Bug fix
  • New feature
  • Refactor
  • Breaking change
  • Documentation update
  • Performance improvement
  • Other

How Has This Been Tested?

Built and ran the initial-counter and duplicate-log regression tests in an ARM64 Linux container with GCC 13. Both passed, covering single and batch duplicates, mixed batches, counter isolation and log suppression.

Test commands:

pre-commit run --files $(git diff --name-only --diff-filter=ACMR origin/main...HEAD)

cmake --build build --target master_metrics_test --parallel 2
./build/mooncake-store/tests/master_metrics_test --gtest_filter='MasterMetricsTest.InitialStatusTest:MasterMetricsTest.DuplicatePutResponsesCountItemsWithoutPerKeyLogs'

Test results:

  • Unit tests pass
  • Integration tests pass (if applicable)
  • Manual testing done (describe below)

Tested locally with 100+ clients generating up to 1,000 OBJECT_ALREADY_EXISTS responses per minute.

Checklist

  • I have performed a self-review of my own code
  • I have formatted my code using ./scripts/code_format.sh
  • I have run pre-commit on the files changed in this PR and all hooks pass
  • I have updated the documentation (if applicable)
  • I have added tests to prove my changes are effective
  • For changes >500 LOC: I have filed an RFC issue

AI Assistance Disclosure

  • No AI tools were used
  • AI tools were used (specify below)

Codex assisted with repo discovery and tests

Copilot AI lite review requested due to automatic review settings September 22, 2026 21:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Fix the missing comma so the Grafana dashboard is valid JSON.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 High severity

Open (1)
What changed in this PR

This PR reduces Mooncake Store log storms by replacing duplicate-object logs with Prometheus counters and Grafana visibility.

Changes:

  • Adds duplicate PutStart and BatchPutStart counters.
  • Removes noisy duplicate logs and adds regression tests.
  • Updates the Grafana dashboard.
File Summary
mooncake-store/​tests/​master_metrics_test.cpp Tests counter behavior and log suppression.
mooncake-store/​src/​rpc_service.cpp Records duplicate responses.
mooncake-store/​src/​master_service.cpp Removes duplicate logs.
mooncake-store/​src/​master_metric_manager.cpp Implements metrics.
mooncake-store/​include/​master_metric_manager.h Declares metrics and accessors.
monitoring/​grafana/​dashboards/​mooncake.json Adds metric panels; currently has invalid JSON due to a missing comma.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@riZZZhik
riZZZhik force-pushed the fix/master-already-exists-metric branch from d01c8aa to 7c8b051 Compare September 22, 2026 21:25

@he-yufeng he-yufeng left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified the whole path against the PR head. The storm source is exactly where the fix lands, and the counting is wired correctly:

All four per-key LOG(INFO) ... object_already_exists sites in master_service.cpp (two in InsertMetadata, one in AllocateAndInsertMetadata, one in the PutStart discard check) are gone — the file goes from 4 to 0. The single-put counter increments at one point, the WrappedMasterService::PutStart wrapper on an OBJECT_ALREADY_EXISTS result, so every service-side producer funnels through it. The batch path replaces the per-item VLOG(1) with an already_exists_count accumulated in the result loop and one inc_batch_put_start_object_already_exists call after the join, which keeps the per-item semantics the old messages had without paying per-item log cost. The counters themselves follow the manager's existing patterns (zero-initialized in update_metrics_for_zero_output, getters, serialized names in the tests).

Coverage boundary, checked method by method: the remaining producers of OBJECT_ALREADY_EXISTS are UpsertStart (line ~5766), CopyStart (~6450), and the standby-restore paths (~3640/3790). The restore paths are startup recovery, not a rate path. Upsert overwrites by design and CopyStart is not the SGLang-resume storm shape, so scoping the counters to PutStart/BatchPutStart matches the described incident; if an operator ever sees those two storm, the same wrapper pattern applies one-for-one. Worth one line in the PR description that the scope decision is deliberate.

Tests cover zero-init and metric-name serialization for both counters plus the log-sink suppression case, and CI is green (21 success, the 2 skips are the usual scope detects).

Verification scope, honestly: this is a source-level review of the mechanism and the counting semantics; I did not run a local build of the new metric tests and rely on the PR's suite plus CI for that.

@Icedcoco Icedcoco left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ykwd
ykwd merged commit 186f6ec into kvcache-ai:main Sep 23, 2026
23 checks passed
@riZZZhik
riZZZhik deleted the fix/master-already-exists-metric branch September 23, 2026 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants