-
Notifications
You must be signed in to change notification settings - Fork 72
Gossip DB fault tolerance #344
Gossip DB fault tolerance #344
Conversation
gossip/store.go
Outdated
// setDirty sets dirty flag. | ||
func (s *Store) setDirty(flag bool) { | ||
key := []byte("is_dirty") | ||
val := make([]byte, 1, 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
S1019: should use make([]byte, 1) instead (from gosimple
)
… flushable.SyncedPool syncs flush of flushables
kvdb/flushable/synced_pool.go
Outdated
if prevId == nil { | ||
prevId = &mark | ||
} | ||
if bytes.Compare(mark, *prevId) != 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
S1004: should use !bytes.Equal(mark, *prevId) instead (from gosimple
)
@@ -188,7 +188,7 @@ func (p *Poset) ProcessEvent(e *inter.Event) (err error) { | |||
if err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- remove defer func and move the commit to the end.
- on err, add a debug log instead of quietly return.
gossip/store.go
Outdated
s.Log.Crit("Failed to get value", "err", err) | ||
} | ||
|
||
return len(val) > 1 && val[0] != 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
len(val) > 0 && val[0] ==1
kvdb/super_db/super_db.go
Outdated
@@ -226,8 +257,11 @@ func (sdb *SuperDb) FlushIfNeeded(id hash.Event) bool { | |||
|
|||
// call on startup, after all dbs are registered | |||
func (sdb *SuperDb) CheckDbsSynced() error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- add comment to the function.
- Compare the flag values across barDbs?
kvdb/super_db/super_db.go
Outdated
key := []byte("flag") | ||
var prevId *hash.Event | ||
var prevId *[]byte | ||
for _, db := range sdb.bareDbs { | ||
mark, err := db.Get(key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change mark to eventId
kvdb/super_db/super_db.go
Outdated
} | ||
|
||
func (sdb *SuperDb) DropDb(name string) { | ||
if db := sdb.bareDbs[name]; db == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add log
defer func() { | ||
if err != nil { | ||
return | ||
} | ||
err = p.store.Commit() | ||
immediately := (p.EpochN != was) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ineffectual assignment to immediately
(from ineffassign
)
Merge pull request #344 from sfxdxdev/gossip-fault-tolerance
Commits whole DB after event connecting.
Detects DB-dirty flag on start.