All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michal Sieron" <michalwsieron@gmail.com>
To: bitbake-devel@lists.openembedded.org
Subject: Re: [PATCH v2 00/10] hashserv: Pipeline Upstream Queries
Date: Wed, 26 Aug 2026 15:48:04 -0700	[thread overview]
Message-ID: <2326647.1787784484085855892@lists.openembedded.org> (raw)
In-Reply-To: <CAJdd5Ga8omZNt_KBBrrLvLhhUYgBa7ptq20vcd3zNX+ZpNiJAw@mail.gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 606 bytes --]

Hi Joshua,

> Any chance you've had time to look at this more? I've been unable to reproduce this particular issue. It looks like the server is just crashing or stuck somewhere where it's no longer responding, but I can't quite figure out where that might be occurring.

Unfortunately, I did not. But I just tried it again on my setup (new changes pulled since last time), and it reproduced immediately.
As I still don't have *that much* time to debug this I went and threw this at Cursor, which did find the issue and generated a fix and a minimal repro test.
I attached the patch.

Br,
Michał

[-- Attachment #1.2: Type: text/html, Size: 737 bytes --]

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-hashserv-server-Fix-upstream-get-unihash-miss-trunca.patch --]
[-- Type: text/x-patch; name="0001-hashserv-server-Fix-upstream-get-unihash-miss-trunca.patch", Size: 3880 bytes --]

From 5bc6f9834c56327db2e853af6d7d188f40011b4f Mon Sep 17 00:00:00 2001
From: Michal Sieron <michal.sieron@nokia.com>
Date: Thu, 27 Aug 2026 00:28:24 +0200
Subject: [PATCH] hashserv: server: Fix upstream get-unihash miss truncating
 stream

When an upstream hash equivalence server is configured,
handle_get_stream() resolves each query through get_upstream_result().
On an upstream miss this returned None, but None is the end-of-stream
sentinel consumed by _stream_queue_handler(). Returning it there
terminated the response stream early, so the downstream client received
fewer replies than it sent, timed out and retried.

Return an empty string ("") on a miss instead, which matches the
non-upstream get-stream handler.

Also add test_upstream_get_stream_miss covering an interleaved miss/hit
batch, an all-miss batch, and a singular miss through an upstream.

AI-Generated: Uses Cursor
Signed-off-by: Michal Sieron <michal.sieron@nokia.com>
---
 lib/hashserv/server.py |  4 +++-
 lib/hashserv/tests.py  | 37 +++++++++++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+), 1 deletion(-)

diff --git a/lib/hashserv/server.py b/lib/hashserv/server.py
index 0153730fa..e28149257 100644
--- a/lib/hashserv/server.py
+++ b/lib/hashserv/server.py
@@ -504,7 +504,9 @@ class ServerClient(bb.asyncrpc.AsyncServerConnection):
                 if unihash:
                     method, taskhash = m.split()
                     await self.server.backfill_queue.put((method, taskhash))
-                return unihash
+                # On miss replace `None` with `""` to match non-upstream handler
+                # and avoid stream truncation.
+                return unihash or ""
 
             queue = asyncio.Queue()
             upstream = UpstreamQueue(
diff --git a/lib/hashserv/tests.py b/lib/hashserv/tests.py
index 6201ce3bd..15ee7ecde 100644
--- a/lib/hashserv/tests.py
+++ b/lib/hashserv/tests.py
@@ -606,6 +606,43 @@ class HashEquivalenceCommonTests(object):
 
         asyncio.run(check_unihashes())
 
+    def test_upstream_get_stream_miss(self):
+        down_server = self.start_server(upstream=self.server.address)
+        down_client = self.start_client(down_server.address)
+
+        # Two hashes present upstream (hits)
+        taskhash1 = '8aa96fcffb5831b3c2c0cb75f0431e3f8b20554a'
+        outhash1 = 'afe240a439959ce86f5e322f8c208e1fedefea9e813f2140c81af866cc9edf7e'
+        unihash1 = '5b521d8a12683086cc08bc2c6d94a7a2dcff17eba53b9911e145d51164689380'
+        self.client.report_unihash(taskhash1, self.METHOD, outhash1, unihash1)
+
+        taskhash2 = 'e3da00593d6a7fb435c7e2114976c59c5fd6d561'
+        outhash2 = '1cf8713e645f491eb9c959d20b5cae1c47133a292626dda9b10709857cbe688a'
+        unihash2 = '7aebef07d66a8c0f92d0c4f65ec8b1fbb850a3693c53827b8774b64fa9a8a9fe'
+        self.client.report_unihash(taskhash2, self.METHOD, outhash2, unihash2)
+
+        # Two taskhashes present nowhere (upstream misses)
+        miss1 = '0000000000000000000000000000000000000001'
+        miss2 = '0000000000000000000000000000000000000002'
+
+        # Miss interleaved with hits: a miss must not truncate the stream
+        results = down_client.get_unihash_batch([
+            (self.METHOD, miss1),
+            (self.METHOD, taskhash1),
+            (self.METHOD, miss2),
+            (self.METHOD, taskhash2),
+        ])
+        self.assertEqual(results, [None, unihash1, None, unihash2])
+
+        # All-miss batch
+        self.assertEqual(
+            down_client.get_unihash_batch([(self.METHOD, miss1), (self.METHOD, miss2)]),
+            [None, None],
+        )
+
+        # Singular get-unihash miss
+        self.assertClientGetHash(down_client, miss1, None)
+
     def test_unihash_exsits(self):
         taskhash, outhash, unihash = self.create_test_hash(self.client)
         self.assertTrue(self.client.unihash_exists(unihash))

  reply	other threads:[~2026-08-26 22:48 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-24 21:25 [bitbake-devel][PATCH 0/6] hashserv: Pipeline Upstream Queries Joshua Watt
2026-07-24 21:25 ` [bitbake-devel][PATCH 1/6] hashserv: client: Add asynchronous streaming API Joshua Watt
2026-07-24 21:25 ` [bitbake-devel][PATCH 2/6] hashserv: server: Fix formatting Joshua Watt
2026-07-24 21:25 ` [bitbake-devel][PATCH 3/6] hashserv: server: Add queued streaming API Joshua Watt
2026-07-24 21:25 ` [bitbake-devel][PATCH 4/6] hashserv: server: Use streaming and queue API for upstream unihash queries Joshua Watt
2026-07-24 21:25 ` [bitbake-devel][PATCH 5/6] hashserv: server: Use streaming and queue API for upstream exist queries Joshua Watt
2026-07-24 21:25 ` [bitbake-devel][PATCH 6/6] hashserv: tests: Add test for upstream pipelining Joshua Watt
2026-07-26 13:50 ` [bitbake-devel][PATCH 0/6] hashserv: Pipeline Upstream Queries Richard Purdie
2026-07-30 18:30 ` [bitbake-devel][PATCH v2 00/10] " Joshua Watt
2026-07-30 18:30   ` [bitbake-devel][PATCH v2 01/10] asyncrpc: Add Task Group Joshua Watt
2026-07-30 18:30   ` [bitbake-devel][PATCH v2 02/10] asyncrpc: serv: Use " Joshua Watt
2026-07-30 18:30   ` [bitbake-devel][PATCH v2 03/10] asyncrpc: serv: Cancel all clients on server stop Joshua Watt
2026-07-30 18:30   ` [bitbake-devel][PATCH v2 04/10] hashserv: tests: Improve test logging Joshua Watt
2026-07-30 18:30   ` [bitbake-devel][PATCH v2 05/10] hashserv: client: Add asynchronous streaming API Joshua Watt
2026-07-30 18:30   ` [bitbake-devel][PATCH v2 06/10] hashserv: server: Add queued " Joshua Watt
2026-07-30 18:31   ` [bitbake-devel][PATCH v2 07/10] hashserv: server: Use streaming and queue API for upstream unihash queries Joshua Watt
2026-07-30 18:31   ` [bitbake-devel][PATCH v2 08/10] hashserv: server: Use streaming and queue API for upstream exist queries Joshua Watt
2026-07-30 18:31   ` [bitbake-devel][PATCH v2 09/10] hashserv: tests: Add more upstream tests Joshua Watt
2026-07-30 18:31   ` [bitbake-devel][PATCH v2 10/10] hashserv: tests: Add test for upstream pipelining Joshua Watt
2026-07-31 13:05   ` [PATCH v2 00/10] hashserv: Pipeline Upstream Queries Michal Sieron
2026-08-26 20:05     ` [bitbake-devel] " Joshua Watt
2026-08-26 22:48       ` Michal Sieron [this message]
2026-08-27 18:57         ` Joshua Watt
2026-08-28 15:58   ` [bitbake-devel][PATCH v3 00/11] " Joshua Watt
2026-08-28 15:58     ` [bitbake-devel][PATCH v3 01/11] asyncrpc: Add Task Group Joshua Watt
2026-08-28 15:58     ` [bitbake-devel][PATCH v3 02/11] asyncrpc: serv: Use " Joshua Watt
2026-08-28 15:58     ` [bitbake-devel][PATCH v3 03/11] asyncrpc: serv: Cancel all clients on server stop Joshua Watt
2026-08-28 15:58     ` [bitbake-devel][PATCH v3 04/11] hashserv: tests: Improve test logging Joshua Watt
2026-08-28 15:58     ` [bitbake-devel][PATCH v3 05/11] hashserv: client: Add asynchronous streaming API Joshua Watt
2026-08-28 15:58     ` [bitbake-devel][PATCH v3 06/11] hashserv: server: Add queued " Joshua Watt
2026-08-28 15:58     ` [bitbake-devel][PATCH v3 07/11] hashserv: server: Use streaming and queue API for upstream unihash queries Joshua Watt
2026-08-28 15:58     ` [bitbake-devel][PATCH v3 08/11] hashserv: server: Use streaming and queue API for upstream exist queries Joshua Watt
2026-08-28 15:58     ` [bitbake-devel][PATCH v3 09/11] hashserv: tests: Add more upstream tests Joshua Watt
2026-08-28 15:58     ` [bitbake-devel][PATCH v3 10/11] hashserv: tests: Add test for upstream pipelining Joshua Watt
2026-08-28 15:58     ` [bitbake-devel][PATCH v3 11/11] hashserv: server: Fix upstream get-unihash miss truncating stream Joshua Watt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2326647.1787784484085855892@lists.openembedded.org \
    --to=michalwsieron@gmail.com \
    --cc=bitbake-devel@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.