spring-projects / spring-integration-extensions

The Spring Integration Extensions project provides extension components for Spring Integration
http://www.springintegration.org/
280 stars 266 forks source link

Memory leak with org.springframework.integration.hazelcast.leader.LeaderInitiator #235

Closed mleguevel closed 3 years ago

mleguevel commented 3 years ago

Hello,

I think that the hazelcast LeaderInitiator causes a memory leak. The reason for this is that it's calling tryLock twice before calling unlock and continuing with tryLock / unlock.

When doing this, an internal Map in hazelcast keeps growing while the LeaderInitiator keeps calling tryLock and unlock. This Map can be found either in com.hazelcast.cp.internal.datastructures.lock.RaftLock for the version 3.12.9 of hazelcast or in com.hazelcast.cp.internal.datastructures.lock.Lock for the version 4.0.3. I've reproduced the problem with both versions.

I first created an issue in hazelcast repository and their conclusion seems to be that it works as designed.

Can this be considered a bug in LeaderInitiator then?

Thank you.

artembilan commented 3 years ago

Hi, @mleguevel !

I'm not fully sure what is going on, but if you raise a Pull Request with the fix and some test to confirm that there is no problem and everything else works as designed (all other tests passes), I'll accept such a contribution with a great pleasure.

More over it would be great to have a fix since we are heading to release with Hazelcast extension soon enough.

Thank you!

mleguevel commented 3 years ago

Hi @artembilan

I created a PR: https://github.com/spring-projects/spring-integration-extensions/pull/236 I'm not entirely sure that it's totally equivalent to the previous algorithm though. But the LeaderInitiatorTest tests pass. I removed the two additional hazelcast instances from the test class because I assumed that they were added to circumvent the bug that prevented hazelcast from starting in unsafe mode in the 3.12.X versions. Tell me if it's not the reason.