Skip to content

Deadlock when using http kvstore within virtual_chunked #253

@sjperkins

Description

@sjperkins

Environment Details

$ uname -o -m -s -v -r
Linux 6.8.0-85-generic #85-Ubuntu SMP PREEMPT_DYNAMIC Thu Sep 18 15:26:59 UTC 2025 x86_64 GNU/Linux
$ python --version
Python 3.11.13
$ uv pip freeze | grep tensorstore
tensorstore==0.1.78

I'm accessing some npy files on a http/s3 store with the following simplified pattern:

import tensorstore as ts

def virtual_store_factory(endpoint: str, chunk_info: Dict):
  http_spec = { "driver": "http", "base_url": endpoint }
  http_store = ts.KvStore.open(http_spec).result()
  
  def read(domain, array, params):
    key_bits = [f"{o:05}" for o in domain.origin]
    key = f"prefix/{'_'.join(key_bits)}.npy"
    read_result = http_store.read(key).result()
    data = np.frombuffer(read_result.value[header_len:], dtype=dtype)   # Simplification
    tensor_data = ts.array(data)
    array[...] = tensor_data[domain.translate_backward_by[domain.origin]]
    return read_result.stamp

  return ts.virtual_chunked(
    read_function=read,  
    rank=len(chunk_info["chunks"]),
    shape=tuple(sum(dc) for dc in chunk_info["chunks"]),
    dtype=chunk_info["dtype"],
    chunk_layout=ts.ChunkLayout(chunk_shape=[c[0] for c in chunk_info["chunks"])
   )

If I then try use the store:

virtual_store = virtual_store_factory(...)
data = virtual_store[index].read().result()

I see from prints that all read_result = http_store.read(key).result() futures are issued and completed, but for some reason data = virtual_store[index].read().result() does not complete.

Question

  • Is using the http store within the virtual store conceptually incorrect in some way?
  • although, I imagine the http_store reference is retained within read's closure variable as long as virtual_store is alive.
  • Is there perhaps some more appropriate way of achieving the same result?

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