Skip to content

A new named query filter hides live rows from the object sweep, which then deletes their objects #538

Open

Description

@pdevito3

Summary

The sweep loaders keep every query filter of the model. A new named query filter, for example an archive filter, hides its rows from the sweep, so the sweep deletes the objects of those live rows after the grace.

Where

Main at 3b7a3c7122b9a3dd4a18c66c85640be95913ce4a.

  • NamedStorageKeys.cs:54-58. The loader queries dbContext.Set<TEntity>() with all filters on. It keeps them on purpose, so that a soft-deleted row names no key and the Tenant filter scopes the system caller.
  • QueryFilterNames.cs:3-7. Today only SoftDelete and Tenant exist, so the gap is latent.

Reproduction steps

  1. Add a named query filter Archived to the workshop attachment entity that hides rows with IsArchived = true.
  2. Add an attachment, then set IsArchived = true on its row.
  3. Move the clock past the grace (AddTimeout + Margin) with a fake TimeProvider, and run SweepObjects.
  4. Read the object from the bucket.

Expected

The sweep keeps the object, because a live row names it. Or a test fails as soon as a filter that the sweep does not know is added.

Actual

The sweep does not see the archived row and deletes its object. Un-archiving the row then points at a missing file.

Impact

Silent, irreversible data loss in an app that adds a query filter, which is a common change. No test or build check catches it.

Source

The re-review finding about a new app query filter in the review comment of #526: #526 (comment)

Suggested fix

From the review: ignore each query filter in the loader and apply the soft-delete rule and the tenant scope in the loader itself, or add a test that fails on a filter name that the sweep does not know.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions