Cache: Received (unused sequence) Log on Sync Gateway

I’m seeing odd messages in the SG Log file with * logging.

“Cache: Received #… (unused sequence)”

What does this message mean?

Any info would be appreciated.

“Unused Sequences” backstory:

When Sync Gateway creates new Couchbase Server docs, it must allocate a unique, monotonically increasing sequence number for each document from a global sequence counter.

Sometimes, however, it will allocate a sequence but it will never end up being used. For example if it allocates sequence 63 while trying to save a doc with ID=foo, however another Sync Gateway writes a doc with the same ID in the meantime, the save operation will fail and sequence 63 will never be used.

When the “changes cache” (which stores a local cache of items on changes feeds) sees these unused sequences on the DCP feed, it will emit that log entry.

It looks harmless and would be expected to happen under normal usage.

@traun We are also getting same messages “Cache: Received #… (unused sequence)” in syncgateway logs. Due to these,document mutations are arriving delay in _changes feed.
We did not observed any failures syncgateway nodes
Can you let us know what are scenarios , the sequences are getting unused and also how to avoid these unused messages.

2020-06-24T10:16:42.970Z [DBG] DCP+: Received #5563682 after 1ms (“s447390030110_ptx1592993884052_meta.doc” / “2-920997f5b53cdea06591f77b45054524”)
2020-06-24T10:16:42.970Z [INF] Cache: Deferring #5563682 (3 now waiting for #5563678#5563679) doc “s447390030110_ptx1592993884052_meta.doc” / “2-920997f5b53cdea06591f77b45054524”
2020-06-24T10:16:42.978Z [INF] HTTP: #24071536: GET /ptxdata/s447390030110_ptx1592233176445_meta.doc?rev=2-849b77481e86c00b027f70319eb527a4&revs=true&attachments=true (as 447390030109)
2020-06-24T10:16:42.981Z [INF] HTTP+: #24071536: --> 200 (4.0 ms)
2020-06-24T10:16:43.077Z [INF] HTTP: #24071537: GET /ptxdata/ (as ADMIN)
2020-06-24T10:16:43.077Z [INF] HTTP+: #24071537: --> 200 (0.1 ms)
2020-06-24T10:16:43.229Z [INF] HTTP: #24071538: GET /
2020-06-24T10:16:43.229Z [INF] HTTP+: #24071538: --> 200 (0.1 ms)
2020-06-24T10:16:43.434Z [INF] Cache: Received #5563678 (unused sequence)
2020-06-24T10:16:43.434Z [INF] Cache: Received #5563679 (unused sequence)

I see the same logs and tens of thousands of them per day. Interestingly enough I have been using a single SG node for months now.

SG version 2.7.3

What version of Sync Gateway are you running. We’ve been making enhancements to unused sequence handling over the releases. That said, unused sequences shouldn’t be of great concern if they aren’t causing issues.

“unused sequences” means that Sync Gateway has allocated these sequences because it expects to see that sequence ( it’s seen sequences higher than that), but sequences didn’t show up within the skipped sequence waiting window at which point it abandons that sequence and tags it as unused. Various reasons why a sequence never shows up - for instance, sync gateway could crash before the allocated sequences are used for instance. Here is another reason.