Skip to content

SPOC-499: Remove spock.batch_inserts GUC and multi-insert apply machinery#415

Open
danolivo wants to merge 1 commit intomainfrom
spoc-499
Open

SPOC-499: Remove spock.batch_inserts GUC and multi-insert apply machinery#415
danolivo wants to merge 1 commit intomainfrom
spoc-499

Conversation

@danolivo
Copy link
Copy Markdown
Contributor

The batch-insert optimisation in the apply worker buffered consecutive inserts to the same relation and flushed them via heap_multi_insert(), gated by the spock.batch_inserts GUC. The feature was silently disabled whenever use_try_block was active, and the code itself contained an acknowledged TODO noting uncertainty around snapshot push/pop semantics and command-counter visibility — a subsequent UPDATE or DELETE replicated in the same transaction could need to see those buffered tuples, with no clear guarantee that was correct.

Given the correctness risk and the added complexity, the feature is removed entirely.

Changes

  • Drop the spock.batch_inserts GUC and its spock_batch_inserts global variable (spock.c, spock.h).
  • Remove multi_insert_finish() and all six of its call sites from spock_apply.c (at commit, relation-change, update, delete, and two points inside handle_insert).
  • Remove the ApplyMIState struct, the spkmistate static variable, and the entire spock_apply_heap_mi_*() function family (can_mi, mi_start, mi_flush, mi_add_tuple, mi_finish) from spock_apply_heap.c/.h.
  • Remove all user-facing documentation: docs/managing/batch_inserts.md (deleted), references in docs/configuring.md, docs/conflicts.md, docs/managing/index.md, and mkdocs.yml.
  • Remove the ApplyMIState typedef from utils/pgindent/typedefs.list.

Every INSERT now goes through the normal single-tuple apply path.

The batch-insert optimisation in the apply worker was gated by
spock.batch_inserts and relied on accumulating
consecutive inserts to the same relation before flushing them via
heap_multi_insert().  The logic was disabled entirely when
use_try_block was active, and had acknowledged correctness concerns
around snapshot semantics and command-counter visibility for
subsequently replicated DML that needed to see those tuples.

Remove the feature entirely: drop the GUC, the ApplyMIState struct,
the spkmistate static variable, multi_insert_finish() and all its
call sites, and the spock_apply_heap_mi_*() family of functions.
Remove matching documentation (batch_inserts.md, configuring.md,
conflicts.md, managing/index.md, mkdocs.yml) and the ApplyMIState
typedef from pgindent's typedefs.list.

Every INSERT now goes through the normal single-tuple apply path.
@danolivo danolivo requested a review from mason-sharp April 13, 2026 08:58
@danolivo danolivo self-assigned this Apr 13, 2026
@danolivo danolivo added the enhancement New feature or request label Apr 13, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 13, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4a5abce7-0c8e-4868-9a3f-54f5a385b262

📥 Commits

Reviewing files that changed from the base of the PR and between dfb56c2 and 182c415.

📒 Files selected for processing (11)
  • docs/configuring.md
  • docs/conflicts.md
  • docs/managing/batch_inserts.md
  • docs/managing/index.md
  • include/spock.h
  • include/spock_apply_heap.h
  • mkdocs.yml
  • src/spock.c
  • src/spock_apply.c
  • src/spock_apply_heap.c
  • utils/pgindent/typedefs.list
💤 Files with no reviewable changes (10)
  • docs/managing/index.md
  • include/spock.h
  • mkdocs.yml
  • docs/conflicts.md
  • utils/pgindent/typedefs.list
  • docs/managing/batch_inserts.md
  • src/spock.c
  • include/spock_apply_heap.h
  • src/spock_apply.c
  • src/spock_apply_heap.c

📝 Walkthrough

Walkthrough

This change removes the batch insert feature from the codebase, including its configuration option (spock.batch_inserts), related documentation, exported function declarations, and the heap-level multi-insert implementation that accumulated and bulk-inserted tuples for performance optimization.

Changes

Cohort / File(s) Summary
Documentation Files
docs/configuring.md, docs/conflicts.md, docs/managing/batch_inserts.md, docs/managing/index.md, mkdocs.yml
Removed all references to the batch insert feature, including the configuration option description, constraints on its usage, and navigation links to batch insert documentation.
Public Header Declarations
include/spock.h, include/spock_apply_heap.h
Removed exported global variable declaration and three public multi-insert function declarations (spock_apply_heap_can_mi, spock_apply_heap_mi_add_tuple, spock_apply_heap_mi_finish).
Configuration and Variable Registration
src/spock.c
Removed the global spock_batch_inserts variable and its GUC (Grand Unified Configuration) registration, eliminating the batch insert setting from PostgreSQL configuration control.
Core Apply Logic
src/spock_apply.c, src/spock_apply_heap.c
Removed multi-insert state management, buffering logic, and helper functions; eliminated conditional tuple accumulation and bulk-insert coordination from INSERT/UPDATE/DELETE handling paths. Deleted ApplyMIState type and internal lifecycle functions (spock_apply_heap_mi_start, spock_apply_heap_mi_flush).
Development Tools
utils/pgindent/typedefs.list
Removed ApplyMIState typedef entries from code formatting configuration.

Poem

🐰 A simpler path we now shall take,
No batching buffers left to break,
Each insert flows as nature planned,
One tuple at a time so grand,
The code grows lean, the logic clear,
Much cleaner than the code was here! 🌿

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: removal of the spock.batch_inserts GUC and its supporting multi-insert machinery, which is exactly what the changeset accomplishes across multiple files.
Description check ✅ Passed The description is directly related to the changeset, explaining the motivation for removing the batch-insert feature and comprehensively listing all the specific changes made across configuration, source code, headers, and documentation files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch spoc-499

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
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

TIP This summary will be updated as you push new changes. Give us feedback

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.

1 participant