Skip to content

redis: stop configuring notifications on client connect - #1257

Merged
qiluo-msft merged 1 commit into
sonic-net:masterfrom
ashutosh-agrawal:redis-server-owned-notifications
Oct 7, 2026
Merged

qiluo-msft merged 1 commit into
sonic-net:masterfrom
ashutosh-agrawal:redis-server-owned-notifications

Conversation

@ashutosh-agrawal

Copy link
Copy Markdown
Member

Why

DBInterface currently sends CONFIG SET notify-keyspace-events KEA when it creates its first connection to a database. Keyspace notification selection is a server-wide setting, so configuring it from each client duplicates Redis startup configuration and makes connection creation change global server state.

This behavior dates back to the original Python SDK. At that time, the SDK enabled notifications itself so its blocking reads could wait for missing data. The C++ implementation added in sonic-swss-common PR #387 retained that behavior for compatibility.

SONiC later found that client-owned setup was unreliable for chassis databases because a Redis process could need to publish events before any local DBInterface connection existed. sonic-buildimage PR #12540 moved the setting into redis.conf, where it is applied when each Redis process starts. The connection-time write is now redundant.

What changed

  • Stop sending CONFIG SET from DBInterface::_onetime_connect().
  • Document that keyspace notifications are provided by Redis server configuration.
  • Add a regression test that verifies connecting does not issue CONFIG SET.
  • Support both the older Redis command-statistics name and the Redis 7+ subcommand name in the test.

Compatibility

SONiC Redis images already enable notify-keyspace-events AKE at startup:

  • dockers/docker-database/Dockerfile.common.j2, shared by the database image and docker-sonic-vs
  • the VPP, Alpine VS, and P4 Redis images

The sonic-swss-common development and CI setup also enables AKE before running Redis-dependent tests. The repository README already documents this Redis server requirement for standalone development.

Validation

  • Built the Trixie Debian packages successfully.
  • Verified the regression test fails against the previous behavior because the CONFIG call count changes from 0 to 1.
  • Verified the patched regression test passes without a CONFIG write.
  • Ran the existing test_DBInterface Python test, including pub/sub keyspace notifications and a blocking read; it passed.

SONiC Redis images already enable keyspace notifications in redis.conf. Keep that server-wide setting under server startup control so read-only clients do not need CONFIG write permission.

Add a regression test that detects CONFIG SET on both older Redis releases and releases that report subcommand statistics separately.

Signed-off-by: Ashutosh Agrawal <ashu@cisco.com>
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@ashutosh-agrawal

Copy link
Copy Markdown
Member Author

/azpw retry

@mssonicbld

Copy link
Copy Markdown
Collaborator

Retrying failed(or canceled) jobs...

@mssonicbld

Copy link
Copy Markdown
Collaborator

Retrying failed(or canceled) stages in build 1240364:

✅Stage Test:

  • Job vstest: retried.

@qiluo-msft
qiluo-msft merged commit f3aa11c into sonic-net:master Oct 7, 2026
20 checks passed
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.

3 participants