store icon indicating copy to clipboard operation
store copied to clipboard

there is potential deadLock for lock order is different for PersistenceManager$Default.store and BinaryStorer$Default.storeAll

Open useryq8 opened this issue 8 months ago • 3 comments

Environment Details

  • EclipseStore Version: 1.2.0
  • JDK version: OpenJDK Runtime Environment Zulu21.32+17-CA (build 21.0.2+13-LTS)
  • OS:
  • os.arch=amd64 os.name=Linux os.version=3.10.0-1160.105.1.el7.x86_64
  • Used frameworks: Spingboot 3.2.2

Describe the bug

We write ourself Map class to store object to eclipse. it is running multi-thread, but it block for deadlock, I get the jstack ,it has dead-lock for PersistenceManager$Default.store and BinaryStorer$Default.storeAll has different lock order.

at org.eclipse.serializer.persistence.types.PersistenceManager$Default.store(PersistenceManager.java:2998) at org.eclipse.serializer.persistence.binary.types.BinaryStorer$Default.storeAll(BinaryStorer.java:460)

you can see the screenshot

To Reproduce

for the same Persister, to store object by PersistenceManager$Default.store and .BinaryStorer$Default.storeAll in mulit-thread

Expected behavior

PersistenceManager$Default.store and BinaryStorer$Default.storeAll has the same lock order, then there is no deadlock happen

Screenshots

Image

Additional context

Add any other context about the problem here.

useryq8 avatar May 16 '25 12:05 useryq8

Many thanks for your bug report.

Is it possible that you update to version 2.0.0 or later? There are some changes done to the BinaryStorer with https://github.com/eclipse-serializer/serializer/pull/143].

I was not yet able to reproduce the deadlock. Please let me know if it occurs with version 2 or later again.

hg-ms avatar May 19 '25 12:05 hg-ms

~~Issue has been confirmed to exist still in version 2.1.3, see #414~~

issue #414 is not exactly the same, see traces

hg-ms avatar Jun 24 '25 04:06 hg-ms

Hi, I have another potential cause of the deadlock. Do you call an of the “Store” methods from within another storer that has already acquired a lock? If so, this would explain why you get the deadlock. You must never do that! If you want to persist a referenced object from within a TypeHandler always use one of the apply methods from a PersistenceStoreHandler.

hg-ms avatar Jun 25 '25 04:06 hg-ms