Opened at 2022-12-14T16:53:25Z
Closed at 2023-01-10T20:53:42Z
#3956 closed defect (fixed)
Uploading a 20MB mutable fails in HTTP, but succeeds in Foolscap
Reported by: | itamarst | Owned by: | GitHub <noreply@…> |
---|---|---|---|
Priority: | normal | Milestone: | HTTP Storage Protocol |
Component: | unknown | Version: | n/a |
Keywords: | Cc: | ||
Launchpad Bug: |
Description (last modified by itamarst)
To reproduce: use benchmarks/upload_download.py from https://github.com/tahoe-lafs/tahoe-lafs/tree/3952-benchmarks, with a 20MB file. It'll run with Foolscap, but in HTTP:
> result = await self.clients[0].create_mutable_file(MutableData(DATA)) E allmydata.mutable.common.NotEnoughServersError: ("Publish ran out of good servers, last failure was: [Failure instance: Traceback: <class 'allmydata.storage.http_client.ClientException'>: (413, b'')\n/home/itamarst/devel/tahoe-lafs/venv/lib/python3.10/site-packages/twisted/internet/defer.py:734:errback\n/home/itamarst/devel/tahoe-lafs/venv/lib/python3.10/site-packages/twisted/internet/defer.py:797:_startRunCallbacks\n/home/itamarst/devel/tahoe-lafs/venv/lib/python3.10/site-packages/twisted/internet/defer.py:891:_runCallbacks\n/home/itamarst/devel/tahoe-lafs/venv/lib/python3.10/site-packages/twisted/internet/defer.py:1791:gotResult\n--- <exception caught here> ---\n/home/itamarst/devel/tahoe-lafs/venv/lib/python3.10/site-packages/twisted/internet/defer.py:1692:_inlineCallbacks\n/home/itamarst/devel/tahoe-lafs/venv/lib/python3.10/site-packages/twisted/python/failure.py:518:throwExceptionIntoGenerator\n/home/itamarst/devel/tahoe-lafs/src/allmydata/storage_client.py:1445:slot_testv_and_readv_and_writev\n/home/itamarst/devel/tahoe-lafs/venv/lib/python3.10/site-packages/twisted/internet/defer.py:1696:_inlineCallbacks\n/home/itamarst/devel/tahoe-lafs/src/allmydata/storage/http_client.py:868:read_test_write_chunks\n]", None)
That is, we're hitting a hard-coded size limit in the client code which presumably shouldn't be enforced given this works for Foolscap?
Change History (8)
comment:1 Changed at 2022-12-14T16:53:45Z by itamarst
- Description modified (diff)
comment:2 Changed at 2022-12-15T18:19:36Z by itamarst
comment:3 Changed at 2022-12-15T18:47:05Z by itamarst
cbor2 can parse from file, at least.
In theory one could do terrible things with mmap() such that the Rust CDDL (which requiers a byte slice) can validate a file.
But first... does the very flexible Foolscap mutable writing API actually use all that flexibility? If not, we might be able to simplify the HTTP protocol a lot.
comment:4 Changed at 2022-12-15T18:59:44Z by itamarst
The test vectors are "check strings", there's only one, and it looks like check strings are always short. But it's hard to be quite sure :( But plausibly saying "validation checks need to fit in an HTTP header" is actually a reasonable thing to try.
Digging deeper:
- Only place that generates _new_ calls to slot_testv_and_readv_and_writev (as opposed) to proxying are two styles of mutable in mutable/layout.py.
- Reads are only ever some sort of header info, never actual user data.
- There is only ever one test.
- Most of the time the checkstring is just composed of a sequence number, hash, and salt. So in this case it's small.
- The other time you have a checkstring is for bad shares (line 508 in mutable/publish.py). Bad share checkstrings are set via mark_bad_share() in mutable/servermap.py. As far as I can tell these are always "prefixes" of length 75 bytes.
So: seems like moving all the test vectors and read vectors into a HTTP header would work just fine. And then the body can be just the new data, and does not need to be CBOR validated... assuming there is only ever one write in the write vector. So next will look into that.
comment:5 Changed at 2022-12-19T15:00:35Z by itamarst
MDMF has multiple entries in the write vector. So options are:
- Coalesce them into a single write (likely to be possible, but need to investigate).
- Continue to do body as CBOR, and fudge the schema validation.
- Use the actual relevant HTTP feature... which isn't that different than option 2, really.
Next I will look into coalescing.
comment:6 Changed at 2022-12-19T18:56:50Z by itamarst
Coalescing is mostly OK, except! It's possible to do a write at an offset. So there will be holes, and when first creating a file a hole means null bytes (zeros), but later on it means "don't overwrite".
comment:7 Changed at 2022-12-20T15:31:43Z by itamarst
Given all the above, best bet is just:
- Increasing size limit of CBOR for the mutable upload case.
- Do our best to not use too much memory for CBOR parsing and CDDL validation.
comment:8 Changed at 2023-01-10T20:53:42Z by GitHub <noreply@…>
- Owner set to GitHub <noreply@…>
- Resolution set to fixed
- Status changed from new to closed
In 7ef1c020/trunk:
Mutable uploads get sent as CBOR, and we limit CBOR messages to 1MB cause we don't have streaming parsing or streaming validation at the moment.
Solutions might be: