Discussion:
Possible thread lockup due to AcidPtr?
Walt Karas
2018-09-15 01:23:46 UTC
Permalink
It looks to me like the AcidPtr docs need a prominent waring that a
thread should have two instances of these (or AcidCommitPtr) in
existence at the same time. If the addresses of the two protected
objects hashed to the same mutex, wouldn't it cause the thread to lock
up (due to trying to lock the same mutex twice)? If this did happen,
it would be very hard to debug.
Aaron Canary
2018-09-17 18:36:07 UTC
Permalink
yes. I had considered using a recursive mutex to handle this case. I chose
not to support it because locking multiple things and write to them at
the same time is against the spirit of ACID style databases.

I suppose I could add an assert when a lock is waiting on a mutex owned by
the same thread.
Post by Walt Karas
It looks to me like the AcidPtr docs need a prominent waring that a
thread should have two instances of these (or AcidCommitPtr) in
existence at the same time. If the addresses of the two protected
objects hashed to the same mutex, wouldn't it cause the thread to lock
up (due to trying to lock the same mutex twice)? If this did happen,
it would be very hard to debug.
--
Aaron Canary
ATS - Senior Software Engineer
Walt Karas
2018-09-17 18:51:11 UTC
Permalink
The assert would be good but I think the docs need a warning that two
AcidPtr instances or two AcidCommitPtr instances should not exist at
the same time in the same thread.
Post by Aaron Canary
yes. I had considered using a recursive mutex to handle this case. I chose
not to support it because locking multiple things and write to them at
the same time is against the spirit of ACID style databases.
I suppose I could add an assert when a lock is waiting on a mutex owned by
the same thread.
Post by Walt Karas
It looks to me like the AcidPtr docs need a prominent waring that a
thread should have two instances of these (or AcidCommitPtr) in
existence at the same time. If the addresses of the two protected
objects hashed to the same mutex, wouldn't it cause the thread to lock
up (due to trying to lock the same mutex twice)? If this did happen,
it would be very hard to debug.
--
Aaron Canary
ATS - Senior Software Engineer
Derek Dagit
2018-09-17 19:58:57 UTC
Permalink
Post by Walt Karas
The assert would be good but I think the docs need a warning that two
AcidPtr instances or two AcidCommitPtr instances should not exist at the
same time in the same thread.

+1 for clarification
Post by Walt Karas
The assert would be good but I think the docs need a warning that two
AcidPtr instances or two AcidCommitPtr instances should not exist at
the same time in the same thread.
Post by Aaron Canary
yes. I had considered using a recursive mutex to handle this case. I
chose
Post by Aaron Canary
not to support it because locking multiple things and write to them at
the same time is against the spirit of ACID style databases.
I suppose I could add an assert when a lock is waiting on a mutex owned
by
Post by Aaron Canary
the same thread.
Post by Walt Karas
It looks to me like the AcidPtr docs need a prominent waring that a
thread should have two instances of these (or AcidCommitPtr) in
existence at the same time. If the addresses of the two protected
objects hashed to the same mutex, wouldn't it cause the thread to lock
up (due to trying to lock the same mutex twice)? If this did happen,
it would be very hard to debug.
--
Aaron Canary
ATS - Senior Software Engineer
--
Derek
Loading...