Skip to content

Conversation

JeremyXin
Copy link
Contributor

@JeremyXin JeremyXin commented Sep 16, 2025

Purpose of this pull request

fix: #9865

The main job of pr:

  1. Fixed the bug of ReidsClusterClient, where RedisDataType.SET.set passes in the created jedis object instead of this to fix [Bug] [connector-redis] redis cluster mode to write set data error #9865
  2. 'RedisSourceReader' supports cluster mode scan, and the 'ReidsClusterClient' class implements the 'scanKeyResult' method in cluster mode
  3. Support the format of TEXT
  4. Add redis cluster e2e testing

Does this PR introduce any user-facing change?

How was this patch tested?

Check list

}
}
```
Copy link
Member

@zhangshenghang zhangshenghang Sep 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a question. Text format has been applied to Redis here. However, it is still not supported in HTTP. Do we need to modify the HTTP connector separately in the future? @Hisoka-X

https://github.com/apache/seatunnel/blob/02c7eb3177989bcd50ba6c1059862c1586d3fa39/docs/en/connector-v2/source/Http.md?plain=1#L176C1-L177C1

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we can do the same thing in HTTP. LocalFile already did this.

Comment on lines 111 to 113
protected String getCustomKey(SeaTunnelRow element, List<String> fields, String keyField) {
Matcher matcher = PLACEHOLDER_PATTERN.matcher(keyField);
StringBuffer result = new StringBuffer();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's reuse PlaceholderUtils

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, also the placeholder representation in the original configuration needs to be changed, from :{placeholder} to :${placeholder}

List<String> resultKeys;
String nextCursor;

try (Jedis jedis = new Jedis(pool.getResource())) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we cache Jedis client to save CPU cost?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, replace the scanKeyResult method in the cluster mode with directly using the jedisCluster.scan method

for (Map.Entry<String, ConnectionPool> entry : nodes.entrySet()) {
ConnectionPool pool = entry.getValue();
try {
try (Jedis jedis = new Jedis(pool.getResource())) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

}

@Override
public String info() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain why this method can fix #9865 ?

Copy link
Contributor Author

@JeremyXin JeremyXin Sep 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It turns out that when writing to set type data, the batchWriteSet method of RedisClusterClient class:RedisDataType'.SET.set(this,...) . The passed jedis object is this, but this jedis object actually did not initialize the Connection connection, which led to the error #9865. The actual jedis object that should be used is the Jedis object passed in from the constructor.

The info method rewritten in JedisWrapper is designed to support querying redis version information in cluster mode. The JedisWrapper class inherits from the Jedis class, but does not initialize the Connection object of the parent class. Therefore, the execution of all Jedis-related methods should go through JedisCluster. Instead of executing the methods in the parent class Jedis (all of which will result in execution errors due to the Connection not being initialized).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] [connector-redis] redis cluster mode to write set data error
3 participants