From: Joshua Watt <jpewhacker@gmail.com>
To: bitbake-devel@lists.openembedded.org
Cc: Michal Sieron <michal.sieron@nokia.com>,
Joshua Watt <JPEWhacker@gmail.com>
Subject: [bitbake-devel][PATCH v3 11/11] hashserv: server: Fix upstream get-unihash miss truncating stream
Date: Fri, 28 Aug 2026 09:58:18 -0600 [thread overview]
Message-ID: <20260828155942.1219468-12-JPEWhacker@gmail.com> (raw)
In-Reply-To: <20260828155942.1219468-1-JPEWhacker@gmail.com>
From: Michal Sieron <michal.sieron@nokia.com>
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.
AI-Generated: Uses Cursor
Signed-off-by: Michal Sieron <michal.sieron@nokia.com>
Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
---
lib/hashserv/server.py | 20 ++++++++++++++++++--
lib/hashserv/tests.py | 37 +++++++++++++++++++++++++++++++++++++
2 files changed, 55 insertions(+), 2 deletions(-)
diff --git a/lib/hashserv/server.py b/lib/hashserv/server.py
index 0153730fa..d9c30bdb8 100644
--- a/lib/hashserv/server.py
+++ b/lib/hashserv/server.py
@@ -232,7 +232,15 @@ def permissions(*permissions, allow_anon=True, allow_self_service=False):
class UpstreamQueue(object):
UPSTREAM_NONCE = object()
- def __init__(self, queue, get_local_result, send_upstream, get_upstream_result):
+ def __init__(
+ self,
+ logger,
+ queue,
+ get_local_result,
+ send_upstream,
+ get_upstream_result,
+ ):
+ self.logger = logger
self.queue = queue
self.pending = []
self.cond = asyncio.Condition()
@@ -256,6 +264,12 @@ class UpstreamQueue(object):
if value is self.UPSTREAM_NONCE:
value = await self.get_upstream_result(m)
+ if value is None:
+ self.logger.error(
+ "None is not allowed as a stream value. Terminating stream"
+ )
+ return
+
await self.queue.put(value)
finally:
await self.queue.put(None)
@@ -504,10 +518,11 @@ class ServerClient(bb.asyncrpc.AsyncServerConnection):
if unihash:
method, taskhash = m.split()
await self.server.backfill_queue.put((method, taskhash))
- return unihash
+ return unihash or ""
queue = asyncio.Queue()
upstream = UpstreamQueue(
+ self.logger,
queue,
get_local_result,
send_upstream,
@@ -543,6 +558,7 @@ class ServerClient(bb.asyncrpc.AsyncServerConnection):
queue = asyncio.Queue()
upstream = UpstreamQueue(
+ self.logger,
queue,
get_local_result,
stream.send_query,
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))
--
2.55.0
prev parent reply other threads:[~2026-08-28 15:59 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
2026-08-27 18:57 ` [bitbake-devel] " 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 ` Joshua Watt [this message]
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=20260828155942.1219468-12-JPEWhacker@gmail.com \
--to=jpewhacker@gmail.com \
--cc=bitbake-devel@lists.openembedded.org \
--cc=michal.sieron@nokia.com \
/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.