-
Hi, I rediscovered an issue today which causes some problems with tests where we do logging assertions (yeah, I know it's not super-great). Here is our Lettuce-related shutdown code: private void destroyRedisClient( RedisClient redisClient, @Nullable StatefulRedisConnection<String, byte[]> redisConnection ) {
if ( redisConnection != null && redisConnection.isOpen() ) {
try {
redisConnection.close();
}
catch ( Exception e ) {
logger.warn( "Error closing Redis connection", e );
}
}
if ( redisClient.getResources() != null ) {
try {
redisClient.getResources().shutdown().await();
}
catch ( Exception ignored ) {
// ignore
}
}
try {
redisClient.shutdown();
}
catch ( Exception ignored ) {
// ignore
}
} What puzzles me is that even after the above has executed (which should be fully synchronous & blocking if I understand things right), the
Hmm. Maybe I'm getting it now. We're seeing this logging because when the resources are being shutdown, some logging is emitted because of reconnection attempts happening before the resources have yet shutdown? WDYT of this theory @mp911de, could this be what's happening? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
The order in which resources are shut down is wrong. |
Beta Was this translation helpful? Give feedback.
-
Blargh, please disregard the above. The problem I was seeing was actually
Thanks, this might be the root cause for all my headache in fact. 🙇 Will test this approach right away and see if it helps. |
Beta Was this translation helpful? Give feedback.
The order in which resources are shut down is wrong.
ClientResources
must be disposed last because it contains the worker thread pools. Stopping threads before closing the connection/client leads to strange effects and is wrong API usage.