Skip to content

fix(tasks): headless workers leave schedules, endpoint statistics and change-log pruning to the API processes - #2281

Merged
c-thiel merged 1 commit into
mainfrom
ct/headless-worker-background-services
Nov 13, 2026
Merged

c-thiel merged 1 commit into
mainfrom
ct/headless-worker-background-services

Conversation

@c-thiel

@c-thiel c-thiel commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Headless task workers (LAKEKEEPER__SERVE_HTTP_API=false) no longer queue the runs of task schedules, write endpoint statistics or prune the cache change log. The processes that serve the HTTP API already do this for the whole deployment, so a worker with a small database pool keeps its connections for its tasks, heartbeats and health checks.

Due schedules are claimed in the database, so one API process is enough. Workers always run next to API processes.

Every process now skips the endpoint statistics flush when it counted no call. Idle processes ran two reads and one insert every 30 seconds.

A failed endpoint statistics write logs a warning for each retry and one error when it gives up.

Release notes

  • Headless task workers no longer queue scheduled tasks, write endpoint statistics or prune the cache change log. The API processes do this, so workers with small database pools keep their connections for their tasks.
  • Idle processes no longer write empty endpoint statistics every 30 seconds.

Downstream follow-up

  • No public item changed. A statistics sink passed to a headless serve is now unused, and EndpointStatisticsSink::consume_endpoint_statistics is no longer called with an empty map.

Summary by CodeRabbit

  • Reliability

    • Endpoint statistics writes are retried after temporary failures. Empty reporting intervals no longer trigger writes, and failed writes are recorded as lost statistics.
    • Background services now run according to process mode and maintenance settings; read-only maintenance and headless processes avoid services that should not run there.
    • Cache-change-log pruning is limited to HTTP API processes and is disabled during read-only maintenance.
  • Documentation

    • Clarified which Lakekeeper instances queue scheduled jobs.

… change-log pruning to the API processes

Headless task workers (LAKEKEEPER__SERVE_HTTP_API=false) no longer run the task schedule materializer, the endpoint statistics tracker or the cache change-log pruner. The processes that serve the HTTP API do this for the whole deployment, so a worker's small database pool serves its tasks.

Every process skips the endpoint statistics flush when it counted no call. A failed statistics write logs a warning per retry and one error when it gives up.
@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Background-service startup now depends on HTTP API and maintenance-mode settings. Endpoint-statistics flushing skips empty batches, logs dropped batches, and retries PostgreSQL sink operations with backoff. Cache-log pruning and scheduled-job documentation now reflect HTTP API process eligibility.

Changes

Process services and endpoint statistics

Layer / File(s) Summary
Select and start process services
crates/lakekeeper/src/serve.rs, crates/lakekeeper/src/service/cache_invalidation/poller.rs, docs/docs/configuration.md
HTTP API processes start the endpoint-statistics tracker and oldest-due sampler. The task-schedule materializer also requires non-read-only maintenance mode. Cache-log pruning requires the HTTP API and non-read-only maintenance mode. The documentation describes scheduled-job queuing on HTTP API instances and excludes headless workers.
Flush counted endpoint statistics
crates/lakekeeper/src/service/endpoint_statistics.rs
The tracker skips sink calls when no endpoint calls were counted. Sink failures log the dropped batch. A test checks empty and nonempty flushes.
Retry PostgreSQL sink operations
crates/lakekeeper-storage-postgres/src/endpoint_statistics/sink.rs
The sink retries processing up to five times with exponential backoff. It removes local error logs while retaining API error conversion for insert and lookup failures.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Possibly related PRs

Suggested reviewers: brgr-s

Merge Risk: Minimal · up to e1d3f

Headless workers stop running scheduled-task materialization, statistics writes and cache-log pruning, leaving those jobs to API-serving processes. No concrete merge-blocking risk was identified in the supplied change context.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: headless task workers no longer run schedules, endpoint statistics, or change-log pruning, which the API processes handle instead. The raw summary confirms this in ser…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: headless task workers no longer run schedules, endpoint statistics, or change-log pruning, which the API processes handle instead. The raw summary confirms this in serve.rs, poller.rs, and endpoint_statistics.rs, and the objectives state the same intent. The title is specific and accurate. It is 109 characters, which is long for a title, but the content is on target.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit counts each call with care,
Then skips the empty batch of air.
If retries hop through delays,
The tracker logs the lost arrays.
HTTP paths decide who starts,
While headless stays apart.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a875fde2-8a16-4e0f-be7b-1f6b8489b238
Commits

Reviewing files that changed from the base of the PR and between c18bc33 and e1d3f68.

Files selected for processing: 5

  • crates/lakekeeper-storage-postgres/src/endpoint_statistics/sink.rs
  • crates/lakekeeper/src/serve.rs
  • crates/lakekeeper/src/service/cache_invalidation/poller.rs
  • crates/lakekeeper/src/service/endpoint_statistics.rs
  • docs/docs/configuration.md

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 1 remain after this review.

@github-actions

Copy link
Copy Markdown
Contributor

✅ PR Title Formatted Correctly

The title of this PR match the correct format. Thank you!

@c-thiel
c-thiel merged commit 04526c4 into main Nov 13, 2026
72 of 73 checks passed
@c-thiel
c-thiel deleted the ct/headless-worker-background-services branch November 13, 2026 07:00
c-thiel added a commit that referenced this pull request Nov 14, 2026
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.

1 participant