Changeset: 9f79c6af29bb for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/9f79c6af29bb
Modified Files:
        gdk/gdk_storage.c
Branch: Jul2021
Log Message:

To avoid deadlock, and also unnecessary work, try the lock, don't wait.


diffs (25 lines):

diff --git a/gdk/gdk_storage.c b/gdk/gdk_storage.c
--- a/gdk/gdk_storage.c
+++ b/gdk/gdk_storage.c
@@ -860,10 +860,17 @@ BATsave_locked(BAT *bd)
                        bd->tvheap->wasempty = vhs.wasempty;
                bd->batCopiedtodisk = true;
                DESCclean(bd);
-               MT_rwlock_rdlock(&bd->thashlock);
-               if (bd->thash && bd->thash != (Hash *) 1)
-                       BAThashsave(bd, dosync);
-               MT_rwlock_rdunlock(&bd->thashlock);
+               if (MT_rwlock_rdtry(&bd->thashlock)) {
+                       /* if we can't get the lock, don't bother saving
+                        * the hash (normally, the hash lock should not
+                        * be acquired when the heap lock has already
+                        * been acquired, and here we have the heap
+                        * lock, so we must be careful with the hash
+                        * lock) */
+                       if (bd->thash && bd->thash != (Hash *) 1)
+                               BAThashsave(bd, dosync);
+                       MT_rwlock_rdunlock(&bd->thashlock);
+               }
        }
        return err;
 }
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to