Closed anha1 closed 1 year ago
We're seeing this, too, and my diagnosis (before I found this bug) was the same. https://stackoverflow.com/questions/4612492/static-initializer-and-static-synchronized-method-locking-issue I think talks a little bit about the locks there (in the second edit to the accepted answer) - even though one of the threads is runnable, it can't make progress because of the internal lock you mentioned.
V1 is no longer maintained. V2 bypasses this kind of issue by avoiding the use of statics.
Affected version: archaius-core v0.7.6
Minimal example to reproduce the issue:
In ~50% of runs, the application hangs, output:
Thread dump:
If uncommenting "Thread.sleep(1000)", everything works as expected:
This deadlock is taken from a real-world Spring Boot 2 application with a casual Zipkin setup, here are thread dumps from this Spring Boot 2 + Zipkin application (but the issue looks exactly the same as in the minimal example provided):
My assumption is that the issue is caused by classic deadlock conditions - two locks are acquired in different order by two threads. Obviously, the first lock is
synchronized (ConfigurationManager.class)
. And the second lock is an internal lock associated with the static initializer of ConfigurationManager.