From 9ff33d247703550f015afc098b73caca3f1d8c87 Mon Sep 17 00:00:00 2001 From: Lars Lehtonen Date: Wed, 8 Apr 2026 09:21:56 -0700 Subject: [PATCH] view: fix dropped errors --- view/pool.go | 15 +++++++++++---- view/resource.go | 14 +++++++++----- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/view/pool.go b/view/pool.go index 48ba24b0..1e07387e 100644 --- a/view/pool.go +++ b/view/pool.go @@ -4,12 +4,13 @@ import ( "context" "database/sql" "fmt" - as "github.com/aerospike/aerospike-client-go" - "github.com/aerospike/aerospike-client-go/types" "strconv" "strings" "sync" "time" + + as "github.com/aerospike/aerospike-client-go" + "github.com/aerospike/aerospike-client-go/types" ) var ( @@ -226,7 +227,12 @@ func (d *db) keepConnectionAlive(driver string, dsn string, config *DBConfig) { } if err != nil || aDb == nil { + fmt.Printf("[INFO] %v database connection lost, reconnecting\n", driver) newDb, err := sql.Open(driver, dsn) + if err != nil { + fmt.Printf("[INFO] couldn't open new %v database \n", driver) + continue + } d.mutex.Lock() d.actual = newDb if newDb != nil { @@ -234,10 +240,11 @@ func (d *db) keepConnectionAlive(driver string, dsn string, config *DBConfig) { } d.mutex.Unlock() - ctx, timeout := d.ctxWithTimeout(time.Duration(5) * time.Second) + toSecs := 5 + ctx, timeout := d.ctxWithTimeout(time.Duration(toSecs) * time.Second) err = newDb.PingContext(ctx) if err != nil { - fmt.Printf("[INFO] couldn't connect to one of %v database \n", driver) + fmt.Printf("[INFO] couldn't ping new %v database after %d seconds\n", driver, toSecs) } timeout() diff --git a/view/resource.go b/view/resource.go index b1867d19..0abf0593 100644 --- a/view/resource.go +++ b/view/resource.go @@ -4,6 +4,12 @@ import ( "context" "embed" "fmt" + "path" + "reflect" + "strings" + "sync" + "time" + "github.com/viant/afs" "github.com/viant/afs/file" "github.com/viant/afs/storage" @@ -19,11 +25,6 @@ import ( "github.com/viant/xdatly/predicate" "github.com/viant/xreflect" "gopkg.in/yaml.v3" - "path" - "reflect" - "strings" - "sync" - "time" ) const ( @@ -191,6 +192,9 @@ func (r *Resource) loadText(ctx context.Context, URL string, expand bool) (strin embedFs = r.FSEmbedder.EmbedFS() } data, err := fs.DownloadWithURL(ctx, URL, embedFs) + if err != nil { + return "", err + } if err = r.UpdateTime(ctx, URL); err != nil { return "", err