Skip to content

Where do non-user-coordinated writes and appends belong in the 4.0 plan? #6

Open

Description

@maxrjones

TL;DR: the 4.0 plan covers the read path thoroughly but assumes writes are user-coordinated. The two patterns that produce large Zarr archives (parallel disjoint-region writes and append-along-axis growth) have no design home. IIRC, Ryan Abernathey postulated coordinated/distributed writes as the flagship Zarr V4 feature at the Zarr Summit, so this gap is worth a deliberate decision. Where should it live, and what's the Zarr-Python / Icechunk seam? Input from both maintainer groups would be especially valuable.

Context

The read path is well covered: lazy indexing + a query planner, range coalescing, request dedup, a caching substrate, ETag revalidation, pre-allocated buffers, and an engine boundary for zarrs / TensorStore.

The write path is not. The plan implicitly assumes the caller handles coordination. I.e., not clobbering shared chunks, creating the array before anyone writes, cleaning up after a failed distributed write. That holds for one process writing a whole array. It doesn't match how large archives are produced, where no single process holds the array open and many workers (or many sequential jobs) mutate one logical array.

The two patterns

1. Parallel disjoint-region writes

A coordinator creates the array once. N workers then each write a non-overlapping slab, lock-free. This is xarray.to_zarr(region=...) under Dask, Pangeo Forge recipes, and sharded ML checkpointing, the workhorse for petabyte-scale archives. Unaddressed problems:

  • Create vs. write. No first-class "create the array, then hand out write regions" primitive, and no guard against writing into an uninitialized array (or racing to initialize it).
  • Chunk alignment. Regions are only safe if disjoint at the chunk level. A boundary inside a chunk means two workers read-modify-write it and one update is silently lost. Nothing surfaces or checks this.
  • Partial failure. A write that dies halfway leaves the array torn: some chunks present, metadata claiming the full shape. No transaction boundary, so no clean roll-back or resume.

2. Append / time-series growth

A daily/hourly job extends an array along a time axis (NOAA, ECMWF, every operational pipeline). An append is a coupled metadata-update + chunk-write (resize shape, then write the new chunks), which is what makes it more than a region write:

  • Metadata races. Resize mutates array metadata, and concurrent appenders race on it. There is no atomic "extend and claim the new region."
  • Partial-edge chunks. If the axis length isn't a chunk multiple, the last chunk is partially filled, so appending is a read-modify-write on an existing chunk, which is more dangerous than fresh writes and bad for concurrent readers.
  • Read-during-append. A reader mid-append may see resized metadata before its chunks exist, or vice versa. What can it rely on?

What the roadmap covers, and what it doesn't

Adjacent work exists but doesn't solve this:

  • Performance / concurrency: concurrency within one process's IO, not across processes or jobs.
  • Transactional stores: store-level multi-key atomicity and ETag conditional writes. A necessary substrate, but not an array-level story: it doesn't answer "how do N workers safely fill one array," "how does append atomically extend shape-plus-chunks," or "how do I recover a torn write."
  • Engine boundary: routes IO through zarrs / TensorStore, but the coordination semantics are exactly what would need specifying for engines to behave consistently.

The gap: no proposal owns array-creation-and-region-handout, atomic append, or distributed-write recovery. It falls between the store-transaction layer (too low) and "the user coordinates it" (no layer). This is the part of the lifecycle that decides whether Zarr-Python scales for its largest producers, not just its largest consumers.

Questions for discussion

  1. In scope for 4.0, or delegated? A fine answer is "coordinated writes are Icechunk's job; Zarr-Python provides the chunk primitives." If so, say it, and define the seam: what must Zarr-Python expose so Icechunk (and others) build coordination on top without re-implementing the hierarchy layer?
  2. Where would it live? Own proposal? Hierarchy-layer verbs (atomic region_write, append)? An array-level layer on the transactional-stores substrate?
  3. Create + region handout: a first-class "create, then hand out disjoint write regions" primitive with chunk-alignment checked, not assumed?
  4. Atomic append: a named op coupling resize + chunk writes, with defined partial-edge and concurrent-appender behavior?
  5. Reader consistency: what can a reader assume mid-write, or is it "undefined until the writer signals done"?
  6. Partial-failure recovery: resumable/recoverable distributed writes in-library, or firmly Icechunk's?
  7. Spec implications: does any of this need format-level support (partial-shard rewrites, an "in-progress" metadata convention), or is it all implementation on the existing v3 format?

Prior art

  • xarray region= / append_dim=: the de facto user API, and the compatibility target.
  • Pangeo Forge: reference coordinator-creates / workers-fill at scale.
  • Dask to_zarr region writes: where the chunk-alignment failure modes show up.
  • Icechunk: distributed-write atomicity + recovery via a content-addressed, transactional manifest swap. The seam question, and a model to learn from.
  • TensorStore: open-with-create, atomic resize, concurrent-write coordination as first-class.
  • ML checkpointing (Orbax, Megatron dist_checkpointing): sharded-tensor writes with strict alignment/atomicity needs.

Activity

  1. d-v-b commented on Jun 8, 2026

    @d-v-b
    Collaborator

    as I understand it, safe, uncoordinated, distributed writes effectively requires a new storage format. That's why icechunk and ocdbt exist as storage specifications.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions