ExStorageService.Metadata.GCGuard (ex_storage_service v0.6.4)

Copy Markdown View Source

Fences local physical deletion against concurrent object publication.

Writers atomically extend a per-hash guard while requiring the deletion lock to be absent. Collectors atomically claim the inverse condition. This closes the metadata-scan-to-file-delete race that a grace period alone cannot close.

Summary

Functions

claim(hash, node_id, node_generation, now_ms, lease_ms, opts \\ [])

@spec claim(
  binary(),
  binary(),
  pos_integer(),
  non_neg_integer(),
  pos_integer(),
  keyword()
) ::
  {:ok, map()} | {:error, term()}

lock_compare(hash, token)

@spec lock_compare(binary(), binary()) :: term()

release(hash, token, opts \\ [])

@spec release(binary(), binary(), keyword()) :: :ok | {:error, term()}

renew(hash, token, now_ms, lease_ms, opts \\ [])

@spec renew(binary(), binary(), non_neg_integer(), pos_integer(), keyword()) ::
  {:ok, map()} | {:error, term()}

Extends a collector lease while proving that the caller still owns the lock.

Collectors renew immediately before a physical rename or delete boundary so an expired owner cannot mutate bytes after a writer has replaced its lock.