lib: Remove USE_BADGER experiment (#7089)

This removes the switch for using a Badger database, because it has bugs
that it seems there is no interest in fixing, and no actual bug tracker
to track them in.

It retains the actual implementation for the sole purpose of being able
to do the conversion back to LevelDB if anyone is actually running with
USE_BADGER. At some point in a couple of versions we can remove the
implementation as well.
This commit is contained in:
Jakob Borg 2020-11-03 09:10:35 +01:00 committed by GitHub
parent 5b9280c50f
commit 7892547873
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 1 additions and 23 deletions

View File

@ -43,7 +43,6 @@ var (
"STHASHING", "STHASHING",
"STNORESTART", "STNORESTART",
"STNOUPGRADE", "STNOUPGRADE",
"USE_BADGER",
} }
) )

View File

@ -131,24 +131,14 @@ const (
) )
func Open(path string, tuning Tuning) (Backend, error) { func Open(path string, tuning Tuning) (Backend, error) {
if os.Getenv("USE_BADGER") != "" {
l.Warnln("Using experimental badger db")
if err := maybeCopyDatabase(path, strings.Replace(path, locations.BadgerDir, locations.LevelDBDir, 1), OpenBadger, OpenLevelDBRO); err != nil {
return nil, err
}
return OpenBadger(path)
}
if err := maybeCopyDatabase(path, strings.Replace(path, locations.LevelDBDir, locations.BadgerDir, 1), OpenLevelDBAuto, OpenBadger); err != nil { if err := maybeCopyDatabase(path, strings.Replace(path, locations.LevelDBDir, locations.BadgerDir, 1), OpenLevelDBAuto, OpenBadger); err != nil {
return nil, err return nil, err
} }
return OpenLevelDB(path, tuning) return OpenLevelDB(path, tuning)
} }
func OpenMemory() Backend { func OpenMemory() Backend {
if os.Getenv("USE_BADGER") != "" {
return OpenBadgerMemory()
}
return OpenLevelDBMemory() return OpenLevelDBMemory()
} }

View File

@ -10,7 +10,6 @@ import (
"bytes" "bytes"
"context" "context"
"fmt" "fmt"
"os"
"testing" "testing"
"github.com/syncthing/syncthing/lib/db/backend" "github.com/syncthing/syncthing/lib/db/backend"
@ -801,11 +800,6 @@ func TestFlushRecursion(t *testing.T) {
// Verify that a commit hook can write to the transaction without // Verify that a commit hook can write to the transaction without
// causing another flush and thus recursion. // causing another flush and thus recursion.
// Badger doesn't work like this.
if os.Getenv("USE_BADGER") != "" {
t.Skip("Not supported on Badger")
}
db := NewLowlevel(backend.OpenMemory()) db := NewLowlevel(backend.OpenMemory())
defer db.Close() defer db.Close()

View File

@ -53,11 +53,6 @@ const (
var baseDirs = make(map[BaseDirEnum]string, 3) var baseDirs = make(map[BaseDirEnum]string, 3)
func init() { func init() {
if os.Getenv("USE_BADGER") != "" {
// XXX: Replace the leveldb name with the badger name.
locationTemplates[Database] = strings.Replace(locationTemplates[Database], LevelDBDir, BadgerDir, 1)
}
userHome := userHomeDir() userHome := userHomeDir()
config := defaultConfigDir(userHome) config := defaultConfigDir(userHome)
baseDirs[UserHomeBaseDir] = userHome baseDirs[UserHomeBaseDir] = userHome