ocfs2: A race between refmap setting and clearing
Hi all,
We have found a race between refmap setting and clearing which will cause the lock resource on master is freed before other nodes purge it.
Node 1 Node 2(master)dlm_do_master_request
dlm_master_request_handler
-> dlm_lockres_set_refmap_bitcall dlm_purge_lockres after unlock
dlm_deref_handler
-> find lock resource is in
DLM_LOCK_RES_SETREF_INPROG state, so dispatch a deref workdlm_purge_lockres succeed.
dlm_do_master_request
dlm_master_request_handler -> dlm_lockres_set_refmap_bit
deref work trigger, call dlm_lockres_clear_refmap_bit to clear Node 1 from refmap
Now Node 2 can purge the lock resource but the owner of lock resource on Node 1 is still Node 2 which may trigger BUG if the lock resource is $RECOVERY or other problems.
We have discussed 2 solutions:
1)The master return error to Node 1 if the DLM_LOCK_RES_SETREF_INPROG is set. Node 1 will not retry and master send another message to Node 1 after clearing the refmap. Node 1 can purge the lock resource after the refmap on master is cleared.
2) The master return error to Node 1 if the DLM_LOCK_RES_SETREF_INPROG is set, and Node 1 will retry to deref the lockres.
Does anybody has better ideas?
Thanks,
--Jiufei
Hi Jiufei,
Quoted 36 lines · xuejiufei
Hi all,
We have found a race between refmap setting and clearing which will cause the lock resource on master is freed before other nodes purge it.Node 1 Node 2(master)
dlm_do_master_requestdlm_master_request_handler -> dlm_lockres_set_refmap_bitcall
dlm_purge_lockresafter unlock
dlm_deref_handler
-> find lock resource is in
DLM_LOCK_RES_SETREF_INPROGstate, so dispatch a deref workdlm_purge_lockressucceed.
dlm_do_master_request
dlm_master_request_handler->dlm_lockres_set_refmap_bitderef work trigger, call
dlm_lockres_clear_refmap_bitto clear Node 1 from refmapNow Node 2 can purge the lock resource but the owner of lock resource on Node 1 is still Node 2 which may trigger BUG if the lock resource is $RECOVERY or other problems.
We have discussed 2 solutions:
1)The master return error to Node 1 if theDLM_LOCK_RES_SETREF_INPROGis set. Node 1 will not retry and master send another message to Node 1 after clearing the refmap. Node 1 can purge the lock resource after the refmap on master is cleared.
2) The master return error to Node 1 if theDLM_LOCK_RES_SETREF_INPROGis set, and Node 1 will retry to deref the lockres.
Quoted 2 lines
Does anybody has better ideas?
dlm_purge_lockres() will wait to drop ref until DLM_LOCK_RES_SETREF_INPROG cleared. So if set this flag when find the master during doing master request. And then this flag was cleared when receiving assert master message, can this fix the issue?
Thanks,
Junxiao.
Quoted 3 lines
Thanks,
--Jiufei
Hi, Junxiao
Quoted 39 lines · Junxiao Bi
Hi Jiufei,
Quoted 36 lines · xuejiufei
Hi all,
We have found a race between refmap setting and clearing which will cause the lock resource on master is freed before other nodes purge it.Node 1 Node 2(master)
dlm_do_master_requestdlm_master_request_handler -> dlm_lockres_set_refmap_bitcall
dlm_purge_lockresafter unlock
dlm_deref_handler
-> find lock resource is in
DLM_LOCK_RES_SETREF_INPROGstate, so dispatch a deref workdlm_purge_lockressucceed.
dlm_do_master_request
dlm_master_request_handler->dlm_lockres_set_refmap_bitderef work trigger, call
dlm_lockres_clear_refmap_bitto clear Node 1 from refmapNow Node 2 can purge the lock resource but the owner of lock resource on Node 1 is still Node 2 which may trigger BUG if the lock resource is $RECOVERY or other problems.
We have discussed 2 solutions:
1)The master return error to Node 1 if theDLM_LOCK_RES_SETREF_INPROGis set. Node 1 will not retry and master send another message to Node 1 after clearing the refmap. Node 1 can purge the lock resource after the refmap on master is cleared.
2) The master return error to Node 1 if theDLM_LOCK_RES_SETREF_INPROGis set, and Node 1 will retry to deref the lockres.
Quoted 7 lines
Quoted 2 lines
Does anybody has better ideas?
dlm_purge_lockres()will wait to drop ref untilDLM_LOCK_RES_SETREF_INPROGcleared. So if set this flag when find the master during doing master request. And then this flag was cleared when receiving assert master message, can this fix the issue?
I don't think this can fix. Before doing master request, the lock resource is already purged. The master should clear the refmap before client purge it.
Thanks,
Jiufei
Quoted 9 lines
Thanks,
Junxiao.Quoted 3 lines
Thanks,
--Jiufei.
Quoted 44 lines · xuejiufei
Hi, Junxiao
Quoted 41 lines · Junxiao Bi
Hi Jiufei,
Quoted 38 lines · xuejiufei
Hi all,
We have found a race between refmap setting and clearing which will cause the lock resource on master is freed before other nodes purge it.Node 1 Node 2(master)
dlm_do_master_requestdlm_master_request_handler -> dlm_lockres_set_refmap_bitcall
dlm_purge_lockresafter unlock
dlm_deref_handler
-> find lock resource is in
DLM_LOCK_RES_SETREF_INPROGstate, so dispatch a deref workdlm_purge_lockressucceed.
dlm_do_master_request
dlm_master_request_handler->dlm_lockres_set_refmap_bitderef work trigger, call
dlm_lockres_clear_refmap_bitto clear Node 1 from refmapNow Node 2 can purge the lock resource but the owner of lock resource on Node 1 is still Node 2 which may trigger BUG if the lock resource is $RECOVERY or other problems.
We have discussed 2 solutions:
1)The master return error to Node 1 if theDLM_LOCK_RES_SETREF_INPROGis set. Node 1 will not retry and master send another message to Node 1 after clearing the refmap. Node 1 can purge the lock resource after the refmap on master is cleared.
2) The master return error to Node 1 if theDLM_LOCK_RES_SETREF_INPROGis set, and Node 1 will retry to deref the lockres.Does anybody has better ideas?
Quoted 7 lines
Quoted 5 lines
dlm_purge_lockres()will wait to drop ref untilDLM_LOCK_RES_SETREF_INPROGcleared. So if set this flag when find the master during doing master request. And then this flag was cleared when receiving assert master message, can this fix the issue?I don't think this can fix. Before doing master request, the lock resource is already purged. The master should clear the refmap before client purge it.
inflight_locks is increased in dlm_get_lock_resource() which will stop lockres purged? Set DLM_LOCK_RES_SETREF_INPROG when found lockres owner during master request, then this will stop lockres purged after unlock?
Thanks,
Junxiao.
Quoted 14 lines
Thanks,
JiufeiQuoted 9 lines
Thanks,
Junxiao.Quoted 3 lines
Thanks,
--Jiufei.
Hi Junxiao,
I have not describe the issue clearly.
Node 1 Node 2(master)
dlmlockdlm_do_master_request
dlm_master_request_handler
-> dlm_lockres_set_refmap_bitdlmlock succeed
dlmunlock succeed
dlm_purge_lockres
dlm_deref_handler
-> find lock resource is in
DLM_LOCK_RES_SETREF_INPROG state, so dispatch a deref workdlm_purge_lockres succeed.
call dlmlock againdlm_do_master_request
dlm_master_request_handler -> dlm_lockres_set_refmap_bit
deref work trigger, call dlm_lockres_clear_refmap_bit to clear Node 1 from refmap
dlm_purge_lockres succeed
dlm_send_remote_lock_request
return DLM_IVLOCKID because the lockres is not exist
BUG if the lockres is $RECOVERY
Quoted 77 lines · Junxiao Bi
Quoted 44 lines · xuejiufei
Hi, Junxiao
Quoted 41 lines · Junxiao Bi
Hi Jiufei,
Quoted 38 lines · xuejiufei
Hi all,
We have found a race between refmap setting and clearing which will cause the lock resource on master is freed before other nodes purge it.Node 1 Node 2(master)
dlm_do_master_requestdlm_master_request_handler -> dlm_lockres_set_refmap_bitcall
dlm_purge_lockresafter unlock
dlm_deref_handler
-> find lock resource is in
DLM_LOCK_RES_SETREF_INPROGstate, so dispatch a deref workdlm_purge_lockressucceed.
dlm_do_master_request
dlm_master_request_handler->dlm_lockres_set_refmap_bitderef work trigger, call
dlm_lockres_clear_refmap_bitto clear Node 1 from refmapNow Node 2 can purge the lock resource but the owner of lock resource on Node 1 is still Node 2 which may trigger BUG if the lock resource is $RECOVERY or other problems.
We have discussed 2 solutions:
1)The master return error to Node 1 if theDLM_LOCK_RES_SETREF_INPROGis set. Node 1 will not retry and master send another message to Node 1 after clearing the refmap. Node 1 can purge the lock resource after the refmap on master is cleared.
2) The master return error to Node 1 if theDLM_LOCK_RES_SETREF_INPROGis set, and Node 1 will retry to deref the lockres.Does anybody has better ideas?
Quoted 7 lines
Quoted 5 lines
dlm_purge_lockres()will wait to drop ref untilDLM_LOCK_RES_SETREF_INPROGcleared. So if set this flag when find the master during doing master request. And then this flag was cleared when receiving assert master message, can this fix the issue?I don't think this can fix. Before doing master request, the lock resource is already purged. The master should clear the refmap before client purge it.
inflight_locksis increased indlm_get_lock_resource()which will stop lockres purged? SetDLM_LOCK_RES_SETREF_INPROGwhen found lockres owner during master request, then this will stop lockres purged after unlock?Thanks,
Junxiao.Quoted 14 lines
Thanks,
JiufeiQuoted 9 lines
Thanks,
Junxiao.Quoted 3 lines
Thanks,
--Jiufei.
.
Quoted 27 lines · xuejiufei
Hi Junxiao,
I have not describe the issue clearly.Node 1 Node 2(master)
dlmlockdlm_do_master_requestdlm_master_request_handler -> dlm_lockres_set_refmap_bitdlmlock succeed
dlmunlock succeed
dlm_purge_lockres
dlm_deref_handler
-> find lock resource is in
DLM_LOCK_RES_SETREF_INPROGstate, so dispatch a deref workdlm_purge_lockressucceed.call dlmlock again
dlm_do_master_request
dlm_master_request_handler->dlm_lockres_set_refmap_bitderef work trigger, call
dlm_lockres_clear_refmap_bitto clear Node 1 from refmap
Quoted 5 lines
dlm_purge_lockressucceed
dlm_send_remote_lock_request
returnDLM_IVLOCKIDbecause the lockres is not exist
More clear now. Thank you.
This is a very complicated race. I didn't have a good solution to fix it now. Your fix looks work, but I am afraid if we keep going fix this kinds of races case by case, we will make dlm harder to understand and easy to involve bugs, maybe we should think about refactor dlm.
Thanks,
Junxiao.
Quoted 81 lines
BUG if the lockres is $RECOVERY
Quoted 77 lines · Junxiao Bi
Quoted 44 lines · xuejiufei
Hi, Junxiao
Quoted 41 lines · Junxiao Bi
Hi Jiufei,
Quoted 38 lines · xuejiufei
Hi all,
We have found a race between refmap setting and clearing which will cause the lock resource on master is freed before other nodes purge it.Node 1 Node 2(master)
dlm_do_master_requestdlm_master_request_handler -> dlm_lockres_set_refmap_bitcall
dlm_purge_lockresafter unlock
dlm_deref_handler
-> find lock resource is in
DLM_LOCK_RES_SETREF_INPROGstate, so dispatch a deref workdlm_purge_lockressucceed.
dlm_do_master_request
dlm_master_request_handler->dlm_lockres_set_refmap_bitderef work trigger, call
dlm_lockres_clear_refmap_bitto clear Node 1 from refmapNow Node 2 can purge the lock resource but the owner of lock resource on Node 1 is still Node 2 which may trigger BUG if the lock resource is $RECOVERY or other problems.
We have discussed 2 solutions:
1)The master return error to Node 1 if theDLM_LOCK_RES_SETREF_INPROGis set. Node 1 will not retry and master send another message to Node 1 after clearing the refmap. Node 1 can purge the lock resource after the refmap on master is cleared.
2) The master return error to Node 1 if theDLM_LOCK_RES_SETREF_INPROGis set, and Node 1 will retry to deref the lockres.Does anybody has better ideas?
Quoted 7 lines
Quoted 5 lines
dlm_purge_lockres()will wait to drop ref untilDLM_LOCK_RES_SETREF_INPROGcleared. So if set this flag when find the master during doing master request. And then this flag was cleared when receiving assert master message, can this fix the issue?I don't think this can fix. Before doing master request, the lock resource is already purged. The master should clear the refmap before client purge it.
inflight_locksis increased indlm_get_lock_resource()which will stop lockres purged? SetDLM_LOCK_RES_SETREF_INPROGwhen found lockres owner during master request, then this will stop lockres purged after unlock?Thanks,
Junxiao.Quoted 14 lines
Thanks,
JiufeiQuoted 9 lines
Thanks,
Junxiao.Quoted 3 lines
Thanks,
--Jiufei.
.
Hi Junxiao,
Quoted 30 lines · Junxiao Bi
Quoted 29 lines · xuejiufei
Hi Junxiao,
I have not describe the issue clearly.Node 1 Node 2(master)
dlmlockdlm_do_master_requestdlm_master_request_handler -> dlm_lockres_set_refmap_bitdlmlock succeed
dlmunlock succeed
dlm_purge_lockres
dlm_deref_handler
-> find lock resource is in
DLM_LOCK_RES_SETREF_INPROGstate, so dispatch a deref workdlm_purge_lockressucceed.call dlmlock again
dlm_do_master_request
dlm_master_request_handler->dlm_lockres_set_refmap_bitderef work trigger, call
dlm_lockres_clear_refmap_bitto clear Node 1 from refmap
dlm_purge_lockressucceed
Quoted 9 lines
Quoted 3 lines
dlm_send_remote_lock_request
returnDLM_IVLOCKIDbecause the lockres is not existMore clear now. Thank you.
This is a very complicated race. I didn't have a good solution to fix it now. Your fix looks work, but I am afraid if we keep going fix this kinds of races case by case, we will make dlm harder to understand and easy to involve bugs, maybe we should think about refactor dlm.
Agree. IMO, the root cause is bit op cannot handle such a case. I wonder if we have to change it to refcount, which may require a much bigger refactoring.
Thanks,
Joseph
Quoted 88 lines
Thanks,
Junxiao.Quoted 81 lines
BUG if the lockres is $RECOVERY
Quoted 77 lines · Junxiao Bi
Quoted 44 lines · xuejiufei
Hi, Junxiao
Quoted 41 lines · Junxiao Bi
Hi Jiufei,
Quoted 38 lines · xuejiufei
Hi all,
We have found a race between refmap setting and clearing which will cause the lock resource on master is freed before other nodes purge it.Node 1 Node 2(master)
dlm_do_master_requestdlm_master_request_handler -> dlm_lockres_set_refmap_bitcall
dlm_purge_lockresafter unlock
dlm_deref_handler
-> find lock resource is in
DLM_LOCK_RES_SETREF_INPROGstate, so dispatch a deref workdlm_purge_lockressucceed.
dlm_do_master_request
dlm_master_request_handler->dlm_lockres_set_refmap_bitderef work trigger, call
dlm_lockres_clear_refmap_bitto clear Node 1 from refmapNow Node 2 can purge the lock resource but the owner of lock resource on Node 1 is still Node 2 which may trigger BUG if the lock resource is $RECOVERY or other problems.
We have discussed 2 solutions:
1)The master return error to Node 1 if theDLM_LOCK_RES_SETREF_INPROGis set. Node 1 will not retry and master send another message to Node 1 after clearing the refmap. Node 1 can purge the lock resource after the refmap on master is cleared.
2) The master return error to Node 1 if theDLM_LOCK_RES_SETREF_INPROGis set, and Node 1 will retry to deref the lockres.Does anybody has better ideas?
Quoted 7 lines
Quoted 5 lines
dlm_purge_lockres()will wait to drop ref untilDLM_LOCK_RES_SETREF_INPROGcleared. So if set this flag when find the master during doing master request. And then this flag was cleared when receiving assert master message, can this fix the issue?I don't think this can fix. Before doing master request, the lock resource is already purged. The master should clear the refmap before client purge it.
inflight_locksis increased indlm_get_lock_resource()which will stop lockres purged? SetDLM_LOCK_RES_SETREF_INPROGwhen found lockres owner during master request, then this will stop lockres purged after unlock?Thanks,
Junxiao.Quoted 14 lines
Thanks,
JiufeiQuoted 9 lines
Thanks,
Junxiao.Quoted 3 lines
Thanks,
--Jiufei.
.
.
Quoted 42 lines · Joseph Qi
Hi Junxiao,
Quoted 30 lines · Junxiao Bi
Quoted 29 lines · xuejiufei
Hi Junxiao,
I have not describe the issue clearly.Node 1 Node 2(master)
dlmlockdlm_do_master_requestdlm_master_request_handler -> dlm_lockres_set_refmap_bitdlmlock succeed
dlmunlock succeed
dlm_purge_lockres
dlm_deref_handler
-> find lock resource is in
DLM_LOCK_RES_SETREF_INPROGstate, so dispatch a deref workdlm_purge_lockressucceed.call dlmlock again
dlm_do_master_request
dlm_master_request_handler->dlm_lockres_set_refmap_bitderef work trigger, call
dlm_lockres_clear_refmap_bitto clear Node 1 from refmap
dlm_purge_lockressucceedQuoted 9 lines
Quoted 3 lines
dlm_send_remote_lock_request
returnDLM_IVLOCKIDbecause the lockres is not existMore clear now. Thank you.
This is a very complicated race. I didn't have a good solution to fix it now. Your fix looks work, but I am afraid if we keep going fix this kinds of races case by case, we will make dlm harder to understand and easy to involve bugs, maybe we should think about refactor dlm.
Quoted 3 lines
Agree. IMO, the root cause is bit op cannot handle such a case. I wonder if we have to change it to refcount, which may require a much bigger refactoring.
one bit for each node seems reasonable, as lockres is per node. I think the cause is the dis-order of set/clear, i am trying to see whether they can be made happen in order.
Thanks,
Junxiao.
Quoted 94 lines
Thanks,
JosephQuoted 88 lines
Thanks,
Junxiao.Quoted 81 lines
BUG if the lockres is $RECOVERY
Quoted 77 lines · Junxiao Bi
Quoted 44 lines · xuejiufei
Hi, Junxiao
Quoted 41 lines · Junxiao Bi
Hi Jiufei,
Quoted 38 lines · xuejiufei
Hi all,
We have found a race between refmap setting and clearing which will cause the lock resource on master is freed before other nodes purge it.Node 1 Node 2(master)
dlm_do_master_requestdlm_master_request_handler -> dlm_lockres_set_refmap_bitcall
dlm_purge_lockresafter unlock
dlm_deref_handler
-> find lock resource is in
DLM_LOCK_RES_SETREF_INPROGstate, so dispatch a deref workdlm_purge_lockressucceed.
dlm_do_master_request
dlm_master_request_handler->dlm_lockres_set_refmap_bitderef work trigger, call
dlm_lockres_clear_refmap_bitto clear Node 1 from refmapNow Node 2 can purge the lock resource but the owner of lock resource on Node 1 is still Node 2 which may trigger BUG if the lock resource is $RECOVERY or other problems.
We have discussed 2 solutions:
1)The master return error to Node 1 if theDLM_LOCK_RES_SETREF_INPROGis set. Node 1 will not retry and master send another message to Node 1 after clearing the refmap. Node 1 can purge the lock resource after the refmap on master is cleared.
2) The master return error to Node 1 if theDLM_LOCK_RES_SETREF_INPROGis set, and Node 1 will retry to deref the lockres.Does anybody has better ideas?
Quoted 7 lines
Quoted 5 lines
dlm_purge_lockres()will wait to drop ref untilDLM_LOCK_RES_SETREF_INPROGcleared. So if set this flag when find the master during doing master request. And then this flag was cleared when receiving assert master message, can this fix the issue?I don't think this can fix. Before doing master request, the lock resource is already purged. The master should clear the refmap before client purge it.
inflight_locksis increased indlm_get_lock_resource()which will stop lockres purged? SetDLM_LOCK_RES_SETREF_INPROGwhen found lockres owner during master request, then this will stop lockres purged after unlock?Thanks,
Junxiao.Quoted 14 lines
Thanks,
JiufeiQuoted 9 lines
Thanks,
Junxiao.Quoted 3 lines
Thanks,
--Jiufei.
.
.
Quoted 43 lines · Junxiao Bi
Quoted 42 lines · Joseph Qi
Hi Junxiao,
Quoted 39 lines · Junxiao Bi
Quoted 27 lines · xuejiufei
Hi Junxiao,
I have not describe the issue clearly.Node 1 Node 2(master)
dlmlockdlm_do_master_requestdlm_master_request_handler -> dlm_lockres_set_refmap_bitdlmlock succeed
dlmunlock succeed
dlm_purge_lockres
dlm_deref_handler
-> find lock resource is in
DLM_LOCK_RES_SETREF_INPROGstate, so dispatch a deref workdlm_purge_lockressucceed.call dlmlock again
dlm_do_master_request
dlm_master_request_handler->dlm_lockres_set_refmap_bitderef work trigger, call
dlm_lockres_clear_refmap_bitto clear Node 1 from refmapQuoted 5 lines
dlm_purge_lockressucceed
dlm_send_remote_lock_request
returnDLM_IVLOCKIDbecause the lockres is not existMore clear now. Thank you.
This is a very complicated race. I didn't have a good solution to fix it now. Your fix looks work, but I am afraid if we keep going fix this kinds of races case by case, we will make dlm harder to understand and easy to involve bugs, maybe we should think about refactor dlm.
Quoted 7 lines
Quoted 3 lines
Agree. IMO, the root cause is bit op cannot handle such a case. I wonder if we have to change it to refcount, which may require a much bigger refactoring.
one bit for each node seems reasonable, as lockres is per node. I think the cause is the dis-order of set/clear, i am trying to see whether they can be made happen in order.
Agree. The solution 1) in my first mail is going to add a new message to keep the order of set and clear. Other nodes can purge the lock resource only after the refmap on master is cleared.
Thanks
Jiufei
Quoted 100 lines
Thanks,
Junxiao.Quoted 94 lines
Thanks,
JosephQuoted 88 lines
Thanks,
Junxiao.Quoted 81 lines
BUG if the lockres is $RECOVERY
Quoted 77 lines · Junxiao Bi
Quoted 44 lines · xuejiufei
Hi, Junxiao
Quoted 41 lines · Junxiao Bi
Hi Jiufei,
Quoted 38 lines · xuejiufei
Hi all,
We have found a race between refmap setting and clearing which will cause the lock resource on master is freed before other nodes purge it.Node 1 Node 2(master)
dlm_do_master_requestdlm_master_request_handler -> dlm_lockres_set_refmap_bitcall
dlm_purge_lockresafter unlock
dlm_deref_handler
-> find lock resource is in
DLM_LOCK_RES_SETREF_INPROGstate, so dispatch a deref workdlm_purge_lockressucceed.
dlm_do_master_request
dlm_master_request_handler->dlm_lockres_set_refmap_bitderef work trigger, call
dlm_lockres_clear_refmap_bitto clear Node 1 from refmapNow Node 2 can purge the lock resource but the owner of lock resource on Node 1 is still Node 2 which may trigger BUG if the lock resource is $RECOVERY or other problems.
We have discussed 2 solutions:
1)The master return error to Node 1 if theDLM_LOCK_RES_SETREF_INPROGis set. Node 1 will not retry and master send another message to Node 1 after clearing the refmap. Node 1 can purge the lock resource after the refmap on master is cleared.
2) The master return error to Node 1 if theDLM_LOCK_RES_SETREF_INPROGis set, and Node 1 will retry to deref the lockres.Does anybody has better ideas?
Quoted 7 lines
Quoted 5 lines
dlm_purge_lockres()will wait to drop ref untilDLM_LOCK_RES_SETREF_INPROGcleared. So if set this flag when find the master during doing master request. And then this flag was cleared when receiving assert master message, can this fix the issue?I don't think this can fix. Before doing master request, the lock resource is already purged. The master should clear the refmap before client purge it.
inflight_locksis increased indlm_get_lock_resource()which will stop lockres purged? SetDLM_LOCK_RES_SETREF_INPROGwhen found lockres owner during master request, then this will stop lockres purged after unlock?Thanks,
Junxiao.Quoted 14 lines
Thanks,
JiufeiQuoted 9 lines
Thanks,
Junxiao.Quoted 3 lines
Thanks,
--Jiufei.
.
.
.
Hi Jiufei & Joseph,
Quoted 49 lines · xuejiufei
Quoted 46 lines · Junxiao Bi
Quoted 45 lines · Joseph Qi
Hi Junxiao,
Quoted 30 lines · Junxiao Bi
Quoted 29 lines · xuejiufei
Hi Junxiao,
I have not describe the issue clearly.Node 1 Node 2(master)
dlmlockdlm_do_master_requestdlm_master_request_handler -> dlm_lockres_set_refmap_bitdlmlock succeed
dlmunlock succeed
dlm_purge_lockres
dlm_deref_handler
-> find lock resource is in
DLM_LOCK_RES_SETREF_INPROGstate, so dispatch a deref workdlm_purge_lockressucceed.call dlmlock again
dlm_do_master_request
dlm_master_request_handler->dlm_lockres_set_refmap_bitderef work trigger, call
dlm_lockres_clear_refmap_bitto clear Node 1 from refmap
dlm_purge_lockressucceedQuoted 9 lines
Quoted 3 lines
dlm_send_remote_lock_request
returnDLM_IVLOCKIDbecause the lockres is not existMore clear now. Thank you.
This is a very complicated race. I didn't have a good solution to fix it now. Your fix looks work, but I am afraid if we keep going fix this kinds of races case by case, we will make dlm harder to understand and easy to involve bugs, maybe we should think about refactor dlm.Agree. IMO, the root cause is bit op cannot handle such a case. I wonder if we have to change it to refcount, which may require a much bigger refactoring.
Quoted 7 lines
Quoted 4 lines
one bit for each node seems reasonable, as lockres is per node. I think the cause is the dis-order of set/clear, i am trying to see whether they can be made happen in order.
Agree. The solution 1) in my first mail is going to add a new message to keep the order of set and clear. Other nodes can purge the lock resource only after the refmap on master is cleared.
I am taking another way, try to delete deref_lockres_worker, and make deref refmap happen directly in deref handler. This needs find the dis-order part and fix. As I can see, the dis-order can only happen at do_assert_master set refmap after deref_lockres_handler clear it?
For this, need make sure not return MASTERY_REF to owner after purge. SETREF_INPROG is designed to do this. It is set by assert_master_handler and purge will wait it cleared before deref lockres. There are two cases where SETREF_INPROG is not set when purge
1. assert master message not coming when purge()
This happened when lockres owner already exist when asking for a lockres. Lockres owner will be known from master request message and dlm_get_lock_resouces return. Soon dlmlock/dlmunlock is done, and purge done. Then assert master message coming, but since MLE have been deleted in dlm_get_lock_resouce, it will not return MASTERY_REF to owner to reset refmap. So no problem in this case.
2. assert master handler set SETREF_INPROG too late SETREF_INPROG is set after lockres owner has been updated and dlm->spinlock released. That will make dlm_get_lock_resource waken up too fast, and then purge may happen before SETREF_INPROG is set. This is a bug and can be fix by the following patch.
fs/ocfs2/dlm/dlmmaster.c +1 -0
@@ -1965,6 +1965,7 @@ ok:if (res) {int wake =0 ;spin_lock (&res->spinlock); + res->state |=DLM_LOCK_RES_SETREF_INPROG ;if (mle->type ==DLM_MLE_MIGRATION ) { mlog(0, "finishing off migration of
lockres %.*s, "
"from %u to %u\n",
@@ -2029,12 +2030,8 @@ ok:
done:
ret = 0;
- if (res) {
- spin_lock(&res->spinlock);
- res->state |= DLM_LOCK_RES_SETREF_INPROG;
- spin_unlock(&res->spinlock);
+ if (res)
*ret_data = (void *)res;
- }
dlm_put(dlm);
if (master_request) {
mlog(0, "need to tell master to reassert\n");Besides this path, revert commit f3f854648de64c4b6f13f6f13113bc9525c621e5 ("ocfs2_dlm: Ensure correct ordering of set/clear refmap bit on lockres"), can this fix this issue?
Thanks,
Junxiao.
Quoted 105 lines
Thanks
JiufeiQuoted 100 lines
Thanks,
Junxiao.Quoted 94 lines
Thanks,
JosephQuoted 88 lines
Thanks,
Junxiao.Quoted 81 lines
BUG if the lockres is $RECOVERY
Quoted 77 lines · Junxiao Bi
Quoted 44 lines · xuejiufei
Hi, Junxiao
Quoted 41 lines · Junxiao Bi
Hi Jiufei,
Quoted 38 lines · xuejiufei
Hi all,
We have found a race between refmap setting and clearing which will cause the lock resource on master is freed before other nodes purge it.Node 1 Node 2(master)
dlm_do_master_requestdlm_master_request_handler -> dlm_lockres_set_refmap_bitcall
dlm_purge_lockresafter unlock
dlm_deref_handler
-> find lock resource is in
DLM_LOCK_RES_SETREF_INPROGstate, so dispatch a deref workdlm_purge_lockressucceed.
dlm_do_master_request
dlm_master_request_handler->dlm_lockres_set_refmap_bitderef work trigger, call
dlm_lockres_clear_refmap_bitto clear Node 1 from refmapNow Node 2 can purge the lock resource but the owner of lock resource on Node 1 is still Node 2 which may trigger BUG if the lock resource is $RECOVERY or other problems.
We have discussed 2 solutions:
1)The master return error to Node 1 if theDLM_LOCK_RES_SETREF_INPROGis set. Node 1 will not retry and master send another message to Node 1 after clearing the refmap. Node 1 can purge the lock resource after the refmap on master is cleared.
2) The master return error to Node 1 if theDLM_LOCK_RES_SETREF_INPROGis set, and Node 1 will retry to deref the lockres.Does anybody has better ideas?
Quoted 7 lines
Quoted 5 lines
dlm_purge_lockres()will wait to drop ref untilDLM_LOCK_RES_SETREF_INPROGcleared. So if set this flag when find the master during doing master request. And then this flag was cleared when receiving assert master message, can this fix the issue?I don't think this can fix. Before doing master request, the lock resource is already purged. The master should clear the refmap before client purge it.
inflight_locksis increased indlm_get_lock_resource()which will stop lockres purged? SetDLM_LOCK_RES_SETREF_INPROGwhen found lockres owner during master request, then this will stop lockres purged after unlock?Thanks,
Junxiao.Quoted 14 lines
Thanks,
JiufeiQuoted 9 lines
Thanks,
Junxiao.Quoted 3 lines
Thanks,
--Jiufei.
.
.
.
Hi Junxiao,
commit f3f854648de64c4b6f13f6f13113bc9525c621e5 is to solve the disorder problem of set/clear refmap on master. If it is reverted, how to fix the problem the patch described?
I think the following is the issue that patch fixed.
The set refmap bit message is sent before the clear refmap message. But these two message is processed by different processes, so the set refmap message may be handled before the clear.
Node 1 Node 2(master)
dlm_wq o2net_wq
dlm_do_assert_masterdlm_do_assert_handler
return MASTERY_REF
receive MASTERY_REFdlm_purge_lockres
send deref message
receive deref message -> dlm_deref_lockres_handler
and clear refmap
-> set refmap
Quoted 230 lines · Junxiao Bi
Hi Jiufei & Joseph,
Quoted 49 lines · xuejiufei
Quoted 46 lines · Junxiao Bi
Quoted 45 lines · Joseph Qi
Hi Junxiao,
Quoted 30 lines · Junxiao Bi
Quoted 29 lines · xuejiufei
Hi Junxiao,
I have not describe the issue clearly.Node 1 Node 2(master)
dlmlockdlm_do_master_requestdlm_master_request_handler -> dlm_lockres_set_refmap_bitdlmlock succeed
dlmunlock succeed
dlm_purge_lockres
dlm_deref_handler
-> find lock resource is in
DLM_LOCK_RES_SETREF_INPROGstate, so dispatch a deref workdlm_purge_lockressucceed.call dlmlock again
dlm_do_master_request
dlm_master_request_handler->dlm_lockres_set_refmap_bitderef work trigger, call
dlm_lockres_clear_refmap_bitto clear Node 1 from refmap
dlm_purge_lockressucceedQuoted 9 lines
Quoted 3 lines
dlm_send_remote_lock_request
returnDLM_IVLOCKIDbecause the lockres is not existMore clear now. Thank you.
This is a very complicated race. I didn't have a good solution to fix it now. Your fix looks work, but I am afraid if we keep going fix this kinds of races case by case, we will make dlm harder to understand and easy to involve bugs, maybe we should think about refactor dlm.Agree. IMO, the root cause is bit op cannot handle such a case. I wonder if we have to change it to refcount, which may require a much bigger refactoring.
Quoted 7 lines
Quoted 4 lines
one bit for each node seems reasonable, as lockres is per node. I think the cause is the dis-order of set/clear, i am trying to see whether they can be made happen in order.
Agree. The solution 1) in my first mail is going to add a new message to keep the order of set and clear. Other nodes can purge the lock resource only after the refmap on master is cleared.
I am taking another way, try to delete
deref_lockres_worker, and make deref refmap happen directly in deref handler. This needs find the dis-order part and fix. As I can see, the dis-order can only happen atdo_assert_masterset refmap afterderef_lockres_handlerclear it?For this, need make sure not return
MASTERY_REFto owner after purge.SETREF_INPROGis designed to do this. It is set byassert_master_handlerand purge will wait it cleared before deref lockres. There are two cases whereSETREF_INPROGis not set when purge1. assert master message not coming when
purge()
This happened when lockres owner already exist when asking for a lockres. Lockres owner will be known from master request message anddlm_get_lock_resoucesreturn. Soon dlmlock/dlmunlock is done, and purge done. Then assert master message coming, but since MLE have been deleted indlm_get_lock_resouce, it will not returnMASTERY_REFto owner to reset refmap. So no problem in this case.2. assert master handler set
SETREF_INPROGtoo lateSETREF_INPROGis set after lockres owner has been updated anddlm->spinlockreleased. That will makedlm_get_lock_resourcewaken up too fast, and then purge may happen beforeSETREF_INPROGis set. This is a bug and can be fix by the following patch.fs/ocfs2/dlm/dlmmaster.c +1
-0@@ -1965,6 +1965,7 @@ ok:if (res) {int wake =0 ;spin_lock (&res->spinlock); + res->state |=DLM_LOCK_RES_SETREF_INPROG ;if (mle->type ==DLM_MLE_MIGRATION ) { mlog(0, "finishing off migration oflockres %.*s, "
"from %u to %u\n",fs/ocfs2/dlm/dlmmaster.c +1
-5@@ -2029,12 +2030,8 @@ ok: done: ret =0 ; -if (res) { -spin_lock (&res->spinlock); - res->state |=DLM_LOCK_RES_SETREF_INPROG ; -spin_unlock (&res->spinlock); +if (res) *ret_data = (void *)res; - }dlm_put (dlm);if (master_request) {mlog (0 ,"need to tell master to reassert\n" );Besides this path, revert commit
f3f854648de64c4b6f13f6f13113bc9525c621e5("ocfs2_dlm: Ensure correct ordering of set/clear refmap bit on lockres"), can this fix this issue?Thanks,
Junxiao.Quoted 105 lines
Thanks
JiufeiQuoted 100 lines
Thanks,
Junxiao.Quoted 94 lines
Thanks,
JosephQuoted 88 lines
Thanks,
Junxiao.Quoted 81 lines
BUG if the lockres is $RECOVERY
Quoted 77 lines · Junxiao Bi
Quoted 44 lines · xuejiufei
Hi, Junxiao
Quoted 41 lines · Junxiao Bi
Hi Jiufei,
Quoted 38 lines · xuejiufei
Hi all,
We have found a race between refmap setting and clearing which will cause the lock resource on master is freed before other nodes purge it.Node 1 Node 2(master)
dlm_do_master_requestdlm_master_request_handler -> dlm_lockres_set_refmap_bitcall
dlm_purge_lockresafter unlock
dlm_deref_handler
-> find lock resource is in
DLM_LOCK_RES_SETREF_INPROGstate, so dispatch a deref workdlm_purge_lockressucceed.
dlm_do_master_request
dlm_master_request_handler->dlm_lockres_set_refmap_bitderef work trigger, call
dlm_lockres_clear_refmap_bitto clear Node 1 from refmapNow Node 2 can purge the lock resource but the owner of lock resource on Node 1 is still Node 2 which may trigger BUG if the lock resource is $RECOVERY or other problems.
We have discussed 2 solutions:
1)The master return error to Node 1 if theDLM_LOCK_RES_SETREF_INPROGis set. Node 1 will not retry and master send another message to Node 1 after clearing the refmap. Node 1 can purge the lock resource after the refmap on master is cleared.
2) The master return error to Node 1 if theDLM_LOCK_RES_SETREF_INPROGis set, and Node 1 will retry to deref the lockres.Does anybody has better ideas?
Quoted 7 lines
Quoted 5 lines
dlm_purge_lockres()will wait to drop ref untilDLM_LOCK_RES_SETREF_INPROGcleared. So if set this flag when find the master during doing master request. And then this flag was cleared when receiving assert master message, can this fix the issue?I don't think this can fix. Before doing master request, the lock resource is already purged. The master should clear the refmap before client purge it.
inflight_locksis increased indlm_get_lock_resource()which will stop lockres purged? SetDLM_LOCK_RES_SETREF_INPROGwhen found lockres owner during master request, then this will stop lockres purged after unlock?Thanks,
Junxiao.Quoted 14 lines
Thanks,
JiufeiQuoted 9 lines
Thanks,
Junxiao.Quoted 3 lines
Thanks,
--Jiufei.
.
.
.
.
Hi Jiufei,
Right. Revert that patch will introduce that dis-order, thank you for pointing it out. I will think about more about it. My idea is to do some refactor to make it more smooth while not introducing complicated things to just fix that bug.
Thanks,
Junxiao.
Quoted 257 lines · xuejiufei
Hi Junxiao,
commitf3f854648de64c4b6f13f6f13113bc9525c621e5is to solve the disorder problem of set/clear refmap on master. If it is reverted, how to fix the problem the patch described?I think the following is the issue that patch fixed.
The set refmap bit message is sent before the clear refmap message. But these two message is processed by different processes, so the set refmap message may be handled before the clear.Node 1 Node 2(master)
dlm_wqo2net_wq
dlm_do_assert_masterdlm_do_assert_handler
returnMASTERY_REF
receiveMASTERY_REFdlm_purge_lockres
send deref message
receive deref message ->dlm_deref_lockres_handler
and clear refmap
-> set refmapQuoted 230 lines · Junxiao Bi
Hi Jiufei & Joseph,
Quoted 49 lines · xuejiufei
Quoted 46 lines · Junxiao Bi
Quoted 45 lines · Joseph Qi
Hi Junxiao,
Quoted 30 lines · Junxiao Bi
Quoted 29 lines · xuejiufei
Hi Junxiao,
I have not describe the issue clearly.Node 1 Node 2(master)
dlmlockdlm_do_master_requestdlm_master_request_handler -> dlm_lockres_set_refmap_bitdlmlock succeed
dlmunlock succeed
dlm_purge_lockres
dlm_deref_handler
-> find lock resource is in
DLM_LOCK_RES_SETREF_INPROGstate, so dispatch a deref workdlm_purge_lockressucceed.call dlmlock again
dlm_do_master_request
dlm_master_request_handler->dlm_lockres_set_refmap_bitderef work trigger, call
dlm_lockres_clear_refmap_bitto clear Node 1 from refmap
dlm_purge_lockressucceedQuoted 9 lines
Quoted 3 lines
dlm_send_remote_lock_request
returnDLM_IVLOCKIDbecause the lockres is not existMore clear now. Thank you.
This is a very complicated race. I didn't have a good solution to fix it now. Your fix looks work, but I am afraid if we keep going fix this kinds of races case by case, we will make dlm harder to understand and easy to involve bugs, maybe we should think about refactor dlm.Agree. IMO, the root cause is bit op cannot handle such a case. I wonder if we have to change it to refcount, which may require a much bigger refactoring.
Quoted 7 lines
Quoted 4 lines
one bit for each node seems reasonable, as lockres is per node. I think the cause is the dis-order of set/clear, i am trying to see whether they can be made happen in order.
Agree. The solution 1) in my first mail is going to add a new message to keep the order of set and clear. Other nodes can purge the lock resource only after the refmap on master is cleared.
I am taking another way, try to delete
deref_lockres_worker, and make deref refmap happen directly in deref handler. This needs find the dis-order part and fix. As I can see, the dis-order can only happen atdo_assert_masterset refmap afterderef_lockres_handlerclear it?For this, need make sure not return
MASTERY_REFto owner after purge.SETREF_INPROGis designed to do this. It is set byassert_master_handlerand purge will wait it cleared before deref lockres. There are two cases whereSETREF_INPROGis not set when purge1. assert master message not coming when
purge()
This happened when lockres owner already exist when asking for a lockres. Lockres owner will be known from master request message anddlm_get_lock_resoucesreturn. Soon dlmlock/dlmunlock is done, and purge done. Then assert master message coming, but since MLE have been deleted indlm_get_lock_resouce, it will not returnMASTERY_REFto owner to reset refmap. So no problem in this case.2. assert master handler set
SETREF_INPROGtoo lateSETREF_INPROGis set after lockres owner has been updated anddlm->spinlockreleased. That will makedlm_get_lock_resourcewaken up too fast, and then purge may happen beforeSETREF_INPROGis set. This is a bug and can be fix by the following patch.fs/ocfs2/dlm/dlmmaster.c +1
-0@@ -1965,6 +1965,7 @@ ok:if (res) {int wake =0 ;spin_lock (&res->spinlock); + res->state |=DLM_LOCK_RES_SETREF_INPROG ;if (mle->type ==DLM_MLE_MIGRATION ) { mlog(0, "finishing off migration oflockres %.*s, "
"from %u to %u\n",fs/ocfs2/dlm/dlmmaster.c +1
-5@@ -2029,12 +2030,8 @@ ok: done: ret =0 ; -if (res) { -spin_lock (&res->spinlock); - res->state |=DLM_LOCK_RES_SETREF_INPROG ; -spin_unlock (&res->spinlock); +if (res) *ret_data = (void *)res; - }dlm_put (dlm);if (master_request) {mlog (0 ,"need to tell master to reassert\n" );Besides this path, revert commit
f3f854648de64c4b6f13f6f13113bc9525c621e5("ocfs2_dlm: Ensure correct ordering of set/clear refmap bit on lockres"), can this fix this issue?Thanks,
Junxiao.Quoted 105 lines
Thanks
JiufeiQuoted 100 lines
Thanks,
Junxiao.Quoted 94 lines
Thanks,
JosephQuoted 88 lines
Thanks,
Junxiao.Quoted 81 lines
BUG if the lockres is $RECOVERY
Quoted 77 lines · Junxiao Bi
Quoted 44 lines · xuejiufei
Hi, Junxiao
Quoted 41 lines · Junxiao Bi
Hi Jiufei,
Quoted 38 lines · xuejiufei
Hi all,
We have found a race between refmap setting and clearing which will cause the lock resource on master is freed before other nodes purge it.Node 1 Node 2(master)
dlm_do_master_requestdlm_master_request_handler -> dlm_lockres_set_refmap_bitcall
dlm_purge_lockresafter unlock
dlm_deref_handler
-> find lock resource is in
DLM_LOCK_RES_SETREF_INPROGstate, so dispatch a deref workdlm_purge_lockressucceed.
dlm_do_master_request
dlm_master_request_handler->dlm_lockres_set_refmap_bitderef work trigger, call
dlm_lockres_clear_refmap_bitto clear Node 1 from refmapNow Node 2 can purge the lock resource but the owner of lock resource on Node 1 is still Node 2 which may trigger BUG if the lock resource is $RECOVERY or other problems.
We have discussed 2 solutions:
1)The master return error to Node 1 if theDLM_LOCK_RES_SETREF_INPROGis set. Node 1 will not retry and master send another message to Node 1 after clearing the refmap. Node 1 can purge the lock resource after the refmap on master is cleared.
2) The master return error to Node 1 if theDLM_LOCK_RES_SETREF_INPROGis set, and Node 1 will retry to deref the lockres.Does anybody has better ideas?
Quoted 7 lines
Quoted 5 lines
dlm_purge_lockres()will wait to drop ref untilDLM_LOCK_RES_SETREF_INPROGcleared. So if set this flag when find the master during doing master request. And then this flag was cleared when receiving assert master message, can this fix the issue?I don't think this can fix. Before doing master request, the lock resource is already purged. The master should clear the refmap before client purge it.
inflight_locksis increased indlm_get_lock_resource()which will stop lockres purged? SetDLM_LOCK_RES_SETREF_INPROGwhen found lockres owner during master request, then this will stop lockres purged after unlock?Thanks,
Junxiao.Quoted 14 lines
Thanks,
JiufeiQuoted 9 lines
Thanks,
Junxiao.Quoted 3 lines
Thanks,
--Jiufei.
.
.
.
.
Hi Jiufei,
I didn't find other solution for this issue. You can go with yours. Looks like your second one is more straightforward, there deref work can be removed.
Thanks,
Junxiao.
Quoted 41 lines · xuejiufei
Hi all,
We have found a race between refmap setting and clearing which will cause the lock resource on master is freed before other nodes purge it.Node 1 Node 2(master)
dlm_do_master_requestdlm_master_request_handler -> dlm_lockres_set_refmap_bitcall
dlm_purge_lockresafter unlock
dlm_deref_handler
-> find lock resource is in
DLM_LOCK_RES_SETREF_INPROGstate, so dispatch a deref workdlm_purge_lockressucceed.
dlm_do_master_request
dlm_master_request_handler->dlm_lockres_set_refmap_bitderef work trigger, call
dlm_lockres_clear_refmap_bitto clear Node 1 from refmapNow Node 2 can purge the lock resource but the owner of lock resource on Node 1 is still Node 2 which may trigger BUG if the lock resource is $RECOVERY or other problems.
We have discussed 2 solutions:
1)The master return error to Node 1 if theDLM_LOCK_RES_SETREF_INPROGis set. Node 1 will not retry and master send another message to Node 1 after clearing the refmap. Node 1 can purge the lock resource after the refmap on master is cleared.
2) The master return error to Node 1 if theDLM_LOCK_RES_SETREF_INPROGis set, and Node 1 will retry to deref the lockres.Does anybody has better ideas?
Thanks,
--Jiufei
Hi Junxiao,
Quoted 6 lines · Junxiao Bi
Hi Jiufei,
I didn't find other solution for this issue. You can go with yours. Looks like your second one is more straightforward, there deref work can be removed.
There are two problems with the second solution:
1) Node retry to deref the lock resource will block dlm_thread to process other lock resources.
2) When node retries to drop the refmap bit, the master may be in another assert master work, that will take a long time to purge a lockres. So I prefer the first solution.
Thanks,
Jiufei
Quoted 48 lines
Thanks,
Junxiao.Quoted 36 lines · xuejiufei
Hi all,
We have found a race between refmap setting and clearing which will cause the lock resource on master is freed before other nodes purge it.Node 1 Node 2(master)
dlm_do_master_requestdlm_master_request_handler -> dlm_lockres_set_refmap_bitcall
dlm_purge_lockresafter unlock
dlm_deref_handler
-> find lock resource is in
DLM_LOCK_RES_SETREF_INPROGstate, so dispatch a deref workdlm_purge_lockressucceed.
dlm_do_master_request
dlm_master_request_handler->dlm_lockres_set_refmap_bitderef work trigger, call
dlm_lockres_clear_refmap_bitto clear Node 1 from refmapNow Node 2 can purge the lock resource but the owner of lock resource on Node 1 is still Node 2 which may trigger BUG if the lock resource is $RECOVERY or other problems.
We have discussed 2 solutions:
1)The master return error to Node 1 if theDLM_LOCK_RES_SETREF_INPROGis set. Node 1 will not retry and master send another message to Node 1 after clearing the refmap. Node 1 can purge the lock resource after the refmap on master is cleared.
2) The master return error to Node 1 if theDLM_LOCK_RES_SETREF_INPROGis set, and Node 1 will retry to deref the lockres.Quoted 5 lines
Does anybody has better ideas?
Thanks,
--Jiufei.
Quoted 5 lines · xuejiufei
Hi Junxiao,
Quoted 2 lines · Junxiao Bi
Hi Jiufei,
Quoted 7 lines
Quoted 4 lines
I didn't find other solution for this issue. You can go with yours. Looks like your second one is more straightforward, there deref work can be removed.
There are two problems with the second solution:
1) Node retry to deref the lock resource will blockdlm_threadto process other lock resources.
Yes, a little, but i don't think that will be long. Indeed I think about clear DLM_LOCK_RES_DROPPING_REF and requeue lockres again before, that will not block dlm_thread, but I found dlm had an assuming about this flag, it assumed the lockres is gone if it is set. If this bad assuming can be fixed, the second solution will be much better.
Quoted 2 lines
2) When node retries to drop the refmap bit, the master may be in another assert master work, that will take a long time to purge a lockres.
Delay purging lockres maybe not a bad idea, but a good one. Like in your case, the second lock request can go directly without master reqeust. This can improve performance.
Thanks,
Junxiao.
Quoted 54 lines
So I prefer the first solution.
Thanks,
JiufeiQuoted 48 lines
Thanks,
Junxiao.Quoted 36 lines · xuejiufei
Hi all,
We have found a race between refmap setting and clearing which will cause the lock resource on master is freed before other nodes purge it.Node 1 Node 2(master)
dlm_do_master_requestdlm_master_request_handler -> dlm_lockres_set_refmap_bitcall
dlm_purge_lockresafter unlock
dlm_deref_handler
-> find lock resource is in
DLM_LOCK_RES_SETREF_INPROGstate, so dispatch a deref workdlm_purge_lockressucceed.
dlm_do_master_request
dlm_master_request_handler->dlm_lockres_set_refmap_bitderef work trigger, call
dlm_lockres_clear_refmap_bitto clear Node 1 from refmapNow Node 2 can purge the lock resource but the owner of lock resource on Node 1 is still Node 2 which may trigger BUG if the lock resource is $RECOVERY or other problems.
We have discussed 2 solutions:
1)The master return error to Node 1 if theDLM_LOCK_RES_SETREF_INPROGis set. Node 1 will not retry and master send another message to Node 1 after clearing the refmap. Node 1 can purge the lock resource after the refmap on master is cleared.
2) The master return error to Node 1 if theDLM_LOCK_RES_SETREF_INPROGis set, and Node 1 will retry to deref the lockres.Quoted 5 lines
Does anybody has better ideas?
Thanks,
--Jiufei.