Skip to content

Add spark.redis.client.name and the client.name source option - #419

Merged
alberttwong merged 1 commit into
masterfrom
claude/client-name
Nov 23, 2026
Merged

alberttwong merged 1 commit into
masterfrom
claude/client-name

Conversation

@alberttwong

Copy link
Copy Markdown
Collaborator

Closes #398.

Problem

There's no way to name the connector's connections, so in CLIENT LIST a Spark job's connections can't be told apart from any other client's. Jedis can send CLIENT SETNAME on each new connection, but ConnectionPool never passes it a name.

Change

  • spark.redis.client.name names every connection the connector opens: on the driver and on the executors, and to every node of a cluster. CLIENT LIST then shows it as name=.... Unset or empty (the default) leaves connections unnamed, as before.
  • The client.name DataFrame option overrides it for one source. Like the other connection options, it overrides only its own setting. An empty value leaves that source's connections unnamed.
  • RedisEndpoint gets a clientName field (default null):
    • both SparkConf constructors read it;
    • the nodes RedisConfig discovers (cluster nodes, replicas, a replica's master) inherit it.
  • ConnectionPool passes it to the Jedis factory, which sends CLIENT SETNAME after AUTH and SELECT on each new pooled connection. Pools are keyed by endpoint, so each name gets its own pool. CLIENT SETINFO (library name and version) is still sent.
  • A name Redis would refuse (anything but printable ASCII without spaces) fails on the driver with an IllegalArgumentException that names the setting and the option, before any connection is opened.
  • Docs: doc/configuration.md (the parameter, the override table, and CLIENT SETNAME among the commands the connector sends) and the DataFrame options table.

Tests

  • ClientNameConfigSuite needs no Redis. It covers precedence between the setting and the option, empty values, and validation.
  • ConnectionPoolTest: two cases. A pooled connection to an endpoint with a name carries it in CLIENT LIST, next to the library info. One without a name has none.
  • ClientNameSuite runs on standalone, cluster, and standalone with an ACL user. It runs RDD and DataFrame jobs, then reads CLIENT LIST on every node and checks the name of each connection the job opened:
    • the setting names the RDD API's and a DataFrame source's connections;
    • the option overrides the setting for its source;
    • without a name, or with an empty option, connections stay unnamed.

Locally: JDK 8. CI here runs Redis 6.0.10 on the old fixed ports, so I ran the full suite with this change on top of #417's Testcontainers harness:

Redis Result
redis:7.4 318 passed, 0 failed
redis:8.6 318 passed, 0 failed

That's upstream's 295 tests plus the 23 new ones, with scalatest-maven-plugin 2.2.0 from the plugin PR. This PR doesn't depend on either: CI here runs it on Redis 6.0.10, where CLIENT SETNAME and CLIENT ID exist, and ConnectionPoolTest checks the library info only where CLIENT SETINFO set it (Redis 7.2+).

🤖 Generated with Claude Code

Every connection the connector opens can now carry a client name, as
CLIENT LIST shows (name=...). Set spark.redis.client.name for the whole
job; a DataFrame source's client.name option overrides it for that
source. Without the setting, or with an empty value, connections stay
unnamed as before.

- RedisEndpoint gets a clientName field (default null). The SparkConf and
  SparkConf + parameters constructors read it, and the nodes RedisConfig
  discovers (cluster nodes, replicas, a replica's master) inherit it.
- ConnectionPool passes it to JedisFactory, so Jedis sends CLIENT SETNAME
  after AUTH and SELECT on each new pooled connection. Pools are keyed by
  endpoint, so each name gets its own pool.
- A name Redis would refuse (anything but printable ASCII without spaces)
  fails on the driver with an IllegalArgumentException that names the
  setting and option, before any connection is opened.

Tests: ClientNameConfigSuite (precedence, empty, validation; no server),
two ConnectionPoolTest cases, and ClientNameSuite on standalone, cluster
and standalone ACL. Those run RDD and DataFrame jobs, then read CLIENT
LIST on every node and check each connection the job opened. Docs:
doc/configuration.md and the DataFrame options table.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

i cannot define clientName in configuration

1 participant