Skip to content

feat: execute droptable and reopen tasks in batch#421

Open
thweetkomputer wants to merge 2 commits intomainfrom
batch-global-request-zc
Open

feat: execute droptable and reopen tasks in batch#421
thweetkomputer wants to merge 2 commits intomainfrom
batch-global-request-zc

Conversation

@thweetkomputer
Copy link
Collaborator

@thweetkomputer thweetkomputer commented Mar 17, 2026

Here are some reminders before you submit the pull request

  • Add tests for the change
  • Document changes
  • Reference the link of issue using fixes eloqdb/eloqstore#issue_id
  • Reference the link of RFC if exists
  • Pass ctest --test-dir build/tests/

Summary by CodeRabbit

  • New Features

    • Added max_global_request_batch configuration option to control concurrent per-partition request limits for global operations (default: 1000).
  • Refactor

    • Enhanced scheduling and concurrency handling for table truncation, archive, and reopen operations with improved in-flight request management and error aggregation.

@coderabbitai
Copy link

coderabbitai bot commented Mar 17, 2026

Walkthrough

This PR introduces bounded in-flight request control for global operations in EloqStore. A new configuration option max_global_request_batch is added to KvOptions, and DropTable, GlobalArchiveRequest, and GlobalReopenRequest handlers are refactored to use coordinated state machines that limit concurrent per-partition requests while aggregating results.

Changes

Cohort / File(s) Summary
Configuration Structure
include/kv_options.h, src/kv_options.cpp
Added max_global_request_batch configuration option (default 1000) to limit per-partition request concurrency for global operations. Updated config loading and equality comparison.
Global Operation Scheduling
src/eloq_store.cpp
Refactored DropTable, GlobalArchiveRequest, and GlobalReopenRequest handling with state machine classes (DropTableScheduleState, ArchiveScheduleState, ReopenScheduleState) to manage in-flight request coordination, per-subrequest error aggregation, and inflight capping based on configuration.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • eatbreads

Poem

🐰 With states that dance and batches bound,
We hop through operations, sanely crowned!
Per-partition requests now gently flow,
No flooding streams—just measured pace below.
Archive, reopen, truncate with care—
A rabbit's gift of balance in the air! ✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is a template checklist with no actual content about the changes, missing issue references, RFC links, and implementation details required by the repository template. Fill in the template with actual change descriptions, reference the associated issue using 'fixes eloqdb/eloqstore#issue_id', link any RFC if applicable, and document the changes and tests added.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: execute droptable and reopen tasks in batch' accurately summarizes the main changes, which introduce batch scheduling for DropTable, Archive, and Reopen operations.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch batch-global-request-zc
📝 Coding Plan
  • Generate coding plan for human review comments

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/eloq_store.cpp (1)

933-938: Make the global scheduler bounded end-to-end.

Each handler now limits concurrent dispatch, but it still allocates one subrequest object per partition before the first send. That keeps heap growth proportional to partition count and repeats the same scheduler skeleton three times. A small shared helper that keeps only a bounded pool of live subrequests and creates them lazily would remove the duplication and make max_global_request_batch cover memory as well as concurrency.

Also applies to: 940-1008, 1176-1187, 1192-1260, 1398-1407, 1409-1496

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/eloq_store.cpp` around lines 933 - 938, The current handlers eagerly
allocate one subrequest per partition (e.g., creating TruncateRequest instances
and pushing into req->truncate_reqs_) which allows heap growth proportional to
partition count; refactor by introducing a small shared helper (e.g., a
BoundedSubrequestPool or make_lazy_subrequest_generator) that maintains at most
max_global_request_batch live subrequests, creates TruncateRequest (and the
other subrequest types used in the other handlers) lazily when about to
dispatch, and recycles/completes them when a dispatched subrequest finishes;
replace the per-partition eager loops that push into truncate_reqs_ with
iteration that obtains subrequests from this pool and sends them, and reuse the
same helper across the three similar handler sites (the ranges called out) so
memory is bounded by max_global_request_batch as well as concurrency.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/kv_options.cpp`:
- Around line 178-182: When loading max_global_request_batch in KvOptions (the
reader.HasValue/GetUnsigned block for sec_run and max_global_request_batch),
ensure a zero value is not accepted: after reading the unsigned value, normalize
0 to 1 (or reject by returning an error); additionally add a defensive check in
ValidateOptions() to assert max_global_request_batch > 0 and fail validation if
not. Update the reader.GetUnsigned usage for max_global_request_batch and the
ValidateOptions() logic in KvOptions to reference the same semantic (must be >
0).

---

Nitpick comments:
In `@src/eloq_store.cpp`:
- Around line 933-938: The current handlers eagerly allocate one subrequest per
partition (e.g., creating TruncateRequest instances and pushing into
req->truncate_reqs_) which allows heap growth proportional to partition count;
refactor by introducing a small shared helper (e.g., a BoundedSubrequestPool or
make_lazy_subrequest_generator) that maintains at most max_global_request_batch
live subrequests, creates TruncateRequest (and the other subrequest types used
in the other handlers) lazily when about to dispatch, and recycles/completes
them when a dispatched subrequest finishes; replace the per-partition eager
loops that push into truncate_reqs_ with iteration that obtains subrequests from
this pool and sends them, and reuse the same helper across the three similar
handler sites (the ranges called out) so memory is bounded by
max_global_request_batch as well as concurrency.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 63e013d1-96b6-4731-94f5-cf2bba06162e

📥 Commits

Reviewing files that changed from the base of the PR and between 24483fb and c85978c.

📒 Files selected for processing (3)
  • include/kv_options.h
  • src/eloq_store.cpp
  • src/kv_options.cpp

Comment on lines +178 to +182
if (reader.HasValue(sec_run, "max_global_request_batch"))
{
max_global_request_batch = reader.GetUnsigned(
sec_run, "max_global_request_batch", max_global_request_batch);
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Reject or normalize a zero batch limit here.

The schedulers later coerce max_global_request_batch == 0 to 1, so accepting 0 here leaves KvOptions in a state that never matches the effective runtime behavior. Please either validate > 0 in ValidateOptions() or normalize it once during load.
Based on learnings: "Enforce that max_inflight_write is greater than 0 before constructing IouringMgr ... Add an explicit check in the relevant initialization/ValidateOptions logic ..."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/kv_options.cpp` around lines 178 - 182, When loading
max_global_request_batch in KvOptions (the reader.HasValue/GetUnsigned block for
sec_run and max_global_request_batch), ensure a zero value is not accepted:
after reading the unsigned value, normalize 0 to 1 (or reject by returning an
error); additionally add a defensive check in ValidateOptions() to assert
max_global_request_batch > 0 and fail validation if not. Update the
reader.GetUnsigned usage for max_global_request_batch and the ValidateOptions()
logic in KvOptions to reference the same semantic (must be > 0).

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