Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Levin Zimmermann
neoppod
Commits
72eb5bc2
Commit
72eb5bc2
authored
Mar 26, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
X zodb: Correct storage not to deadlock driver on watcher failure
parent
18d00625
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
4 deletions
+18
-4
go/zodb/storage.go
go/zodb/storage.go
+18
-4
No files found.
go/zodb/storage.go
View file @
72eb5bc2
...
...
@@ -181,9 +181,10 @@ type storage struct {
driver
IStorageDriver
l1cache
*
Cache
// can be =nil, if opened with NoCache
down
chan
struct
{}
// ready when no longer operational
downOnce
sync
.
Once
// shutdown may be due to both Close and IO error in watcher|Sync
downErr
error
// reason for shutdown
down
chan
struct
{}
// ready when no longer operational
downOnce
sync
.
Once
// shutdown may be due to both Close and IO error in watcher|Sync
downErr
error
// reason for shutdown
drvCloseErr
error
// err from .driver.Close()
// watcher
...
...
@@ -206,6 +207,11 @@ func (s *storage) shutdown(reason error) {
s
.
downOnce
.
Do
(
func
()
{
close
(
s
.
down
)
s
.
downErr
=
fmt
.
Errorf
(
"not operational due: %s"
,
reason
)
// - if called by Close or failed Sync: driver.Close will close
// drvWatchq and cause watcher to stop.
// - if called by failed watcher: closing driver will prevent
// drvWatchq<- deadlock in driver because we no longer read from it.
s
.
drvCloseErr
=
s
.
driver
.
Close
()
})
}
...
...
@@ -219,7 +225,7 @@ func (s *storage) Iterate(ctx context.Context, tidMin, tidMax Tid) ITxnIterator
func
(
s
*
storage
)
Close
()
error
{
s
.
shutdown
(
fmt
.
Errorf
(
"closed"
))
return
s
.
dr
iver
.
Close
()
// this will close drvWatchq and cause watcher stop
return
s
.
dr
vCloseErr
}
// loading goes through cache - this way prefetching can work
...
...
@@ -492,6 +498,14 @@ func (s *storage) Sync(ctx context.Context) (err error) {
}
// wait till .head >= head
// XXX instead require from drivers that `drv.Sync() -> head`
// guarantees that all EventCommit with .tid <= head were sent to
// watchq
//
// https://lab.nexedi.com/nexedi/ZODB/commit/40116375
// https://github.com/zopefoundation/ZODB/commit/4a6b0283#diff-d2a01f71a79ac2b379e218cf72fa1205d3426cad19e7b72d71899f643be4bb73
//
// ?
watchq
:=
make
(
chan
Event
)
at
=
s
.
AddWatch
(
watchq
)
defer
s
.
DelWatch
(
watchq
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment