Skip to content

Reduce implementation complexity - #270

Merged
ghostdogpr merged 6 commits into
mainfrom
reduce_complexity
Oct 4, 2026
Merged

ghostdogpr merged 6 commits into
mainfrom
reduce_complexity

Conversation

@ghostdogpr

@ghostdogpr ghostdogpr commented Oct 3, 2026 •

Copy link
Copy Markdown
Owner

Reduces the code across the repository by about 4,450 lines while keeping every feature and the binary-compatible public API (MiMa passes).

Each module went through repeated review rounds until they stopped finding removals. Every round looked for three things: freedoms the types allow but the code never needs, concerns that are tangled together, and guarantees that depend on discipline rather than types. Every bug found along the way is fixed with a test.

  • sage-core: simpler command definitions, reply decoders, RESP parser and cluster topology handling.
  • sage-client: paging, routing, transaction scopes, transport lifecycle, reconnect scheduling and the subscription model are shared across topologies and backends. This also fixes several connection, subscription and failover bugs (see the commit message).
  • Tests, benchmarks and examples: integration tests use a shorter style (call.is(expected), >> to chain steps, direct test registration, one suite for both Redis and Valkey), and the benchmarks share one workload per client.

User-visible changes

  • A subscription that the server refuses fails with the server's error.
  • cached() rejects blocking commands with NotCacheable.
  • Master-replica connect reports TimedOut when every ROLE probe times out.

Other fixes

  • In sage-compat-ce, CIO.timeout reported a null result as a timeout.
  • Integration test containers now wait until the server answers PING. This fixes an intermittent connection failure in the Ox smoke suite.
  • Tests no longer use fixed sleeps. They poll the server instead.

Restructure the client internals to remove about 1,550 lines while keeping
every feature and the binary-compatible public API. Shared paging, routing,
transaction scopes, transport lifecycle, reconnect scheduling and the
per-name subscription model replace per-topology and per-backend copies.

Fix bugs found along the way, each covered by a test, including:
- interrupt-safe close, connect and handshake cleanup, and a teardown
  deadlock between the socket I/O threads
- subscribe and unsubscribe reply matching, including Valkey error replies
  to SUNSUBSCRIBE, refused names, and pub/sub-only ACL users
- shard and classic subscriptions moving off migrated, removed or demoted
  nodes, with bounded recovery latency
- retries keeping master-only routing, READONLY inside a transaction, and
  span and event attribution for cached and redirected reads

User-visible changes: a subscription the server refuses fails with the
server's error, cached() rejects blocking commands with NotCacheable, and
master-replica connect reports TimedOut when every ROLE probe times out.
@ghostdogpr ghostdogpr changed the title Reduce complexity Reduce implementation complexity Oct 3, 2026
@ghostdogpr
ghostdogpr marked this pull request as ready for review October 3, 2026 14:29
ghostdogpr and others added 3 commits October 3, 2026 23:29
MultiNodeCluster waits until CLUSTER SLOTS lists every replica. Redis lists a
replica only once its replication offset is nonzero, and on an idle master the
offset first moves with the replication PING, sent every 10 seconds by default.
That wait added about 8 seconds to every cluster test. Sending the PING every
second brings RedisClusterFailoverSuite back from about 68 to 38 seconds.
…f TxSupport

The new byte parser behind ValueCodec and KeyCodec rejected "05" and "-0",
which decoded as 5 and 0 before. Existing string data read as Int or Long
decodes the same way again. A leading '+', spaces and non-ASCII digits are
still rejected.

SharedRunner, LiveClient and RoutedClient move from TxSupport.scala to
LiveClient.scala, since they cover all client dispatch, not only transactions.
@ghostdogpr
ghostdogpr merged commit a48cac8 into main Oct 4, 2026
10 checks passed
@ghostdogpr
ghostdogpr deleted the reduce_complexity branch October 4, 2026 00:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant