You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
endSeqNosmap[uint16]uint64// endSeqNos mark the sequence numbers keyed by vBucket ID that are the end sequence numbers for a stream
63
64
}
64
65
65
-
// NewDCPCommon creates a new DCPCommon which manages updates coming from a cbgt-based DCP feed. The callback function will receive events from a DCP feed. It stores checkpoints in the metaStore starting with checkpointPrefix if persistCheckpoints is true.
66
-
// Specific stats for DCP are stored in expvars rather than SgwStats.
66
+
// NewDCPCommon creates a new DCPCommon instance which manages updates coming from a cbgt-based DCP feed.
// rollbackEx is called when a DCP open stream issues a rollback. The metadata persisted for a given uuid and sequence number and stream reopening is deferred to cbgt via AutoReconnectAfterRollback feed parameter.
// shouldProcessSequence checks the incoming sequence number against the expected end sequence number, and returns true
222
+
// if this sequence number is expected.
223
+
//
224
+
// The expected sequences that should not be processed are sequences between the end sequence and any sequences to the end of that sequence's snapshot.
// Check the expected maximum sequence number when running a one shot feed. Do not checkpoint if the incoming
230
+
// sequence is greater than the expected maximum sequence number.
231
+
//
232
+
// DCP will provide mutations that run to the end of the snapshot that contains the end sequence number.
233
+
endSeq, ok:=c.endSeqNos[vBucketID]
234
+
if!ok {
235
+
AssertfCtx(c.loggingCtx, "Received DCP event for vbno %d which is not tracked by the expected endSeqNos %#+v. This means that endSeqNos was specified with the incorrect number of vBuckets. Processing this sequence anyway", vBucketID, c.endSeqNos)
236
+
returntrue
237
+
}
238
+
returnseq<=endSeq
239
+
}
240
+
220
241
// This updates the value stored in r.seqs with the given seq number for the given partition
221
242
// Setting warnOnLowerSeqNo to true will check
222
243
// if we are setting the seq number to a _lower_ value than we already have stored for that
223
244
// vbucket and log a warning in that case. The valid case for setting warnOnLowerSeqNo to
224
245
// false is when it's a rollback scenario. See https://github.com/couchbase/sync_gateway/issues/1098 for dev notes.
Copy file name to clipboardExpand all lines: base/dcp_dest.go
+43-14Lines changed: 43 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -30,6 +30,7 @@ func init() {
30
30
typeSGDestinterface {
31
31
cbgt.Dest
32
32
cbgt.DestEx
33
+
ForceCheckpointWrite()
33
34
}
34
35
35
36
// DCPDest implements SGDest (superset of cbgt.Dest) interface to manage updates coming from a
@@ -41,28 +42,32 @@ type DCPDest struct {
41
42
metaInitComplete []bool// Whether metadata initialization has been completed, per vbNo
42
43
}
43
44
44
-
// NewDCPDest creates a new DCPDest which manages updates coming from a cbgt-based DCP feed. The callback function will receive events from a DCP feed. If persistCheckpoints is true, stores checkpoints as documents in metadataStore starting with checkpointPrefix.
45
-
// Specific stats for DCP are stored in expvars rather than SgwStats, except for partition stat, which indicates the number of cbgt partitions assigned to this node.
45
+
typeDCPDestOptionsstruct {
46
+
Callback sgbucket.FeedEventCallbackFunc// Callback function receives DCP events.
47
+
MetadataStore sgbucket.DataStore// location to store checkpoints in
48
+
MaxVbNouint16// number of vBuckets for the backing bucket (does not have to match metadata store)
49
+
PersistCheckpointsbool// if true, write checkpoints to MetadataStore with keys prefixed by CheckpointPrefix
50
+
DcpStats*expvar.Map// Optional stats for dcp_rollback_count. This is not exposed by prometheus.
51
+
PartitionStat*SgwIntStat// Optional stat for active partition count, to track cbgt partitions.
52
+
CheckpointPrefixstring// document prefix for checkpoint documents.
53
+
EndSeqNosmap[uint16]uint64// If running a one shot DCP feed, these should match the end sequence numbers for each vbNo.
54
+
}
55
+
56
+
// NewDCPDest creates a new DCPDest which manages updates coming from a cbgt-based DCP feed.
46
57
// Each partition will have its own DCPDest object.
// cbgtFeedParams returns marshalled cbgt.DCPFeedParams as string. This contains information to for a given information , to be passed as feedparams during cbgt.Manager init.
unregisterFeedCallbackfunc(cbgt.Feed) // callback function for when a feed is unregistered. This occurs when a feed completes for any reason: Stop is requested, a rebalance of partitions, the feed naturally ends when reaching expected seequence numbers.
0 commit comments