MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / verifyFailoverLog

Method verifyFailoverLog

base/dcp_client.go:551–567  ·  view source on GitHub ↗

verifyFailoverLog checks for VbUUID changes when failOnRollback is set, and writes the failover log to the client metadata store. If previous VbUUID is zero, it's not considered a rollback - it's not required to initialize vbUUIDs into meta.

(vbID uint16, f []gocbcore.FailoverEntry)

Source from the content-addressed store, hash-verified

549// writes the failover log to the client metadata store. If previous VbUUID is zero, it's
550// not considered a rollback - it's not required to initialize vbUUIDs into meta.
551func (dc *DCPClient) verifyFailoverLog(vbID uint16, f []gocbcore.FailoverEntry) error {
552
553 if dc.failOnRollback {
554 previousMeta := dc.metadata.GetMeta(vbID)
555 // Cases where VbUUID and StartSeqNo aren't set aren't considered rollback
556 if previousMeta.VbUUID == 0 && previousMeta.StartSeqNo == 0 {
557 return nil
558 }
559
560 currentVbUUID := getLatestVbUUID(f)
561 // if previousVbUUID hasn't been set yet (is zero), don't treat as rollback.
562 if previousMeta.VbUUID != currentVbUUID {
563 return ErrVbUUIDMismatch
564 }
565 }
566 return nil
567}
568
569func (dc *DCPClient) deactivateVbucket(vbID uint16) {
570 dc.activeVbucketLock.Lock()

Callers 1

openStreamRequestMethod · 0.95

Calls 2

getLatestVbUUIDFunction · 0.85
GetMetaMethod · 0.65

Tested by

no test coverage detected