Skip to content

fix: prune old terminal instances#265

Open
nanookclaw wants to merge 2 commits into
microsoft:mainfrom
nanookclaw:fix/prune-terminal-instances
Open

fix: prune old terminal instances#265
nanookclaw wants to merge 2 commits into
microsoft:mainfrom
nanookclaw:fix/prune-terminal-instances

Conversation

@nanookclaw

Copy link
Copy Markdown

Summary

Closes #261.

This adds an hourly best-effort maintenance pass to the background worker that prunes old terminal workflow history from df.instances and the matching df.nodes rows. The retention policy is intentionally fixed for now: keep terminal rows for at least 30 days, and always keep the newest 10,000 terminal instances even if they are older.

The pruning query runs in one transaction with constraints deferred, ranks only terminal instances (completed, failed, cancelled) by COALESCE(completed_at, updated_at, created_at), deletes matching nodes first, then deletes the selected instance rows. Failures are logged and do not stop the worker runtime.

A focused pgrx test covers age cutoff, keep-count behavior, nonterminal retention, cancelled/failed/completed statuses, and node cleanup.

Validation

  • cargo fmt --check
  • git diff --check
  • cargo check --lib could not complete in this environment because pgrx build setup is unavailable: $PGRX_HOME does not exist.

@nanookclaw

Copy link
Copy Markdown
Author

Pushed c455288 to address the PG17 test failure.

The failing helper was reading pg_catalog.current_database() as String, but PG17 reports that expression as type name; the update casts it to text before Spi::get_one::<String>(...).

Local verification:

  • cargo fmt --all --check
  • git diff --check

cargo check is still blocked locally by the same pgrx setup gap ($PGRX_HOME missing / cargo-pgrx unavailable), so I’m relying on CI for the full PG17 pgrx test rerun.

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.

Periodically prune the instance and node tables

1 participant