Commit 04346414 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 028fdbf0
...@@ -151,7 +151,7 @@ type storage struct { ...@@ -151,7 +151,7 @@ type storage struct {
l1cache *Cache // can be =nil, if opened with NoCache l1cache *Cache // can be =nil, if opened with NoCache
down chan struct{} // ready when no longer operational down chan struct{} // ready when no longer operational
downOnce sync.Once // shutdown may be due to both Close and IO error in watcher downOnce sync.Once // shutdown may be due to both Close and IO error in watcher|Sync
downErr error // reason for shutdown downErr error // reason for shutdown
// watcher // watcher
...@@ -444,16 +444,25 @@ func (s *storage) Sync(ctx context.Context) (err error) { ...@@ -444,16 +444,25 @@ func (s *storage) Sync(ctx context.Context) (err error) {
return s.downErr return s.downErr
} }
s.headMu.Lock()
at := s.head
s.headMu.Unlock()
head, err := s.driver.Sync(ctx) head, err := s.driver.Sync(ctx)
if err != nil { if err != nil {
return err return err
} }
// XXX check that driver returns head↑ // check that driver returns head↑
if !(head >= at) {
err = fmt.Errorf("%s: storage error: sync not ↑= (%s -> %s)", s.URL(), at, head)
s.shutdown(err)
return err
}
// wait till .head >= head // wait till .head >= head
watchq := make(chan Event) watchq := make(chan Event)
at := s.AddWatch(watchq) at = s.AddWatch(watchq)
defer s.DelWatch(watchq) defer s.DelWatch(watchq)
for at < head { for at < head {
......
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