🧪 Bind replica fault injection to application queries
Some checks are pending
web-ci / checks (push) Waiting to run
web-ci / pool-search-mongo (push) Waiting to run
web-ci / work-availability (push) Blocked by required conditions
web-ci / query-serving (push) Blocked by required conditions

This commit is contained in:
d-robotics 2026-11-15 01:38:45 -08:00
parent 7624987768
commit f68b40e9cf

View File

@ -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) {