From f68b40e9cf79f0ef54ad4f1d63f3d5f640509b3b Mon Sep 17 00:00:00 2001 From: d-robotics Date: Sun, 15 Nov 2026 01:38:45 -0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=AA=20Bind=20replica=20fault=20injecti?= =?UTF-8?q?on=20to=20application=20queries?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/store/query_replica_projection_local_test.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/internal/store/query_replica_projection_local_test.go b/internal/store/query_replica_projection_local_test.go index 37e21981..5baccdab 100644 --- a/internal/store/query_replica_projection_local_test.go +++ b/internal/store/query_replica_projection_local_test.go @@ -1,6 +1,7 @@ package store import ( + "bytes" "context" "errors" "fmt" @@ -172,11 +173,13 @@ type replicaFaultConn struct { armed *atomic.Bool } -func (c *replicaFaultConn) Read(b []byte) (int, error) { - if c.armed.CompareAndSwap(true, false) { +// Inject only on an application find wire message. A shared read switch can +// be consumed by the driver heartbeat connection before the application read. +func (c *replicaFaultConn) Write(b []byte) (int, error) { + if bytes.Contains(b, []byte("\x02find\x00")) && c.armed.CompareAndSwap(true, false) { return 0, context.DeadlineExceeded } - return c.Conn.Read(b) + return c.Conn.Write(b) } func TestQueryReplicaLargeResponseShrinksWithinFixedDeadlineLocal(t *testing.T) {