From 9f9e048d35e2e3fd950657ef20343afda5f1778c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matija=20Petruni=C4=87?= Date: Wed, 31 Jan 2024 12:50:34 +0100 Subject: [PATCH] fix: wait for db lock (#31) --- main.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index e365c27..53f2816 100644 --- a/main.go +++ b/main.go @@ -56,9 +56,16 @@ func main() { go health.StartHealthEndpoint(cfg.Observability.HealthPort) - db, err := lvldb.NewLvlDB(cfg.Store.Path) - if err != nil { - panic(err) + var db *lvldb.LVLDB + for { + db, err = lvldb.NewLvlDB(cfg.Store.Path) + if err != nil { + log.Error().Err(err).Msg("Unable to connect to blockstore file, retry in 10 seconds") + time.Sleep(10 * time.Second) + } else { + log.Info().Msg("Successfully connected to blockstore file") + break + } } periodStore := store.NewPeriodStore(db)