Skip to content

Register ACE schema with Spock skip_schema on MtreeInit#128

Open
danolivo wants to merge 1 commit into
mainfrom
spock-565
Open

Register ACE schema with Spock skip_schema on MtreeInit#128
danolivo wants to merge 1 commit into
mainfrom
spock-565

Conversation

@danolivo

Copy link
Copy Markdown
Contributor

ACE owns a metadata schema (mtree.schema, default pgedge_ace) on every cluster node. The objects in that schema — Merkle trees, CDC bookkeeping, per-node counters — are node-local by design. If Spock ever replicates them, peers corrupt each other.

The recent Spock node-level skip_schema feature (spock@4396157d, spock@14c7f0ed) provides exactly the hook we need: a schema named in spock.node.info->'skip_schema' is excluded from structure sync, refused by repset_add_table, and dropped in-stream by the walsender. This PR has ACE register its own schema with that mechanism the moment it creates it.

What changes

  • db/queries/templates.go — new RegisterSkipSchema SQL template.
  • db/queries/queries.goRegisterSkipSchema(ctx, db, schemaName) wrapper, returns rows affected.
  • internal/consistency/mtree/merkle.goinitOneNode calls it immediately after queries.CreateSchema.

Append the configured mtree.schema to spock.node.info->'skip_schema'
right after creating it on each node. The UPDATE is additive and
idempotent, so operator-set entries are preserved and re-runs are
noops. Best-effort: failures log a warning instead of aborting init.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@danolivo danolivo added the enhancement New feature or request label Jun 26, 2026
@danolivo danolivo requested a review from mason-sharp June 26, 2026 11:46
@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This change adds a query helper and SQL template for registering a schema in Spock’s skip_schema JSONB field, then calls that helper during node initialization after the ACE schema is created.

Changes

Skip-schema registration

Layer / File(s) Summary
Template and query helper
db/queries/templates.go, db/queries/queries.go
Adds RegisterSkipSchema to the template set, defines the idempotent spock.node.info update SQL, and adds a helper that renders the SQL, executes it with schemaName, and returns RowsAffected().
Node initialization wiring
internal/consistency/mtree/merkle.go
Calls queries.RegisterSkipSchema after creating m.aceSchema(), logs warnings on errors, and logs when rows are affected.

Poem

I hopped through the schema with a nibble and grin 🐰
A skip-list sprouted where the new paths begin
One hop for the query, one hop for the call
Now the node keeps its secrets from replication’s sprawl

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: registering the ACE schema with Spock skip_schema during MtreeInit.
Description check ✅ Passed The description matches the implemented changes and explains the Spock skip_schema registration workflow.
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.
✨ 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 spock-565

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.

@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

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.

@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

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@db/queries/templates.go`:
- Around line 695-706: The RegisterSkipSchema template is updating
spock.node.info directly, but skip_schema must be supplied through
spock.sub_create or the related subscription API instead. Move this logic out of
the JSONB update in templates.go and wire the skip_schema list into the
subscription creation path, using the existing spock.sub_create integration
points so the value is consumed by Spock as intended.
🪄 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: 6cf92325-1a9c-4a86-aa77-16d5370f7512

📥 Commits

Reviewing files that changed from the base of the PR and between 5fb45b6 and b786cbc.

📒 Files selected for processing (3)
  • db/queries/queries.go
  • db/queries/templates.go
  • internal/consistency/mtree/merkle.go

Comment thread db/queries/templates.go
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