mirror of
https://github.com/guggero/chantools
synced 2024-11-11 01:10:42 +00:00
lnd+walletinfo: return more verbose error on DB timeout
Fixes #18. Any bbolt database has a unique lock, meaning it cannot be opened by two processes at the same time. The simple "timeout" error that is returned if opening fails is not very informative though.
This commit is contained in:
parent
af356685c1
commit
994b669a0c
@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"go.etcd.io/bbolt"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -140,6 +141,11 @@ func (c *walletInfoCommand) Execute(_ *cobra.Command, _ []string) error {
|
|||||||
"bdb", lncfg.CleanAndExpandPath(c.WalletDB), false,
|
"bdb", lncfg.CleanAndExpandPath(c.WalletDB), false,
|
||||||
lnd.DefaultOpenTimeout,
|
lnd.DefaultOpenTimeout,
|
||||||
)
|
)
|
||||||
|
if err == bbolt.ErrTimeout {
|
||||||
|
return fmt.Errorf("error opening wallet database, make sure " +
|
||||||
|
"lnd is not running and holding the exclusive lock " +
|
||||||
|
"on the wallet")
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error opening wallet database: %v", err)
|
return fmt.Errorf("error opening wallet database: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package lnd
|
package lnd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
@ -16,6 +17,11 @@ const (
|
|||||||
|
|
||||||
func OpenDB(dbPath string, readonly bool) (*channeldb.DB, error) {
|
func OpenDB(dbPath string, readonly bool) (*channeldb.DB, error) {
|
||||||
backend, err := openDB(dbPath, false, readonly, DefaultOpenTimeout)
|
backend, err := openDB(dbPath, false, readonly, DefaultOpenTimeout)
|
||||||
|
if err == bbolt.ErrTimeout {
|
||||||
|
return nil, fmt.Errorf("error opening %s: make sure lnd is "+
|
||||||
|
"not running, database is locked by another process",
|
||||||
|
dbPath)
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user