Remember once jedis concurrent use of JedisException: Could not return the resource to the pool

Today, the line suddenly found a strange question when the project first started redis error JedisException: Could not return the resource to the pool

Direct access interface when not being given the time to visit this page of the newspaper was wrong. And only restart when the project will be reported this wrong, first I thought the interface problem, carefully analyze the original page is loaded this page while a good number of these interfaces are called a method. And this method just rely redis. The line write their own multi-threaded access


Problem occurred


getString method



getPool method


The question is this getPool not thread safe, then used a global

So multiple threads each thread gets the pool is not the same then run out jedis link back to the pool is not the same cause problems.

Find problem solving very simple and direct in getPool by double checking locks can be resolved,

Configuration information may be loaded or static block of code.


Published 55 original articles · won praise 31 · views 80000 +

Guess you like

Origin blog.csdn.net/zengfanwei1990/article/details/80885988