Skip to content

Bug fix#368

Merged
liunyl merged 7 commits into
mainfrom
bug_fix
Jan 20, 2026
Merged

Bug fix#368
liunyl merged 7 commits into
mainfrom
bug_fix

Conversation

@liunyl

@liunyl liunyl commented Jan 18, 2026

Copy link
Copy Markdown
Contributor

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/tx_service#issue_id
  • Reference the link of RFC if exists
  • Pass ./mtr --suite=mono_main,mono_multi,mono_basic

Summary by CodeRabbit

  • Bug Fixes

    • Recycled key locks on successful aborts to prevent resource leaks.
    • Improved memory quota cleanup for range-partition data sync on early exits.
  • Refactor

    • Internal error/signaling pathways updated for more reliable emplacement handling.
    • Simplified internal data layout for slice coordination to make state handling clearer.
  • Chores

    • Reduced noise of a key-not-found diagnostic by lowering its log level.

✏️ Tip: You can customize this high-level summary in your review settings.


Note

Improves correctness and resource management across CC and data sync paths.

  • Refactors FindEmplace to accept bool* (was bool&); updates all call sites and internals; adds safeguard to not block sequence table updates when shard is full
  • Ensures key locks are recycled after successful AbortBlockCmdRequest() in cc_entry.h
  • Returns flush-memory quota on early-exit/error paths in local_cc_shards.cpp (when data_sync_vec is empty or prior flush failed)
  • Simplifies SliceCoordinator initialization (removes union/destructor; always initializes min_paused_key_ and min_paused_slice_index_)
  • Lowers noisy log to DLOG(INFO) in archive-read KEY_NOT_FOUND path

Written by Cursor Bugbot for commit 790350f. This will update automatically on new commits. Configure here.

@coderabbitai

coderabbitai Bot commented Jan 18, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

Walkthrough

Refactors FindEmplace to use a bool* output parameter, replaces an anonymous union with explicit min_paused_key_ and min_paused_slice_index_ fields in SliceCoordinator, adds flush memory quota deallocation on early exits in range-partition sync, recycles a key lock on successful abort, and lowers a log level for a key-not-found path.

Changes

Cohort / File(s) Summary
FindEmplace API Refactoring
tx_service/include/cc/template_cc_map.h, tx_service/include/cc/catalog_cc_map.h
Changed FindEmplace signature to accept bool *emplace (was bool/bool&). Call sites updated to pass &emplace; internal assignments now use *emplace = .... Added guard to skip emplacement for sequence table under specific read-only constraints.
SliceCoordinator Data Layout
tx_service/include/cc/cc_request.h
Removed anonymous union and destructor; introduced explicit public members TxKey min_paused_key_ and size_t min_paused_slice_index_. Constructors/reset now initialize both fields unconditionally.
Memory / Resource Cleanup
tx_service/src/cc/local_cc_shards.cpp, tx_service/include/cc/cc_entry.h
Added deallocation of data sync flush memory quota in two early-exit paths of DataSyncForRangePartition. In LruEntry::AbortBlockCmdRequest, capture return value and call RecycleKeyLock(*ccs) on success before returning.
Logging Adjustment
store_handler/data_store_service_client_closure.cpp
Downgraded LOG(INFO) to DLOG(INFO) for KEY_NOT_FOUND in SyncBatchReadForArchiveCallback.
Submodule Update
store_handler/eloq_data_store_service/eloqstore
Submodule reference (commit hash) updated; no code changes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • yi-xmu
  • MrGuin

Poem

🐰 I swapped a bool for a pointed twig,
freed quota crumbs from a flustered gig,
recycled locks with a gentle tug,
straightened keys and slices snug,
we hop on — code neat, small, and sprig! 🌱

🚥 Pre-merge checks | ❌ 3
❌ Failed checks (2 warnings, 1 inconclusive)
Check name Status Explanation Resolution
Description check ⚠️ Warning The description includes a checklist template but is missing critical details: no issue reference (fixes #issue_id), no RFC reference documentation, and no explicit confirmation that tests were added or that the test suite passed. Complete the checklist items: add issue reference using 'fixes eloqdb/tx_service#issue_id', confirm tests added and documentation updated, and verify test suite passed.
Docstring Coverage ⚠️ Warning Docstring coverage is 13.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Bug fix' is too vague and generic, failing to describe the specific changes or main purpose of the pull request. Replace with a more specific title that describes the primary bug being fixed, such as 'Fix key lock recycling in abort blocking commands' or similar.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bug_fix

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tx_service/include/cc/template_cc_map.h (1)

10055-10269: Fix compile error in BulkEmplaceForTest: pass address-of emplace parameter.

Line 9028 passes emplace (a bool value) to FindEmplace(), which expects bool *emplace (a pointer). Change the call to use &emplace.

Proposed fix
        for (auto key : keys)
        {
            bool emplace = false;
-           auto it = FindEmplace(*key, emplace, false, false);
+           auto it = FindEmplace(*key, &emplace, false, false);
            if (!emplace)
            {
                assert(false);

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@tx_service/include/cc/template_cc_map.h`:
- Around line 10055-10061: The code unconditionally dereferences the emplace
pointer in FindEmplace, which can crash if nullptr; update FindEmplace to either
assert(emplace) at entry or check if (emplace) before writing to *emplace (and
do the same for every other write to *emplace in this file), e.g., set local
bool temp=false and assign to *emplace only when emplace!=nullptr, or use an
explicit EXPECT or assert at start of the function to enforce the non-null
contract; apply the same guard/assert to the other spot that writes to *emplace
(the other FindEmplace/related emplace-handling callsite).

Comment on lines 10055 to 10061
Iterator FindEmplace(const KeyT &key,
bool &emplace,
bool *emplace,
bool force_emplace = false,
bool read_only_req = false)
{
emplace = false;
*emplace = false;
bool fail_if_not_found = false;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Guard against null emplace pointer before dereference.

Line 10060 and Line 10268 unconditionally dereference emplace. With the new pointer-based contract, a nullptr call would crash. Consider guarding the writes (or asserting non-null) to make the API safer.

🛠️ Suggested fix
-        *emplace = false;
+        if (emplace)
+        {
+            *emplace = false;
+        }
...
-        *emplace = true;
+        if (emplace)
+        {
+            *emplace = true;
+        }

Also applies to: 10267-10269

🤖 Prompt for AI Agents
In `@tx_service/include/cc/template_cc_map.h` around lines 10055 - 10061, The code
unconditionally dereferences the emplace pointer in FindEmplace, which can crash
if nullptr; update FindEmplace to either assert(emplace) at entry or check if
(emplace) before writing to *emplace (and do the same for every other write to
*emplace in this file), e.g., set local bool temp=false and assign to *emplace
only when emplace!=nullptr, or use an explicit EXPECT or assert at start of the
function to enforce the non-null contract; apply the same guard/assert to the
other spot that writes to *emplace (the other FindEmplace/related
emplace-handling callsite).

@githubzilla githubzilla 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.

+1

@liunyl liunyl merged commit da35c15 into main Jan 20, 2026
4 of 5 checks passed
@liunyl liunyl deleted the bug_fix branch January 20, 2026 03:00
This was referenced Jan 20, 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.

2 participants