RedisClusterClient use transactions with multi and exec and discard not work
See original GitHub issuehi I get a RedisClusterAsyncConnection with RedisClusterClient.connectClusterAsync() method. but the transactions not work. code is below.
List<RedisURI> initialUris = new ArrayList<RedisURI>();
initialUris.add(RedisURI.Builder.redis("192.168.2.120", 7000).build());
initialUris.add(RedisURI.Builder.redis("192.168.2.120", 7001).build());
initialUris.add(RedisURI.Builder.redis("192.168.2.120", 7002).build());
initialUris.add(RedisURI.Builder.redis("192.168.2.120", 7004).build());
RedisClusterClient rcc = new RedisClusterClient(initialUris);
RedisClusterAsyncConnection<String, String> conn = rcc.connectClusterAsync();
try {
if( conn.multi().get().equals("OK") ){
conn.set("city.name", "beijing");
System.out.println( 1 / 0);
conn.exec().get();
}
} catch (Exception e) {
conn.discard().get()
}
the code will occur exception, conn.exec().get()
not run, conn.discard().get()
is run. but the transaction commited. why?
please help me!1
Issue Analytics
- State:
- Created 8 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
RedisClusterClient (Lettuce 6.2.2.RELEASE API)
You should not use transactional commands on cluster connections since MULTI , EXEC and DISCARD have no key and cannot be assigned to...
Read more >Spring Data Redis - watch and multi on same cluster node
My objective is to apply transaction logic (watch+multi) to a ... repo that transactions on clusters are not supported on spring data redis....
Read more >Module eredis_cluster - HexDocs
The eredis_cluster application is a Redis Cluster client. ... Function to execute a pipeline of commands as a transaction command, by wrapping it...
Read more >Introduction to Lettuce - the Java Redis Client - Baeldung
The call to multi starts the transaction. When a transaction is started, the subsequent commands are not executed until exec() is called. In ......
Read more >Transactions | Redis
How transactions work in Redis. ... of a group of commands in a single step, they are centered around the commands MULTI ,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
There’s no multi support from a top-level cluster connection perspective because there are no distributed transactions in Redis. If you want to use transactions, then obtain a node-specific connection to the node that holds the keys you want to touch within the transaction (
StatefulRedisClusterConnection .getConnection(…)
).Please use StackOverflow or the mailing list if you have further questions.
The getConnection API was deprecated in Lettuce 4.
I am not sure how to perform multi() on clustered connection using Lettuce too.
Anyone can help?