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

Issue with Redisson's LocalCachedMap behavior within a transaction #5809

Open
RajaJaisankar opened this issue Apr 22, 2024 · 1 comment
Open

Comments

@RajaJaisankar
Copy link
Contributor

Expected behavior

After committing the transaction, the value for the key should be updated in the original RLocalCachedMap instance.

Actual behavior

The value for the key in the original RLocalCachedMap instance remains unchanged after committing the transaction.

Steps to reproduce or test case

RedissonClient redissonClient = createRedissonClient();
RLocalCachedMap<Object, Object> localCachedMap = redissonClient.getLocalCachedMap(LocalCachedMapOptions.name("Test")
						.codec(StringCodec.INSTANCE).cacheSize(2000)
						.evictionPolicy(LocalCachedMapOptions.EvictionPolicy.LRU)
                                                .timeToLive(Duration.ofHours(1))
						.syncStrategy(LocalCachedMapOptions.SyncStrategy.UPDATE));
localCachedMap.put("1", "1");
RTransaction transaction = redissonClient.createTransaction(
				TransactionOptions.defaults());
RLocalCachedMap<Object, Object> transactionLocalCachedMap = transaction.getLocalCachedMap(
				localCachedMap);
transactionLocalCachedMap.put("1", "2");
transaction.commit();
System.out.println(localCachedMap.get("1")); //prints 1

Redis version
7.2.4
Redisson version
3.29.0
Redisson configuration

config.setThreads(Integer.parseInt("100"))
	.setNettyThreads(Integer.parseInt("100"))
	.setUseThreadClassLoader(false).setUseScriptCache(true)
	.useClusterServers().addNodeAddress(redisClusterUrls.split(","))
	.setReadMode(ReadMode.MASTER_SLAVE)
	.setTimeout(Integer.parseInt("5") * 60 * 1000)
	.setConnectTimeout(Integer.parseInt("5") * 60 * 1000)
	.setRetryInterval(5000).setRetryAttempts(6)
	.setSubscriptionsPerConnection(Integer.parseInt("100"))
	.setSubscriptionConnectionPoolSize(Integer.parseInt("1000"))
	.setMasterConnectionPoolSize(Integer.parseInt("1000"))
	.setSlaveConnectionPoolSize(Integer.parseInt("1000"));
@RajaJaisankar
Copy link
Contributor Author

Let me know if this is expected behavior or not, right now i am clearing localcache after every transaction commit, this method works as of now.

public void removeTransaction() {
		transactionThreadLocal.remove();
		if (null != redisCacheNamesThreadLocal.get()) {
			for (String cacheName : redisCacheNamesThreadLocal.get()) {
				RLocalCachedMap<Object, Object> cacheMap = getLocalCacheMap(
						cacheName);
				cacheMap.clearLocalCache();
				LOCAL_CACHE_MAP.remove(cacheName);
			}
			redisCacheNamesThreadLocal.remove();
		}
	}

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

No branches or pull requests

1 participant