Skip to content

Commit feb4a02

Browse files
committed
force open LevelDB in parallel
1 parent 96da9ab commit feb4a02

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

go/service/main.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -303,12 +303,11 @@ func (d *Service) Run() (err error) {
303303
return
304304
}
305305

306-
if err = d.G().LocalDb.ForceOpen(); err != nil {
307-
return err
308-
}
309-
if err = d.G().LocalChatDb.ForceOpen(); err != nil {
310-
return err
311-
}
306+
// Open both local DBs concurrently. They are at different paths so there
307+
// is no lock contention between them. Any DB call that arrives before an
308+
// open finishes will block on sync.Once inside doWhileOpenAndNukeIfCorrupted.
309+
go func() { _ = d.G().LocalDb.ForceOpen() }()
310+
go func() { _ = d.G().LocalChatDb.ForceOpen() }()
312311

313312
var l net.Listener
314313
if l, err = d.ConfigRPCServer(); err != nil {
@@ -667,6 +666,12 @@ func (d *Service) StartLoopbackServer(loginMode libkb.LoginAttempt) error {
667666
return err
668667
}
669668

669+
// Open both local DBs concurrently. They are at different paths so there
670+
// is no lock contention between them. Any DB call that arrives before an
671+
// open finishes will block on sync.Once inside doWhileOpenAndNukeIfCorrupted.
672+
go func() { _ = d.G().LocalDb.ForceOpen() }()
673+
go func() { _ = d.G().LocalChatDb.ForceOpen() }()
674+
670675
if l, err = d.G().MakeLoopbackServer(); err != nil {
671676
return err
672677
}

0 commit comments

Comments
 (0)