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

RedisTemplate with disabled transaction support can't use multi/exec in readOnly Transaction [DATAREDIS-1007] #1531

Closed
spring-projects-issues opened this issue Jun 30, 2019 · 4 comments
Assignees
Labels
in: core status: invalid

Comments

@spring-projects-issues
Copy link

@spring-projects-issues spring-projects-issues commented Jun 30, 2019

alonWang opened DATAREDIS-1007 and commented

I believe this pr cause this, #214

to solve it,just need to modify here

RedisConnectionUtils.releaseConnection()

// when redis "transactional" & enableTranactionSupport & readOnly,then release connection.
if (isConnectionTransactional(conn, factory)&& enableTranactionSupport && TransactionSynchronizationManager.isCurrentTransactionReadOnly()) {
            unbindConnection(factory);
        } else if (!isConnectionTransactional(conn, factory)) {
            if (log.isDebugEnabled()) {
                log.debug("Closing Redis Connection");
            }
            conn.close();
        }

Affects: 2.2 RC1 (Moore), 1.8.22 (Ingalls SR22), 2.1.9 (Lovelace SR9)

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jun 30, 2019

alonWang commented

 

demo

@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public mixTransaction(){
//... some jpa read operations
//redisTemplate.enableTransactionSupport is default false. using jedis as Redis Connection.
List result=redisTemplate.execute(new SessionCallback<List>() {
				@SuppressWarnings({ "unchecked" })
				@Override
				public List execute(RedisOperations operations)
								throws DataAccessException {
						operations.watch("123");
                                                // .. check operations
						operations.multi()
						//.. some set operations
						return operations.exec()	
				}
}

 

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jun 30, 2019

Mark Paluch commented

We could store that the Template's transaction support was disabled when creating RedisConnectionHolder and evaluate this setting in RedisConnectionUtils.releaseConnection(…)

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jul 19, 2019

alonWang commented

spring-data-redis 2.1.9 have solved this

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jul 19, 2019

Mark Paluch commented

Thanks for checking. Closing this ticket

@spring-projects-issues spring-projects-issues added status: invalid in: core labels Dec 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core status: invalid
Projects
None yet
Development

No branches or pull requests

2 participants