Skip to content

fix(postgres): clean local push configs on task truncate - #247

Merged
MisterVVP merged 4 commits into
mainfrom
dev-implement-cleanup-for-truncate-on-push-configs
Sep 15, 2026
Merged

MisterVVP merged 4 commits into
mainfrom
dev-implement-cleanup-for-truncate-on-push-configs

Conversation

@MisterVVP

@MisterVVP MisterVVP commented Sep 14, 2026 •

Copy link
Copy Markdown
Owner

Motivation

  • Row-level DELETE triggers do not fire for TRUNCATE, allowing locally owned push configs to survive an administrative TRUNCATE a2a_tasks and risk becoming active for a later reused task ID.
  • Harden maintenance/reset behavior so direct TRUNCATE cannot silently leave locally owned push configs behind while preserving externally owned rows.

Description

  • Bump migration marker to task-aware-push-config-v4 and extend the cleanup function to handle TG_OP = 'TRUNCATE' by deleting all rows where local_postgres_task is true and returning NULL for statement triggers.
  • Add an AFTER TRUNCATE ... FOR EACH STATEMENT trigger (a2a_truncate_task_push_configs_trigger) wired to the same cleanup helper and create it during auto_create_schema initialization without changing normal per-row delete coordination.
  • Extend managed-schema validation to require the truncate trigger (and to validate its wiring), update schema-init SQL to install the truncate trigger, and add a helper to drop the truncate trigger for conformance tests.
  • Add deterministic conformance tests that verify TRUNCATE removes only locally owned push configs and that externally managed schemas are rejected when the truncate trigger is missing, and update the docs in docs/storage.md and book/src/server/storage.md to document the migration and truncate semantics.

Testing

  • Ran ./scripts/verify_changes.sh, which includes clang-format --dry-run --Werror, CMake build, ctest (full unit/functional/ integration run), and clang-tidy, and it completed successfully.
  • Built with PostgreSQL enabled and executed targeted store conformance tests in build-postgres including StoreConformanceTest.TaskTableTruncateRemovesOnlyLocalPushConfigs, StoreConformanceTest.ExternallyManagedPushSchemaRequiresTruncateCleanupTrigger, and StoreConformanceTest.LocalTaskDeletionPreservesExternalTaskStoreConfigs, which passed in the test environment.
  • Ran targeted clang-tidy on changed PostgreSQL sources and the conformance test file, and executed the performance smoke suite (./scripts/run_performance_tests.sh) which reported zero errors.
  • Documentation build with mdbook was not available in the environment and the external TCK checkout failed due to network/proxy restrictions, noted as environmental caveats.

@MisterVVP MisterVVP added the codex Automatic label added by codex agent. Should not be used label Sep 14, 2026 — with ChatGPT Codex Connector
@MisterVVP MisterVVP self-assigned this Sep 14, 2026
@MisterVVP MisterVVP added AI agent AI agent contribution and removed codex Automatic label added by codex agent. Should not be used labels Sep 14, 2026
@MisterVVP MisterVVP linked an issue Sep 14, 2026 that may be closed by this pull request
@MisterVVP

Copy link
Copy Markdown
Owner Author

@codex review this PR

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c63b5731b1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/server/stores/postgres_common.cpp Resolved
Comment thread src/server/stores/postgres_common.cpp Resolved
Comment thread book/src/server/storage.md Resolved
Comment thread src/server/stores/postgres_common.cpp Resolved
…gger support (#248)

### Motivation
- Ensure TRUNCATE-based cleanup cannot run under snapshot isolation
where a stale snapshot could miss concurrently committed local push
configs.
- Extend SQL generation, schema validation, docs, and tests to fully
support statement-level `TRUNCATE` triggers and validation of their
behavior.

### Description
- Added a `TRUNCATE` branch to the push-config cleanup trigger that
raises an exception if the current transaction isolation is `repeatable
read` or `serializable` and otherwise deletes locally-owned push
configs; updated generated function body in
`BuildDeleteTaskPushConfigsFunctionBody` accordingly.
- Introduced `kPostgresTruncateTriggerOperation` and a new error message
constant to centralize the `TRUNCATE` literal and isolation error text,
and updated trigger/SQL builders to use the literal consistently.
- Expanded the push-schema validation SQL and parameter list to assert
the presence and literal form of the `TRUNCATE` handling in the cleanup
function, and increased related parameter/count constants.
- Updated documentation (`book/src/server/storage.md` and
`docs/storage.md`) to describe the new `AFTER TRUNCATE` trigger behavior
and the transaction-isolation rejection; added/adjusted several tests
and test helpers to validate the new behavior and literal-case
preservation.
@MisterVVP

Copy link
Copy Markdown
Owner Author

@codex review this PR

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f7475ca8ff

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@MisterVVP

Copy link
Copy Markdown
Owner Author

@codex review this PR

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: ef7275b9c9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@MisterVVP
MisterVVP marked this pull request as ready for review September 15, 2026 14:59
@MisterVVP
MisterVVP merged commit d97ca10 into main Sep 15, 2026
19 checks passed
@MisterVVP
MisterVVP deleted the dev-implement-cleanup-for-truncate-on-push-configs branch September 15, 2026 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI agent AI agent contribution maintenance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Task]: Handle PostgreSQL task-table TRUNCATE with local push configs

1 participant