Skip to content

fix: Clear a project's infra from the file registry when the project is deleted - #7228

Open
tushar-mahalya wants to merge 2 commits into
feast-dev:masterfrom
tushar-mahalya:fix/file-registry-teardown-infra
Open

tushar-mahalya wants to merge 2 commits into
feast-dev:masterfrom
tushar-mahalya:fix/file-registry-teardown-infra

Conversation

@tushar-mahalya

@tushar-mahalya tushar-mahalya commented Nov 24, 2026 •

Copy link
Copy Markdown

What this PR does / why we need it:

With the local provider and the sqlite online store, running feast apply, feast teardown and then feast apply again leaves the online store with no tables. feast teardown drops the tables and deletes the project from the file registry, but Registry.delete_project left the project's infra objects in the registry. The next feast apply diffs the desired infra against that stale record, prints "No changes to infrastructure" and creates nothing, so feast materialize fails with no such table. The test_workflow.py generated by feast init ends with feast teardown, so this is easy to run into.

FeatureStore.teardown now clears the tracked infra with registry.update_infra(Infra(), project) right after the provider has torn it down, and before the projects are deleted. If it ran after the delete loop, the file registry would re-create the project. Registry.delete_project is unchanged, so feast projects delete, which only removes registry metadata and leaves the tables, keeps the infra record and later applies can still drop obsolete tables. For the SQL registries the extra write is harmless, since delete_project removes the managed infra row anyway.

I added two tests in tests/unit/local_feast_tests/test_local_feature_store.py:

  • One runs the plan and _apply_diffs path the CLI uses, tears down, applies again, and checks that the sqlite tables are recreated. It fails without the change.
  • The other deletes a project in the registry only, re-applies with a renamed view, and checks that the old table is dropped.

I also ran the reproducer from the issue end to end: on master the second apply reports no changes and materialize fails, and with this change the tables are recreated and materialize succeeds.

Which issue(s) this PR fixes:

Fixes #7227

Checks

  • I've made sure the tests are passing.
  • My commits are signed off (git commit -s)
  • My PR title follows conventional commits format

Testing Strategy

  • Unit tests
  • Integration tests
  • Manual tests
  • Testing is not required for this change

Misc

The first commit cleared the infra in Registry.delete_project instead. The second commit moves it to teardown after review feedback, since delete_project is also used for registry-only deletion.

Two tests in tests/unit/local_feast_tests/test_local_feature_store.py that need Java (PySpark) fail on my machine with or without this change. Registry, CLI, diff and local feature store unit tests pass, and ruff and mypy are clean on the changed files.

Found and fixed with help from Claude Code; I reproduced and tested it myself.

…is deleted

`feast teardown` removes the online store but the file registry kept the
project's infra objects. The next `feast apply` diffed the desired infra
against that stale record, reported "No changes to infrastructure" and never
recreated the sqlite tables, so `feast materialize` failed with "no such table".
The SQL registry already deletes the managed infra row in delete_project; do the
same for the file registry, limited to objects named after the deleted project.

Signed-off-by: tushar-mahalya <tusharmahalya@gmail.com>
@tushar-mahalya
tushar-mahalya requested a review from a team as a code owner November 24, 2026 15:36

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Devin Review found 2 potential issues.

5 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)

Devin Review

Deleting a project from the file registry also removed its infra records, but
`feast projects delete` only removes registry metadata and leaves the online
store tables in place. A later apply could then no longer drop obsolete tables,
because diff_infra_protos only deletes objects that are both recorded and no
longer desired. The prefix match could also remove another project's records
(`a` vs `a_b`).

Revert the change to Registry.delete_project and clear the tracked infra in
FeatureStore.teardown instead, right after the provider has torn the infra down
and before the projects are deleted so the registry does not re-create the
project. SQL registries already drop the managed infra row in delete_project.

Signed-off-by: tushar-mahalya <tusharmahalya@gmail.com>
# re-create it), otherwise the next apply diffs against stale infra and
# skips re-creating the tables. SQL registries drop this record in
# delete_project; the file registry keeps it in the registry proto.
self.registry.update_infra(Infra(), self.project, commit=True)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The two added tests cover distinct behaviors, so keeping both seems reasonable.
However, update_infra(Infra(), self.project) clears infrastructure tracking globally; tearing down one project can leave another project’s obsolete tables untracked.
Could we preserve records for surviving tables and extend the teardown test to cover projects sharing a registry with separate databases?

@franciscojavierarceo franciscojavierarceo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we need to address the existing cross-project infrastructure tracking finding. Registry.update_infra copies into the single cached_registry_proto.infra field; its project argument does not scope that replacement. teardown_infra removes the current project's resources, so replacing the entire record with Infra() also forgets tables in other projects or databases. a later apply cannot reconcile those surviving tables. we should retain their infra records and cover teardown with two projects sharing a file registry and separate online databases.

This branch has not been deployed

No deployments
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.

feast apply after feast teardown does not recreate the sqlite online store tables

3 participants