mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-10-06 19:07:50 +00:00
replace pilosa.DefaultTxsrc with storage.DefaultBackend
This commit is contained in:
parent
08fae2be4c
commit
f292d6061a
8 changed files with 27 additions and 42 deletions
|
|
@ -18,7 +18,6 @@ import (
|
|||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/pilosa/pilosa/v2"
|
||||
"github.com/pilosa/pilosa/v2/server"
|
||||
"github.com/pilosa/pilosa/v2/storage"
|
||||
"github.com/spf13/cobra"
|
||||
|
|
@ -106,7 +105,7 @@ func BuildServerFlags(cmd *cobra.Command, srv *server.Command) {
|
|||
// Transactional storage engine
|
||||
// Note: the default for --tx must be kept "" empty string. Otherwise we
|
||||
// cannot detect and honor the PILOSA_TXSRC env var over-ride.
|
||||
flags.StringVarP(&srv.Config.Txsrc, "txsrc", "", "", fmt.Sprintf("transaction/storage to use: one of roaring, rbf, bolt, or a blue-green setup: rbf_roaring, roaring_rbf, bolt_roaring, roaring_bolt, bolt_rbf, etc. The default is: %v. The env var PILOSA_TXSRC is over-ridden by --txsrc option on the command line.", pilosa.DefaultTxsrc))
|
||||
flags.StringVarP(&srv.Config.Txsrc, "txsrc", "", "", fmt.Sprintf("transaction/storage to use: one of roaring, rbf, bolt, or a blue-green setup: rbf_roaring, roaring_rbf, bolt_roaring, roaring_bolt, bolt_rbf, etc. The default is: %v. The env var PILOSA_TXSRC is over-ridden by --txsrc option on the command line.", storage.DefaultBackend))
|
||||
|
||||
// Storage
|
||||
// Note: the default for --storage.backend must be kept "" empty string.
|
||||
|
|
|
|||
|
|
@ -540,7 +540,7 @@ func TestExecutor_Execute_Count(t *testing.T) {
|
|||
|
||||
func roaringOnlyTest(t *testing.T) {
|
||||
src := os.Getenv("PILOSA_TXSRC")
|
||||
if src == pilosa.RoaringTxn || (pilosa.DefaultTxsrc == pilosa.RoaringTxn && src == "") {
|
||||
if src == pilosa.RoaringTxn || (storage.DefaultBackend == pilosa.RoaringTxn && src == "") {
|
||||
// okay to run, we are under roaring only
|
||||
} else {
|
||||
t.Skip("skip for everything but roaring")
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ import (
|
|||
"github.com/davecgh/go-spew/spew"
|
||||
"github.com/pilosa/pilosa/v2/pql"
|
||||
"github.com/pilosa/pilosa/v2/roaring"
|
||||
"github.com/pilosa/pilosa/v2/storage"
|
||||
"github.com/pilosa/pilosa/v2/testhook"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/sync/errgroup"
|
||||
|
|
@ -1720,7 +1721,7 @@ func TestFragment_RankCache_Persistence(t *testing.T) {
|
|||
|
||||
func roaringOnlyTest(t *testing.T) {
|
||||
src := os.Getenv("PILOSA_TXSRC")
|
||||
if src == RoaringTxn || (DefaultTxsrc == RoaringTxn && src == "") {
|
||||
if src == RoaringTxn || (storage.DefaultBackend == RoaringTxn && src == "") {
|
||||
// okay to run, we are under roaring only
|
||||
} else {
|
||||
t.Skip("skip for everything but roaring")
|
||||
|
|
@ -1729,7 +1730,7 @@ func roaringOnlyTest(t *testing.T) {
|
|||
|
||||
func roaringOnlyBenchmark(b *testing.B) {
|
||||
src := os.Getenv("PILOSA_TXSRC")
|
||||
if src == RoaringTxn || (DefaultTxsrc == RoaringTxn && src == "") {
|
||||
if src == RoaringTxn || (storage.DefaultBackend == RoaringTxn && src == "") {
|
||||
// okay to run, we are under roaring only
|
||||
} else {
|
||||
b.Skip("skip for everything but roaring")
|
||||
|
|
|
|||
14
pprof.go
14
pprof.go
|
|
@ -22,14 +22,18 @@ import (
|
|||
"time"
|
||||
|
||||
_ "net/http/pprof" // Imported for its side-effect of registering pprof endpoints with the server.
|
||||
|
||||
"github.com/pilosa/pilosa/v2/storage"
|
||||
)
|
||||
|
||||
// CPUProfileForDur (where "Dur" is short for "Duration"), is used for
|
||||
// performance tuning during development. It's only called—but is currently
|
||||
// commented out—in holder.go.
|
||||
func CPUProfileForDur(dur time.Duration, outpath string) {
|
||||
|
||||
// per-query pprof output:
|
||||
txsrc := os.Getenv("PILOSA_TXSRC")
|
||||
if txsrc == "" {
|
||||
txsrc = DefaultTxsrc
|
||||
txsrc = storage.DefaultBackend
|
||||
}
|
||||
path := outpath + "." + txsrc
|
||||
f, err := os.Create(path)
|
||||
|
|
@ -48,12 +52,14 @@ func CPUProfileForDur(dur time.Duration, outpath string) {
|
|||
}()
|
||||
}
|
||||
|
||||
// MemProfileForDur (where "Dur" is short for "Duration"), is used for
|
||||
// performance tuning during development. It's only called—but is currently
|
||||
// commented out—in holder.go.
|
||||
func MemProfileForDur(dur time.Duration, outpath string) {
|
||||
|
||||
// per-query pprof output:
|
||||
txsrc := os.Getenv("PILOSA_TXSRC")
|
||||
if txsrc == "" {
|
||||
txsrc = DefaultTxsrc
|
||||
txsrc = storage.DefaultBackend
|
||||
}
|
||||
path := outpath + "." + txsrc
|
||||
f, err := os.Create(path)
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ import (
|
|||
"github.com/pilosa/pilosa/v2/statik"
|
||||
"github.com/pilosa/pilosa/v2/stats"
|
||||
"github.com/pilosa/pilosa/v2/statsd"
|
||||
"github.com/pilosa/pilosa/v2/storage"
|
||||
"github.com/pilosa/pilosa/v2/syswrap"
|
||||
"github.com/pilosa/pilosa/v2/testhook"
|
||||
"github.com/pkg/errors"
|
||||
|
|
@ -291,17 +292,17 @@ func (m *Command) SetupServer() error {
|
|||
envTxsrc := os.Getenv("PILOSA_TXSRC")
|
||||
if m.Config.Txsrc == "" {
|
||||
// INVAR: No -tx flag on the command line.
|
||||
// We defer to the environment, and then the DefaultTxsrc
|
||||
// We defer to the environment, and then the DefaultBackend
|
||||
if envTxsrc == "" {
|
||||
// no env variable requested either.
|
||||
m.Config.Txsrc = pilosa.DefaultTxsrc
|
||||
m.Config.Txsrc = storage.DefaultBackend
|
||||
} else {
|
||||
// Tell the "regular" prod server what to use.
|
||||
m.Config.Txsrc = envTxsrc
|
||||
}
|
||||
}
|
||||
// INVAR: m.Config.Txsrc is valid and not "", but pilosa.DefaultTxsrc could be bad.
|
||||
txty := pilosa.MustTxsrcToTxtype(m.Config.Txsrc) // will panic on unknown Txsrc.
|
||||
// INVAR: m.Config.Storage.Backend is valid and not "", but storage.DefaultBackend could be bad.
|
||||
txty := pilosa.MustTxsrcToTxtype(m.Config.Storage.Backend) // will panic on unknown Backend.
|
||||
os.Setenv("PILOSA_TXSRC", m.Config.Txsrc)
|
||||
m.logger.Printf("using Txsrc '%v'/%v", m.Config.Txsrc, txty)
|
||||
if len(txty) == 2 {
|
||||
|
|
|
|||
25
stattx.go
25
stattx.go
|
|
@ -24,9 +24,9 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/pilosa/pilosa/v2/debugstats"
|
||||
"github.com/pilosa/pilosa/v2/roaring"
|
||||
txkey "github.com/pilosa/pilosa/v2/short_txkey"
|
||||
//txkey "github.com/pilosa/pilosa/v2/txkey"
|
||||
)
|
||||
|
||||
// statTx is useful to profile on a
|
||||
|
|
@ -69,29 +69,12 @@ func (w *callStats) reset() {
|
|||
}
|
||||
}
|
||||
|
||||
type LineSorter struct {
|
||||
Line string
|
||||
Tot float64
|
||||
}
|
||||
|
||||
type SortByTot []*LineSorter
|
||||
|
||||
func (p SortByTot) Len() int {
|
||||
return len(p)
|
||||
}
|
||||
func (p SortByTot) Less(i, j int) bool {
|
||||
return p[i].Tot < p[j].Tot
|
||||
}
|
||||
func (p SortByTot) Swap(i, j int) {
|
||||
p[i], p[j] = p[j], p[i]
|
||||
}
|
||||
|
||||
func (c *callStats) report() (r string) {
|
||||
txsrc := os.Getenv("PILOSA_TXSRC")
|
||||
r = fmt.Sprintf("callStats: (%v)\n", txsrc)
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
var lines []*LineSorter
|
||||
var lines []*debugstats.LineSorter
|
||||
for i := kall(0); i < kLast; i++ {
|
||||
slc := c.elap[i].dur
|
||||
n := len(slc)
|
||||
|
|
@ -105,9 +88,9 @@ func (c *callStats) report() (r string) {
|
|||
totaltm = slc[0]
|
||||
}
|
||||
line := fmt.Sprintf(" %20v N=%8v avg/op: %12v sd: %12v total: %12v\n", i.String(), n, time.Duration(mean), time.Duration(sd), time.Duration(totaltm))
|
||||
lines = append(lines, &LineSorter{Line: line, Tot: totaltm})
|
||||
lines = append(lines, &debugstats.LineSorter{Line: line, Tot: totaltm})
|
||||
}
|
||||
sort.Sort(SortByTot(lines))
|
||||
sort.Sort(debugstats.SortByTot(lines))
|
||||
for i := range lines {
|
||||
r += lines[i].Line
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import (
|
|||
"github.com/pilosa/pilosa/v2"
|
||||
"github.com/pilosa/pilosa/v2/http"
|
||||
"github.com/pilosa/pilosa/v2/server"
|
||||
"github.com/pilosa/pilosa/v2/storage"
|
||||
"github.com/pilosa/pilosa/v2/test"
|
||||
)
|
||||
|
||||
|
|
@ -61,9 +62,9 @@ func queryBalances(m0api *pilosa.API, acctOwnerID uint64, fldAcct0, fldAcct1, in
|
|||
|
||||
func skipForRoaring(t *testing.T) {
|
||||
src := os.Getenv("PILOSA_TXSRC")
|
||||
// once txfactory.go DefaultTxsrc != RoaringTxn, this
|
||||
// once txfactory.go storage.DefaultBackend != RoaringTxn, this
|
||||
// will break, of course. Take out the src == "" below.
|
||||
if (src == "" && pilosa.DefaultTxsrc == pilosa.RoaringTxn) || strings.Contains(src, "roaring") {
|
||||
if (src == "" && storage.DefaultBackend == pilosa.RoaringTxn) || strings.Contains(src, "roaring") {
|
||||
t.Skip("skip if roaring pseudo-txn involved -- won't show transactional rollback")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ import (
|
|||
"github.com/pilosa/pilosa/v2/roaring"
|
||||
txkey "github.com/pilosa/pilosa/v2/short_txkey"
|
||||
"github.com/pilosa/pilosa/v2/storage"
|
||||
//txkey "github.com/pilosa/pilosa/v2/txkey"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/zeebo/blake3"
|
||||
)
|
||||
|
|
@ -43,11 +42,6 @@ const (
|
|||
BoltTxn string = "bolt"
|
||||
)
|
||||
|
||||
// DefaultTxsrc is set here. pilosa/server/config.go references it
|
||||
// to set the default for pilosa server exeutable.
|
||||
// Can be overridden with env variable PILOSA_TXSRC for testing.
|
||||
const DefaultTxsrc = RoaringTxn
|
||||
|
||||
// DetectMemAccessPastTx true helps us catch places in api and executor
|
||||
// where mmapped memory is being accessed after the point in time
|
||||
// which the transaction has committed or rolled back. Since
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue