ExStorageService.Storage.Multipart (ex_storage_service v0.6.4)

Copy Markdown View Source

Multipart upload storage operations.

Manages the lifecycle of S3 multipart uploads: initiating uploads, storing individual parts, completing (concatenating) uploads, and aborting/cleaning up.

Cluster metadata uses encoded v2 upload and part keys. Standalone reads and writes retain the legacy "mpu:" / "mpu_part:" records for compatibility.

Part data is stored as global CAS blobs; cluster parts require their full desired replica count before the part record becomes visible.

Summary

Functions

Abort a multipart upload. Deletes upload and part metadata without deleting shared content-addressed blob bytes.

Complete a multipart upload.

Marks a prepared multipart upload complete.

Get upload metadata from Concord.

Initiate a new multipart upload. Returns {:ok, upload_id}.

List all active (non-completed) multipart uploads. Used by the GC.

List all parts for a multipart upload with their etags and sizes.

Builds and durably commits the final multipart blob without publishing object metadata or cleaning the upload.

Store a single part for a multipart upload.

Functions

abort_upload(bucket, upload_id)

Abort a multipart upload. Deletes upload and part metadata without deleting shared content-addressed blob bytes.

complete_upload(bucket, upload_id, parts)

Complete a multipart upload.

Concatenates all parts in order, computes final SHA-256 content hash and the S3 multipart etag (MD5-of-MD5s-partcount), moves the result to the content-addressed store, and cleans up part files.

parts is a list of {part_number, etag} tuples from the client XML.

Returns {:ok, {content_hash, etag, size, manifest_hash}}.

finalize_complete_upload(bucket, upload_id, prepared)

Marks a prepared multipart upload complete.

Standalone preserves its historical immediate metadata cleanup. Cluster mode retains part records through the orphan grace boundary so a lost completion response remains retryable; a later GC phase removes them asynchronously.

get_upload(bucket, upload_id)

Get upload metadata from Concord.

init_upload(bucket, key)

Initiate a new multipart upload. Returns {:ok, upload_id}.

list_active_uploads()

List all active (non-completed) multipart uploads. Used by the GC.

list_parts(bucket, upload_id)

List all parts for a multipart upload with their etags and sizes.

Returns {:ok, parts} where parts is a sorted list of part metadata maps.

prepare_complete_upload(bucket, upload_id, parts)

Builds and durably commits the final multipart blob without publishing object metadata or cleaning the upload.

The caller must publish the object through ExStorageService.ObjectService and call finalize_complete_upload/3 only after that metadata commit succeeds. A failure therefore leaves a retryable upload and a recoverable CAS orphan rather than a falsely completed upload.

store_part(bucket, upload_id, part_number, data)

Store a single part for a multipart upload.

Writes the part data to the global CAS and records metadata in Concord. Returns {:ok, etag} on success.