ExStorageService.Metadata.BlobLocations (ex_storage_service v0.6.2)

Copy Markdown View Source

Strongly reads blob-location evidence and records read-path failures.

A failed or corrupt location transition and its durable repair intent are one Concord transaction. Phase 8 will dispatch these outbox events; reads never wait for that background work.

Summary

Functions

Removes the local location and releases its GC lock in one transaction.

Removes a draining location only while all supplied retained locations remain checksum-ready and the optional durable-job fence is still live.

Types

record()

@type record() :: %{
  key: binary(),
  location: ExStorageService.Metadata.Models.BlobLocation.t(),
  mod_revision: non_neg_integer()
}

Functions

authorize_cleanup(hash, node_id, target_generation, job_id, owner_node, owner_generation, fencing_token, opts \\ [])

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

Revalidates a prepared cleanup fence immediately before physical deletion.

The draining location stores the job token and the retained replica/topology snapshot established by mark_draining/3. This check fails closed if any of those records changed or the durable job lease is no longer live.

list(hash, opts \\ [])

@spec list(
  binary(),
  keyword()
) :: {:ok, [record()]} | {:error, term()}

mark_draining(hash, node_id, opts \\ [])

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

mark_ready(hash, node_id, generation, size, opts \\ [])

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

mark_unhealthy(hash, node_id, state, reason, opts \\ [])

@spec mark_unhealthy(binary(), binary(), :suspect | :unavailable, term(), keyword()) ::
  :ok | {:error, term()}

remove_after_gc(hash, node_id, generation, lock_token, opts \\ [])

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

Removes the local location and releases its GC lock in one transaction.

Callers must invoke this only after the physical representation was removed successfully. The generation and lock token comparisons prevent an old collector from deleting metadata for newly published bytes.

retire(hash, node_id, retained, opts \\ [])

@spec retire(binary(), binary(), [record()], keyword()) :: :ok | {:error, term()}

Removes a draining location only while all supplied retained locations remain checksum-ready and the optional durable-job fence is still live.