From 7277286391710daa31b78fb53f6632c887b77368 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Wed, 6 Mar 2024 11:50:14 +0100 Subject: [PATCH] Manager: increase 'database open' timeout to 1 minute Increase the 'database open' timeout from 5 seconds to 1 minute. This timeout also covers database migrations, and the recently added one that adds a bunch of `NOT NULL` clauses could time out with the old 5 sec limit. The reason this takes long, is that SQLite doesn't directly support adding `NOT NULL` clauses to columns. The only way to do this is to create a new table with the desired schema, copy all data over, then drop the old table. And with a big enough database, this takes time. --- cmd/flamenco-manager/main.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmd/flamenco-manager/main.go b/cmd/flamenco-manager/main.go index 42373bbe..1741e25e 100644 --- a/cmd/flamenco-manager/main.go +++ b/cmd/flamenco-manager/main.go @@ -56,6 +56,10 @@ const ( developmentWebInterfacePort = 8081 webappEntryPoint = "index.html" + + // dbOpenTimeout is the time the persistence layer gets to open the database. + // This includes database migrations, which can take some time to perform. + dbOpenTimeout = 1 * time.Minute ) type shutdownFunc func() @@ -379,7 +383,7 @@ func openDB(configService config.Service) *persistence.DB { log.Fatal().Msg("configure the database in flamenco-manager.yaml") } - dbCtx, dbCtxCancel := context.WithTimeout(context.Background(), 5*time.Second) + dbCtx, dbCtxCancel := context.WithTimeout(context.Background(), dbOpenTimeout) defer dbCtxCancel() persist, err := persistence.OpenDB(dbCtx, dsn) if err != nil {