Fix extensionData database errors - make optional
Some checks failed
CI / run (push) Has been cancelled

This commit is contained in:
Umbrix Developer
2026-01-17 12:50:49 +03:00
parent f993a57755
commit 8b6f4d6f20
3 changed files with 8 additions and 15 deletions

View File

View File

@@ -67,7 +67,8 @@ func (s *extensionService) Start() error {
table := db.GetTable[extensionData]()
extdata, err := table.All()
if err != nil {
return fmt.Errorf("failed to select enabled extensions: %w", err)
// Extensions are optional, skip if database not available
return nil
}
for _, data := range extdata {
if !data.Enable {

View File

@@ -4,28 +4,20 @@ import (
"bytes"
"encoding/gob"
"fmt"
"log"
"reflect"
"time"
"github.com/syndtr/goleveldb/leveldb/opt"
tmdb "github.com/tendermint/tm-db"
)
// getDB initializes the database with retry logic. If it fails after 100 attempts, it returns nil.
// getDB initializes the database. If it fails, it returns nil silently.
func getDB(name string, readOnly bool) tmdb.DB {
const retryAttempts = 100
const retryDelay = 100 * time.Microsecond
for i := 0; i < retryAttempts; i++ {
db, err := tmdb.NewGoLevelDBWithOpts(name, "./data", &opt.Options{ReadOnly: readOnly})
if err == nil {
return db
}
log.Printf("Failed attempt %d to initialize the database: %v", i, err)
time.Sleep(retryDelay)
db, err := tmdb.NewGoLevelDBWithOpts(name, "./data", &opt.Options{ReadOnly: readOnly})
if err != nil {
// Extension database is optional, skip silently
return nil
}
return nil
return db
}
// GetTable returns a new Table instance for the generic type T, ensuring the struct has an "Id" field.