Skip to content

Clearing a cached artifact and queueing its file aren’t atomic #467

Open

Description

@pinguinfuss

#428 made retention clear the record and queue the file in pending_deletes in one transaction. Three other places still do it in two steps:

  • DiscardArtifact (internal/database/queries.go) clears the record, commits, then calls QueuePendingDelete.
  • UpsertArtifact commits the new storage path, then queues the old one separately.
  • The LRU loop in evictBatch (internal/server/eviction.go) clears the record, deletes the file, and only queues it if the delete fails.

A crash or a failed second write between the steps leaves a file in storage that no record points to and nothing will ever delete. I'd move each pair into one transaction, the same way ClearExpiredArtifact does now.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions