Commit 6adc53bd authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent a6874733
...@@ -180,22 +180,22 @@ if we try to upload data to kernel pagecache from under serving read request, ...@@ -180,22 +180,22 @@ if we try to upload data to kernel pagecache from under serving read request,
this can deadlock. this can deadlock.
Another case that needs to be cared about is interaction between uploadBlk and Another case that needs to be cared about is interaction between uploadBlk and
zwatcher: zconnMu being RWMutex, does not allow new RLocks to be taken once zwatcher: zheadMu being RWMutex, does not allow new RLocks to be taken once
Lock request has been issued. Thus the following scenario is possible:: Lock request has been issued. Thus the following scenario is possible::
uploadBlk os.Read zwatcher uploadBlk os.Read zwatcher
page.Lock page.Lock
zconnMu.Rlock zheadMu.Rlock
zconnMu.Lock zheadMu.Lock
page.Lock page.Lock
zconnMu.Rlock zheadMu.Rlock
- zwatcher is waiting for uploadBlk to release zconnMu; - zwatcher is waiting for uploadBlk to release zheadMu;
- uploadBlk is waiting for os.Read to release page; - uploadBlk is waiting for os.Read to release page;
- os.Read is waiting for zwatcher to release zconnMu; - os.Read is waiting for zwatcher to release zheadMu;
- deadlock. - deadlock.
To avoid such deadlocks zwatcher asks OS cache uploaders to pause while it is To avoid such deadlocks zwatcher asks OS cache uploaders to pause while it is
running, and retries taking zconnMu.Lock until all uploaders are indeed paused. running, and retries taking zheadMu.Lock until all uploaders are indeed paused.
...@@ -310,8 +310,6 @@ package main ...@@ -310,8 +310,6 @@ package main
// 4.6) processing ZODB invalidations and serving file reads (see 7) are // 4.6) processing ZODB invalidations and serving file reads (see 7) are
// organized to be mutually exclusive. // organized to be mutually exclusive.
// //
// (TODO head.zheadMu -> special mutex with Lock(ctx) so that Lock could be canceled)
//
// 5) after OS file cache was invalidated, we resync zhead to new database // 5) after OS file cache was invalidated, we resync zhead to new database
// view corresponding to tid. // view corresponding to tid.
// //
...@@ -489,7 +487,7 @@ type Head struct { ...@@ -489,7 +487,7 @@ type Head struct {
// ZODB connection for everything under this head // ZODB connection for everything under this head
// zheadMu protects access to zconn & live _objects_ associated with it. // zheadMu protects zconn.At & live _objects_ associated with it.
// while it is rlocked zconn is guaranteed to stay viewing database at // while it is rlocked zconn is guaranteed to stay viewing database at
// particular view. // particular view.
// //
...@@ -665,6 +663,15 @@ func (_ *zodbCacheControl) PCacheClassify(obj zodb.IPersistent) zodb.PCachePolic ...@@ -665,6 +663,15 @@ func (_ *zodbCacheControl) PCacheClassify(obj zodb.IPersistent) zodb.PCachePolic
return 0 return 0
} }
// -------- zhead lock/wait --------
// TODO head.zheadMu -> special mutex with Lock(ctx) so that Lock wait could be canceled
func (head *Head) zheadRLock() { head.zheadMu.RLock() }
func (head *Head) zheadRUnlock() { head.zheadMu.RUnlock() }
func (head *Head) zheadLock() { head.zheadMu.Lock() }
func (head *Head) zheadUnlock() { head.zheadMu.Unlock() }
// -------- 4) ZODB invalidation -> OS cache -------- // -------- 4) ZODB invalidation -> OS cache --------
func traceZWatch(format string, argv ...interface{}) { func traceZWatch(format string, argv ...interface{}) {
......
...@@ -230,7 +230,7 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit, zhead *ZConn) ΔF { ...@@ -230,7 +230,7 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit, zhead *ZConn) ΔF {
switch obj := obj.(type) { switch obj := obj.(type) {
case zBlk: // ZBlk* case zBlk: // ZBlk*
// z.infile locking: since we write-locked head.zconnMu // z.infile locking: since we write-locked head.zheadMu
// - no other fuse reads are running, and thus no one // - no other fuse reads are running, and thus no one
// is mutating z.infile. XXX recheck // is mutating z.infile. XXX recheck
z := obj.inΔFtail() z := obj.inΔFtail()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment