Skip to content

spock_apply: run exception-log work in ApplyOperationContext#499

Merged
mason-sharp merged 6 commits into
v5_STABLEfrom
MEM_CONSUM
Jun 15, 2026
Merged

spock_apply: run exception-log work in ApplyOperationContext#499
mason-sharp merged 6 commits into
v5_STABLEfrom
MEM_CONSUM

Conversation

@ibrarahmad

@ibrarahmad ibrarahmad commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

After RollbackAndReleaseCurrentSubTransaction the current memory context is TopTransactionContext, so per-row palloc in log_insert_exception accumulated for the whole apply transaction. Switch to ApplyOperationContext for the exception-log body and reset that context per message in handle_update and handle_delete.

Cycle | Before | After | Reduction
-- | -- | -- | --
1 | 446 MB | 110 MB | 75.3%
2 | 433 MB | 264 MB | 39.0%
3 | 609 MB | 310 MB | 49.1%
Average |   |   | 54.5%

SPOC-585

@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f7367899-5ff1-407a-b219-dcbe52bdc769

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch MEM_CONSUM

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.

@codacy-production

codacy-production Bot commented Jun 11, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 duplication

Metric Results
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@ibrarahmad ibrarahmad requested a review from mason-sharp June 11, 2026 15:00
@ibrarahmad ibrarahmad self-assigned this Jun 11, 2026
@ibrarahmad ibrarahmad added the enhancement New feature or request label Jun 11, 2026
Ibrar Ahmed added 6 commits June 15, 2026 12:06
After RollbackAndReleaseCurrentSubTransaction the current memory
context is TopTransactionContext, so per-row palloc in
log_insert_exception accumulated for the whole apply transaction.
Switch to ApplyOperationContext for the exception-log body and
reset that context per message in handle_update and handle_delete.
Trigger the use_try_block retry path by killing the apply worker
mid-transaction with sub_disable, then re-enabling so the new worker
matches its prior commit_lsn. Poll memory context snapshots while
apply is mid-transaction and assert TopTransactionContext stays well
under the pre-fix per-row growth.
Shorten the verbose MemoryContextSwitchTo comment, drop the brittle
"level: 2;" prefix from 022's three context regexes, and add use lib 't'.
…ndler

Replace the per-handler MemoryContextReset calls with a single reset
after each dispatched message instead of scattering them in handle_*.
@mason-sharp mason-sharp merged commit 275b2ef into v5_STABLE Jun 15, 2026
9 of 10 checks passed
@mason-sharp mason-sharp deleted the MEM_CONSUM branch June 15, 2026 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants