Skip to content

fix: scope cold Iceberg tables and watermark by PG schema#55

Merged
vyruss merged 2 commits into
mainfrom
fix/archiver-schema-scoping
Jul 21, 2026
Merged

fix: scope cold Iceberg tables and watermark by PG schema#55
vyruss merged 2 commits into
mainfrom
fix/archiver-schema-scoping

Conversation

@vyruss

@vyruss vyruss commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Each PG schema now maps to its own Iceberg namespace (ice.<schema>.<table>), and archive_watermark is keyed by (schema, table), so two same-named tables in different schemas no longer share cold storage or a watermark. Also makes archiver register idempotent (upsert). Adds a schema_collision regression test.

Closes #53, #52.

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The change makes Iceberg references and archival watermarks schema-aware, removes Iceberg namespace configuration, adds schema-qualified compactor input, makes partition configuration updates upserts, and aligns ColdFront tests, CI setup, examples, and documentation with the public namespace.

Changes

Schema-scoped archiving

Layer / File(s) Summary
Schema-aware watermark and extension runtime
extension/coldfront/..., internal/watermark/..., internal/view/...
archive_watermark and related ColdFront runtime lookups now use (schema_name, table_name); decoupled Iceberg references and regression coverage are schema-qualified.
Schema-derived archiver and compactor identifiers
cmd/archiver/..., cmd/compactor/...
Archiver Iceberg references derive from source schemas, while compactor table arguments accept [schema.]table and default to public.
Configuration removal and partition upsert
internal/config/..., internal/partcfg/...
Iceberg namespace configuration and defaults are removed, and partition configuration insertion updates conflicting schema/table rows.
CI fixtures and documentation
ci/..., config.example.yaml, docs/..., examples/...
Generated configurations omit the removed namespace field, namespace setup uses public, and Iceberg examples use ice.public.

Estimated code review effort: 4 (Complex) | ~45 minutes

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The upsert work in internal/partcfg is unrelated to linked issue #53's schema-scoping fix and appears out of scope. Split the archiver-register idempotence changes into a separate PR, or link the missing issue if they are intended to be part of this scope.
Docstring Coverage ⚠️ Warning Docstring coverage is 30.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: scoping Iceberg tables and watermarks by PostgreSQL schema.
Description check ✅ Passed The description matches the changes, covering schema-scoped cold storage, watermark keying, idempotent register, and the schema_collision test.
Linked Issues check ✅ Passed The changes address #53 by making Iceberg refs and watermark lookups schema-aware, preventing same-named tables from sharing cold data.
✨ 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 fix/archiver-schema-scoping

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 complexity · 0 duplication

Metric Results
Complexity 0
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

🧹 Nitpick comments (1)
internal/view/view_test.go (1)

164-164: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Assert the table predicate too.

This assertion covers only half of the composite lookup. Add table_name = 'events' so the test detects dropped or incorrectly bound table scoping.

Suggested assertion
 assert.Contains(t, sql, "schema_name = 'public'") // watermark lookup is schema-scoped
+assert.Contains(t, sql, "table_name = 'events'")
🤖 Prompt for 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.

In `@internal/view/view_test.go` at line 164, Update the SQL assertion in the
relevant view test to also require the table predicate table_name = 'events'
alongside the existing schema_name check. Keep the assertion focused on
validating both components of the schema-scoped watermark lookup.
🤖 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 `@docs/walkthrough.md`:
- Around line 81-83: Update the runnable namespace-seeding snippet in the
walkthrough to make repeated execution succeed: handle an already-existing
namespace by ignoring the duplicate response or checking for existence before
POSTing. Keep the existing bootstrap and warehouse retry behavior unchanged.

---

Nitpick comments:
In `@internal/view/view_test.go`:
- Line 164: Update the SQL assertion in the relevant view test to also require
the table predicate table_name = 'events' alongside the existing schema_name
check. Keep the assertion focused on validating both components of the
schema-scoped watermark lookup.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 11397183-372c-4766-8458-d490e942a70b

📥 Commits

Reviewing files that changed from the base of the PR and between 83f8810 and 7a05b4f.

⛔ Files ignored due to path filters (24)
  • extension/coldfront/test/expected/allow_mixed_writes.out is excluded by !**/*.out
  • extension/coldfront/test/expected/bakery_wraps_cold_writes.out is excluded by !**/*.out
  • extension/coldfront/test/expected/cast_in_dquoted_identifier.out is excluded by !**/*.out
  • extension/coldfront/test/expected/cast_literal_in_value.out is excluded by !**/*.out
  • extension/coldfront/test/expected/cast_normalize.out is excluded by !**/*.out
  • extension/coldfront/test/expected/classify_between_in_or.out is excluded by !**/*.out
  • extension/coldfront/test/expected/classify_now.out is excluded by !**/*.out
  • extension/coldfront/test/expected/cte_on_dml.out is excluded by !**/*.out
  • extension/coldfront/test/expected/cte_on_insert.out is excluded by !**/*.out
  • extension/coldfront/test/expected/cte_on_insert_1.out is excluded by !**/*.out
  • extension/coldfront/test/expected/ddl_rename_view.out is excluded by !**/*.out
  • extension/coldfront/test/expected/dollar_quote_in_value.out is excluded by !**/*.out
  • extension/coldfront/test/expected/mixed_case_identifier.out is excluded by !**/*.out
  • extension/coldfront/test/expected/param_cold_via_plpgsql.out is excluded by !**/*.out
  • extension/coldfront/test/expected/param_cold_via_plpgsql_1.out is excluded by !**/*.out
  • extension/coldfront/test/expected/returning_cold_rejected.out is excluded by !**/*.out
  • extension/coldfront/test/expected/returning_literal_in_where.out is excluded by !**/*.out
  • extension/coldfront/test/expected/schema_collision.out is excluded by !**/*.out
  • extension/coldfront/test/expected/self_join_rejected.out is excluded by !**/*.out
  • extension/coldfront/test/expected/update_ambiguous_rejected.out is excluded by !**/*.out
  • extension/coldfront/test/expected/update_cold_via_view.out is excluded by !**/*.out
  • extension/coldfront/test/expected/update_hot_via_view.out is excluded by !**/*.out
  • extension/coldfront/test/expected/update_partition_key_blocked.out is excluded by !**/*.out
  • extension/coldfront/test/expected/update_partition_key_move.out is excluded by !**/*.out
📒 Files selected for processing (50)
  • ci/journey.sh
  • ci/lib.sh
  • ci/probe-standby.sh
  • cmd/archiver/main.go
  • cmd/archiver/main_test.go
  • cmd/compactor/config.go
  • cmd/compactor/config_test.go
  • cmd/compactor/main.go
  • config.example.yaml
  • docs/architecture.md
  • docs/architecture_decoupled.md
  • docs/architecture_tiered.md
  • docs/compaction.md
  • docs/installation.md
  • docs/object_store.md
  • docs/usage.md
  • docs/walkthrough.md
  • examples/walkthrough/config/archiver.yaml
  • extension/coldfront/Makefile
  • extension/coldfront/coldfront--1.0.sql
  • extension/coldfront/test/sql/allow_mixed_writes.sql
  • extension/coldfront/test/sql/bakery_wraps_cold_writes.sql
  • extension/coldfront/test/sql/cast_in_dquoted_identifier.sql
  • extension/coldfront/test/sql/cast_literal_in_value.sql
  • extension/coldfront/test/sql/cast_normalize.sql
  • extension/coldfront/test/sql/classify_between_in_or.sql
  • extension/coldfront/test/sql/classify_now.sql
  • extension/coldfront/test/sql/cte_on_dml.sql
  • extension/coldfront/test/sql/cte_on_insert.sql
  • extension/coldfront/test/sql/ddl_rename_view.sql
  • extension/coldfront/test/sql/dollar_quote_in_value.sql
  • extension/coldfront/test/sql/mixed_case_identifier.sql
  • extension/coldfront/test/sql/param_cold_via_plpgsql.sql
  • extension/coldfront/test/sql/returning_cold_rejected.sql
  • extension/coldfront/test/sql/returning_literal_in_where.sql
  • extension/coldfront/test/sql/schema_collision.sql
  • extension/coldfront/test/sql/self_join_rejected.sql
  • extension/coldfront/test/sql/update_ambiguous_rejected.sql
  • extension/coldfront/test/sql/update_cold_via_view.sql
  • extension/coldfront/test/sql/update_hot_via_view.sql
  • extension/coldfront/test/sql/update_partition_key_blocked.sql
  • extension/coldfront/test/sql/update_partition_key_move.sql
  • internal/config/config.go
  • internal/config/config_test.go
  • internal/partcfg/commands.go
  • internal/partcfg/commands_test.go
  • internal/view/view.go
  • internal/view/view_test.go
  • internal/watermark/watermark.go
  • internal/watermark/watermark_test.go
💤 Files with no reviewable changes (5)
  • internal/config/config_test.go
  • examples/walkthrough/config/archiver.yaml
  • ci/probe-standby.sh
  • internal/config/config.go
  • config.example.yaml

Comment thread docs/walkthrough.md
Comment on lines 81 to 83
Bootstrap Lakekeeper, create the `wh` warehouse backed by SeaweedFS,
and seed the `default` namespace. The warehouse POST retries until
and seed the `public` namespace. The warehouse POST retries until
SeaweedFS is ready, and the namespace creation is idempotent:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n## docs/walkthrough.md excerpt\n'
nl -ba docs/walkthrough.md | sed -n '70,130p'

printf '\n## search for namespace creation references\n'
rg -n "namespace|public" -S docs src . --glob '!**/node_modules/**' --glob '!**/dist/**' --glob '!**/build/**' | sed -n '1,200p'

Repository: pgEdge/coldfront

Length of output: 226


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n## locate Lakekeeper namespace-create docs or API references\n'
rg -n "create.*namespace|namespace.*create|409|conflict|already exists|idempotent" -S . --glob '!**/node_modules/**' --glob '!**/dist/**' --glob '!**/build/**' | sed -n '1,240p'

Repository: pgEdge/coldfront

Length of output: 50372


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n## maybe API routes / handlers mentioning namespaces\n'
fd -a -t f . .

Repository: pgEdge/coldfront

Length of output: 11721


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n## docs/walkthrough.md lines 70-130\n'
sed -n '70,130p' docs/walkthrough.md | cat -n

printf '\n## examples/walkthrough/setup.sh\n'
sed -n '1,220p' examples/walkthrough/setup.sh | cat -n

printf '\n## docs/usage.md namespace references\n'
rg -n "namespace|idempotent|already exists|409" docs/usage.md docs/architecture.md docs/installation.md docs/index.md -n -S

Repository: pgEdge/coldfront

Length of output: 8170


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n## docs/walkthrough.md relevant section\n'
sed -n '75,125p' docs/walkthrough.md

printf '\n## examples/walkthrough/README.md\n'
sed -n '1,220p' examples/walkthrough/README.md

printf '\n## examples/walkthrough/guide.sh relevant namespace lines\n'
rg -n "namespace|POST|curl|public|idempotent|409|already exists" examples/walkthrough/guide.sh examples/walkthrough/setup.sh examples/walkthrough/runner.sh examples/walkthrough/install.sh -S

Repository: pgEdge/coldfront

Length of output: 15923


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n## docs/walkthrough.md lines 75-125\n'
sed -n '75,125p' docs/walkthrough.md

printf '\n## examples/walkthrough/setup.sh lines 1-220\n'
sed -n '1,220p' examples/walkthrough/setup.sh

printf '\n## docs/usage.md lines around namespace setup\n'
sed -n '50,80p' docs/usage.md

Repository: pgEdge/coldfront

Length of output: 5889


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n## focused search in walkthrough example files\n'
rg -n "curl|POST|namespace|warehouse|public|already exists|409|idempotent" \
  docs/walkthrough.md examples/walkthrough/{README.md,guide.sh,setup.sh,runner.sh,install.sh} \
  docs/usage.md docs/architecture.md \
  -S

Repository: pgEdge/coldfront

Length of output: 15049


Make the namespace seed rerunnable. The prose calls this idempotent, but the runnable snippet still uses a bare curl -sf POST with no duplicate handling, so a second run can fail on an existing namespace. Match this block to the guide script by ignoring the duplicate response or checking first.

🤖 Prompt for 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.

In `@docs/walkthrough.md` around lines 81 - 83, Update the runnable
namespace-seeding snippet in the walkthrough to make repeated execution succeed:
handle an already-existing namespace by ignoring the duplicate response or
checking for existence before POSTing. Keep the existing bootstrap and warehouse
retry behavior unchanged.

@vyruss

vyruss commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai "out-of-scope": cause is linked so intentionally kept in this PR via Closes #52. "Docstring coverage": exported (non-test) functions are already documented

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

@vyruss Thanks for clarifying. Since #52 is explicitly linked and closed by this PR, I agree that work is in scope. I also accept that exported non-test functions are already documented; I’ll withdraw both findings.


✏️ Learnings added
Learnt from: vyruss
URL: https://github.com/pgEdge/coldfront/pull/55

Timestamp: 2026-07-21T22:20:25.861Z
Learning: For GitHub PR `#55` in pgEdge/coldfront, changes related to issue `#52` are intentionally in scope because the PR explicitly closes `#52`. Exported non-test functions in this change are already documented; do not raise a docstring-coverage finding for them.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

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.

Data loss — same table name in two schemas maps to identical Iceberg table; second archive silently destroys first schema's cold data

1 participant