Fix db lookup for wal file
This commit is contained in:
8
db.go
8
db.go
@@ -244,7 +244,13 @@ func (db *DB) shadowWALExists() (bool, error) {
|
|||||||
// contents of the database page.
|
// contents of the database page.
|
||||||
func (db *DB) recoverShadowWALOnly() error {
|
func (db *DB) recoverShadowWALOnly() error {
|
||||||
db.logger.Printf("recovering: shadow WAL only")
|
db.logger.Printf("recovering: shadow WAL only")
|
||||||
panic("TODO")
|
|
||||||
|
// TODO: Verify last page in shadow WAL matches data in DB.
|
||||||
|
|
||||||
|
db.processedWALByteN = 0
|
||||||
|
db.pendingWALByteN = 0
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// recoverRealAndShadowWALs verifies the last page of the real & shadow WALs match.
|
// recoverRealAndShadowWALs verifies the last page of the real & shadow WALs match.
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
package litestream
|
package litestream
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"sort"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"bazil.org/fuse/fs"
|
"bazil.org/fuse/fs"
|
||||||
@@ -71,12 +73,24 @@ func (f *FileSystem) Open() error {
|
|||||||
|
|
||||||
// DB returns the DB object associated with path.
|
// DB returns the DB object associated with path.
|
||||||
func (f *FileSystem) DB(path string) *DB {
|
func (f *FileSystem) DB(path string) *DB {
|
||||||
|
fmt.Println("dbg/dbs", path, "--", f.DBPaths())
|
||||||
|
|
||||||
f.mu.RLock()
|
f.mu.RLock()
|
||||||
defer f.mu.RUnlock()
|
defer f.mu.RUnlock()
|
||||||
db := f.dbs[path]
|
db := f.dbs[path]
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DBPaths returns a sorted list of all paths managed by the file system.
|
||||||
|
func (f *FileSystem) DBPaths() []string {
|
||||||
|
a := make([]string, 0, len(f.dbs))
|
||||||
|
for k := range f.dbs {
|
||||||
|
a = append(a, k)
|
||||||
|
}
|
||||||
|
sort.Strings(a)
|
||||||
|
return a
|
||||||
|
}
|
||||||
|
|
||||||
// OpenDB initializes a DB for a given path.
|
// OpenDB initializes a DB for a given path.
|
||||||
func (f *FileSystem) OpenDB(path string) error {
|
func (f *FileSystem) OpenDB(path string) error {
|
||||||
f.mu.Lock()
|
f.mu.Lock()
|
||||||
|
|||||||
5
node.go
5
node.go
@@ -64,9 +64,12 @@ func (n *Node) IsWAL() bool {
|
|||||||
// DB returns the DB object associated with the node, if any.
|
// DB returns the DB object associated with the node, if any.
|
||||||
// If node points to a "-wal" file then the associated DB is returned.
|
// If node points to a "-wal" file then the associated DB is returned.
|
||||||
func (n *Node) DB() *DB {
|
func (n *Node) DB() *DB {
|
||||||
if strings.HasPrefix(n.path, sqlite.WALSuffix) {
|
println("dbg/node.db", n.path, strings.HasPrefix(n.path, sqlite.WALSuffix))
|
||||||
|
if strings.HasSuffix(n.path, sqlite.WALSuffix) {
|
||||||
|
println("dbg/node.db.trim", n.path, strings.TrimSuffix(n.path, sqlite.WALSuffix))
|
||||||
return n.fs.DB(strings.TrimSuffix(n.path, sqlite.WALSuffix))
|
return n.fs.DB(strings.TrimSuffix(n.path, sqlite.WALSuffix))
|
||||||
}
|
}
|
||||||
|
println("dbg/node.db.other", n.path)
|
||||||
return n.fs.DB(n.path)
|
return n.fs.DB(n.path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user