Skip to content

fix(preheat): async snapshot sizing and fail-fast scheduler calls - #128

Merged
mangoknight merged 2 commits into
dingodb:mainfrom
mangoknight:fix/scheduler-file-fast-fallback
Oct 13, 2026
Merged

mangoknight merged 2 commits into
dingodb:mainfrom
mangoknight:fix/scheduler-file-fast-fallback

Conversation

@mangoknight

@mangoknight mangoknight commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

Two independent commits.

1. Fail fast on download-path scheduler calls

SchedulerFile runs before every file download with a 300s timeout. When the scheduler's database stalls, every file waits for it even though both callers already have fallbacks (fetch upstream; queue locally and replay hourly).

  • SchedulerFile and the new ReportCachedFile use a 5s timeout; after a failure, skip the scheduler for 30s.
  • Other RPCs keep their existing timeouts.

2. Size the snapshot inside the job

Exact sizing ran synchronously in the create request, so repositories with thousands of files could not be created.

  • Create resolves only the commit and file list, registers the upstream usedStorage estimate, and returns.
  • PreheatCacheTask.Prepare computes the exact size (one revision?blobs=true request, falling back to batched paths-info), stores it and reports it before downloading.
  • Resume reports running plus size; reuse of a completed job compares against its recorded size.
  • proto: UpdateCacheJobStatusReq.usedStorage (field 8); the running report is best-effort and never queued for replay.

Requires dingodb/dingoscheduler#30 for the new field; either side can be upgraded first.

Tests

TestSchedulerFastCallsTimeOutAndCoolDown, TestCreatePreheatReturnsBeforeSnapshotIsSized, TestPreheatSnapshotSizeUsesOneBlobsRequest, TestPreheatMetadataBatchesPathsInfo. go test ./internal/... passes, create path also under -race.

🤖 Generated with Claude Code

mangoknight and others added 2 commits October 13, 2026 15:08
Peer lookup (SchedulerFile) and the cached-file report both run inside
the download path and both already have a fallback: download from
upstream, or queue the report locally for the hourly replay. They still
waited the full 300s RpcRequestTimeout. On 2026-10-13 a DingoDB region
without a leader made every scheduler lookup take 60s, so each file of
every cache job in every region waited 60s+ before downloading.

- SchedulerFile and the new ReportCachedFile use a 5s deadline.
- After any failure both skip the scheduler for 30s, so a stalled
  scheduler costs at most one timeout per cooldown, not one per file.
- Other scheduler RPCs (registration, local-queue replay) keep the
  long timeout.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Creating a preheat job measured every file of the snapshot before
answering, inside the scheduler's 10s request. Batching paths-info
(dingodb#127) fixed repositories with a few hundred files, but uonlp/CulturaX
has 9059: 71 batches at 1-4s each through the regional exit, so create
still failed with "context canceled".

- Create only resolves the commit and file list (one request) and
  registers the job with the upstream usedStorage as an estimate.
- The task measures the snapshot first (Prepare), records the exact
  size locally and reports it to the scheduler, then transfers. A sizing
  failure now fails the job with its reason instead of the create call.
- Sizes come from one revision?blobs=true request (9059 files: 1.7s
  direct), falling back to batched paths-info when sizes are missing.
- Resume reports "running" with the size once preparation is done, so
  the scheduler no longer shows a resumed job as interrupted.
- Completed-job reuse checks against the size that job recorded, since
  a create request now only carries the estimate.
- proto: UpdateCacheJobStatusReq.usedStorage (field 8). The running
  report is best effort and never queued for replay, so it cannot land
  after a terminal status.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@mangoknight mangoknight changed the title fix(scheduler): fail fast on download-path scheduler calls fix(preheat): async snapshot sizing and fail-fast scheduler calls Oct 13, 2026
@cooocy
cooocy self-requested a review October 13, 2026 09:56
@mangoknight
mangoknight added this pull request to the merge queue Oct 13, 2026
Merged via the queue into dingodb:main with commit 2a1a1c6 Oct 13, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants