Mark transactions (multi) for coroutine as deprecated
Bug Report
Current Behavior
Based on this connection pool : BoundedAsyncPool<StatefulRedisConnection<ByteArray, ByteArray>>
If we got a connection, use sync() method and multi to make transaction, the transaction is performed as expected
val pool: BoundedAsyncPool<StatefulRedisConnection<ByteArray, ByteArray>> = ...
val connection: StatefulRedisConnection<ByteArray, ByteArray> = pool.acquire().await()
val result = connection.sync().multi {
get(key1)
get(key2)
sismember(key3, "test".encodeToByteArray())
}
println("Executed multi: $result ") // executed
println("Result 0: ${result.get<ByteArray>(0)}") // executed
The prints display information as expected and the transaction is executed.
However, if we're using the coroutine, the transaction will just block and never be performed
val pool: BoundedAsyncPool<StatefulRedisConnection<ByteArray, ByteArray>> = ...
val connection: RedisCoroutinesCommands<ByteArray, ByteArray> = pool.acquire().await().coroutines()
val result = connection.multi {
get(key1)
get(key2)
sismember(key3, "test".encodeToByteArray())
}
println("Executed multi: $result ") // never executed
println("Result 0: ${result.get<ByteArray>(0)}") // never executed
Stack trace
Nothing thrown.
Input Code
Expected behavior/code
The transaction should be executed using coroutine extension
Environment
- Lettuce version(s): [6.2.3.RELEASE]
- Redis version: [7.0.8]
- Kotlin: [1.8.0]
- Coroutine: [1.6.4]
Possible Solution
Additional context
Looks like a duplicate of #1954.
We deprecated the multi extension because of that reason as Redis' transaction do not work well with an async API.
Ok thanks ! And sorry for the duplicate
So for the moment, we can't use transaction. I will just make several requests in this case while waiting for a possible fix.
while waiting for a possible fix.
No fix is possible as transactional commands only complete after running EXEC.
@mp911de, io.lettuce.core.api.coroutines.RedisCoroutinesCommands.multi is not marked as deprecated in 6.2.4.RELEASE
Ah I see it is marked as deprecated in the javadoc. But it doesn't have the @Deprecated annotation, so it doesn't produce any warnings. Can a @Depreacted annotation be added to prevent users from accidentally using this?
Yes, sorry for the inconvenience. Let me reopen the ticket so we add proper deprecation annotations.