mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-07 09:05:55 +00:00
Merge pull request #157 from travisturner/int-fragment-sync-quick-fix
temporary fix for int field replica sync bug
This commit is contained in:
commit
cdbb274a2b
3 changed files with 61 additions and 0 deletions
10
holder.go
10
holder.go
|
|
@ -911,6 +911,16 @@ func (s *holderSyncer) syncFragment(index, field, view string, shard uint64) err
|
|||
return ErrFieldNotFound
|
||||
}
|
||||
|
||||
// TODO: this is a temporary fix put in place to prevent
|
||||
// the syncer from trying to sync replicas of fields
|
||||
// other than `set` or `time` (i.e. `int`, `mutex`, `bool`,
|
||||
// `decimal`) using ImportRoaring, because ImportRoaring
|
||||
// only supports `set` and `time` fields.
|
||||
if f.Type() != FieldTypeSet && f.Type() != FieldTypeTime {
|
||||
s.Holder.Logger.Printf("temporarily skipping fragment sync: %s/%d", field, shard)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Ensure view exists locally.
|
||||
v, err := f.createViewIfNotExists(view)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -523,3 +523,40 @@ func TestHolderSyncer_TimeQuantum(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure holder can sync integer views with a remote holder.
|
||||
func TestHolderSyncer_IntField(t *testing.T) {
|
||||
c := test.MustNewCluster(t, 2)
|
||||
c[0].Config.Cluster.ReplicaN = 2
|
||||
c[0].Config.AntiEntropy.Interval = 0
|
||||
c[1].Config.Cluster.ReplicaN = 2
|
||||
c[1].Config.AntiEntropy.Interval = 0
|
||||
err := c.Start()
|
||||
if err != nil {
|
||||
t.Fatalf("starting cluster: %v", err)
|
||||
}
|
||||
defer c.Close()
|
||||
|
||||
_, err = c[0].API.CreateIndex(context.Background(), "i", pilosa.IndexOptions{})
|
||||
if err != nil {
|
||||
t.Fatalf("creating index i: %v", err)
|
||||
}
|
||||
_, err = c[0].API.CreateField(context.Background(), "i", "f", pilosa.OptFieldTypeInt(0, 100))
|
||||
if err != nil {
|
||||
t.Fatalf("creating field f: %v", err)
|
||||
}
|
||||
|
||||
hldr0 := &test.Holder{Holder: c[0].Server.Holder()}
|
||||
hldr1 := &test.Holder{Holder: c[1].Server.Holder()}
|
||||
|
||||
// Set data on the local holder for node0.
|
||||
hldr0.SetValue("i", "f", 1, 1)
|
||||
|
||||
// Set data on node1.
|
||||
hldr1.SetValue("i", "f", 2, 2)
|
||||
|
||||
err = c[0].Server.SyncData()
|
||||
if err != nil {
|
||||
t.Fatalf("syncing node 0: %v", err)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ package test
|
|||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"math"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
|
|
@ -165,3 +166,16 @@ func (h *Holder) MustSetBits(index, field string, rowID uint64, columnIDs ...uin
|
|||
h.SetBit(index, field, rowID, columnID)
|
||||
}
|
||||
}
|
||||
|
||||
// SetValue sets an value on the given field.
|
||||
func (h *Holder) SetValue(index, field string, columnID uint64, value int64) {
|
||||
idx := h.MustCreateIndexIfNotExists(index, pilosa.IndexOptions{})
|
||||
f, err := idx.CreateFieldIfNotExists(field, pilosa.OptFieldTypeInt(math.MinInt64, math.MaxInt64))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
_, err = f.SetValue(columnID, value)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue