From 846b806ed5f4ba2baf30ca21efa9da15d2c28624 Mon Sep 17 00:00:00 2001 From: eust-w Date: Fri, 30 Oct 2026 15:57:53 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=AA=20Hold=20the=20pause-resume=20body?= =?UTF-8?q?=20mid-stream=20so=20the=20pause=20lands=20in=20flight?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The native pause-resume scenario failed with both old and new builds because the harness could not reliably see an upload in flight. Pause itself behaved correctly. Client progress counts bytes handed to the socket, and the daemon writes it to SQLite once per second. Loopback buffers absorb about 1-3 MiB of a body (sometimes over 5 MiB on Linux), so a 4 MiB PUT read as 0 or as complete in nearly every sample. The trigger fired on the 3rd or 4th PUT at best, later or never under load, and never on Linux. With FILE_CONCURRENCY=2 and PUT_CONCURRENCY=1, the file queued behind the in-flight PUT is already dispatched and finishes too, so a late pause left nothing paused. The fixture now holds the first direct body after 64 KiB until the harness has paused. pause-resume uses the 12 MiB default size, so a held body still reads as partial. The scenario asserts that the held object arrives intact and that every received object was reserved before the pause. The daemon already follows the documented contract: pause stops new dispatch and lets in-flight objects finish. pause-resume: macOS arm64 10/10, Linux arm64 10/10 (old harness 0/5 on Linux). Full native matrix on macOS: 26/26. Co-Authored-By: Claude Opus 5.5 --- scripts/drosync-local-daily-acceptance.py | 29 +++++++++++++++++++---- tools/drosync/README.md | 2 ++ 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/scripts/drosync-local-daily-acceptance.py b/scripts/drosync-local-daily-acceptance.py index 779228fb..8a3b7971 100644 --- a/scripts/drosync-local-daily-acceptance.py +++ b/scripts/drosync-local-daily-acceptance.py @@ -67,6 +67,8 @@ class Control(http.server.ThreadingHTTPServer): self.uploads={} self.part_paths={} self.part_attempts={} + self.held=None + self.release_held=threading.Event() def session(self, sid): s = dict(self.sessions[sid]) @@ -128,6 +130,16 @@ class Handler(http.server.BaseHTTPRequestHandler): if spool:spool.write(part) n += len(part) time.sleep(0.001 if number else 0.015) + # Client progress counts bytes handed to loopback socket buffers and is + # sampled once per second, so a freely streaming body can read as 0 or + # complete in every sample. Park the first direct body mid-stream until + # the harness has paused, keeping that upload verifiably in flight. The + # body must exceed what buffers absorb while held: over 5 MiB on Linux. + if args.scenario=='pause-resume' and not number: + with c.lock: + hold=c.held is None + if hold:c.held=(iid,n) + if hold:c.release_held.wait(30) if args.scenario=='put-503' and c.injections==0: c.injections+=1 return self.reply({'code':'injected_storage_unavailable','message':'503 fixture','retryable':True},503) @@ -250,7 +262,7 @@ try: if args.scenario.startswith('concurrency-'):names=[f'parallel_{n}.bin' for n in range(8)] for name in names: f = episode / name - f.write_bytes(b'page' if args.scenario=='pagination-1003' else (name.encode()*2000000)[:4*1024*1024 if args.scenario=='pause-resume' or args.scenario.startswith('concurrency-') else 12*1024*1024]) + f.write_bytes(b'page' if args.scenario=='pagination-1003' else (name.encode()*2000000)[:4*1024*1024 if args.scenario.startswith('concurrency-') else 12*1024*1024]) if args.scenario in ['multipart-large','multipart-crash']: block=hashlib.md5(name.encode()).digest()*32768;remaining=(257 if name=='large_257.bin' else 321)*1024*1024 with f.open('wb') as writer: @@ -286,10 +298,13 @@ try: assert time.monotonic() < deadline, 'isolated upload exceeded 180 seconds' with http.open(f'http://127.0.0.1:{port}/api/progress', timeout=5) as response: progress=json.load(response);observed += progress['items'] - if not triggered and args.scenario in ['pause-resume','abort-active','crash-resume','source-rewrite','source-delete','multipart-crash'] and (args.scenario!='multipart-crash' or any(server.uploads.values())) and any(0