S3 replica

This commit is contained in:
Ben Johnson
2021-01-13 10:14:54 -07:00
parent faa5765745
commit 57a02a8628
7 changed files with 940 additions and 28 deletions

13
db.go
View File

@@ -117,6 +117,11 @@ func NewDB(path string) *DB {
return db
}
// SQLDB returns a reference to the underlying sql.DB connection.
func (db *DB) SQLDB() *sql.DB {
return db.db
}
// Path returns the path to the database.
func (db *DB) Path() string {
return db.path
@@ -181,7 +186,7 @@ func (db *DB) CurrentShadowWALIndex(generation string) (index int, size int64, e
if !strings.HasSuffix(fi.Name(), WALExt) {
continue
}
if v, _, _, err := ParseWALPath(fi.Name()); err != nil {
if v, _, _, _, err := ParseWALPath(fi.Name()); err != nil {
continue // invalid wal filename
} else if v > index {
index = v
@@ -478,7 +483,7 @@ func (db *DB) cleanWAL() error {
return err
}
for _, fi := range fis {
if idx, _, _, err := ParseWALPath(fi.Name()); err != nil || idx >= min {
if idx, _, _, _, err := ParseWALPath(fi.Name()); err != nil || idx >= min {
continue
}
if err := os.Remove(filepath.Join(dir, fi.Name())); err != nil {
@@ -858,7 +863,7 @@ func (db *DB) syncWAL(info syncInfo) (newSize int64, err error) {
// Parse index of current shadow WAL file.
dir, base := filepath.Split(info.shadowWALPath)
index, _, _, err := ParseWALPath(base)
index, _, _, _, err := ParseWALPath(base)
if err != nil {
return 0, fmt.Errorf("cannot parse shadow wal filename: %s", base)
}
@@ -1217,7 +1222,7 @@ func (db *DB) checkpointAndInit(info syncInfo, mode string) error {
}
// Parse index of current shadow WAL file.
index, _, _, err := ParseWALPath(info.shadowWALPath)
index, _, _, _, err := ParseWALPath(info.shadowWALPath)
if err != nil {
return fmt.Errorf("cannot parse shadow wal filename: %s", info.shadowWALPath)
}