Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Caused by: org.springframework.dao.InvalidDataAccessApiUsageException: Scan is not supported across multiple nodes within a cluster #2694

Closed
zzy444626905 opened this issue Aug 29, 2023 · 2 comments
Labels
status: invalid An issue that we don't feel is valid

Comments

@zzy444626905
Copy link

env

win10 + jdk1.8 + redis 5.0.5 cluster

maven

<dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-redis</artifactId>
    <version>2.3.3.RELEASE</version>
</dependency>

<dependency>
    <groupId>redis.clients</groupId>
    <artifactId>jedis</artifactId>
    <version>3.9.0</version>
</dependency>

code

AtomicLong count = new AtomicLong();
redisTemplate.execute((RedisCallback<Set<String>>) connection -> {
    Cursor<byte[]> cursor = connection.scan(new ScanOptions.ScanOptionsBuilder()
            .match("*").count(10 * 10000).build());
    while (cursor.hasNext()) {
        byte[] next = cursor.next();
        count.incrementAndGet();
        if (count.get() % 100 == 0) {
            System.out.printf("%s=======================%s\n",new String(next),count.get());
        }
    }
    return null;
});

console output:

C:\Users\Administrator\Desktop>java -jar jar-exe-1.0-SNAPSHOT.jar
[INFO ] [2023-08-29 17:03:14.587] [main] [org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor] [181]
[Initializing ExecutorService]

Exception in thread "main" java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:109)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
        at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88)
Caused by: org.springframework.dao.InvalidDataAccessApiUsageException: Scan is not supported across multiple nodes within a cluster
        at org.springframework.data.redis.connection.jedis.JedisClusterKeyCommands.scan(JedisClusterKeyCommands.java:173)
        at org.springframework.data.redis.connection.DefaultedRedisConnection.scan(DefaultedRedisConnection.java:117)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.springframework.data.redis.core.CloseSuppressingInvocationHandler.invoke(CloseSuppressingInvocationHandler.java:61)
        at com.sun.proxy.$Proxy6.scan(Unknown Source)
        at com.zzy.redis_tool.RedisTool.lambda$main$0(RedisTool.java:47)
        at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:228)
        at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:188)
        at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:175)
        at com.zzy.redis_tool.RedisTool.main(RedisTool.java:46)
        ... 8 more
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 29, 2023
@zzy444626905
Copy link
Author

Ha ha, I'll sit and wait for reply of the big boss who named Mark Paluch.

@mp911de
Copy link
Member

mp911de commented Aug 29, 2023

Spring Data Redis 2.3 is no longer supported. Please upgrade to 2.7. Please use the Lettuce driver to scan across a cluster, there's no support for Jedis Cluster Scans.

@mp911de mp911de closed this as not planned Won't fix, can't repro, duplicate, stale Aug 29, 2023
@mp911de mp911de added status: invalid An issue that we don't feel is valid and removed status: waiting-for-triage An issue we've not yet triaged labels Aug 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

3 participants