Uploaded image for project: 'Couchbase Gateway'
  1. Couchbase Gateway
  2. CBG-3330

[3.1.2 Backport] buildRevokedFeed query iteration fails when no documents processed

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Critical
    • 3.1.2
    • None
    • SyncGateway
    • Security Level: Public
    • None
    • CBG Sprint 136
    • 1

    Description

      buildRevokedFeed performs query pagination based on the channel query limit (defaults to 5000). It determines the starting sequence for the next iteration based on the last sequence processed, but it appears that there are scenarios where the last sequence is never incremented in a batch, resulting in the query processing the same batch repeatedly.

      paginationOptions.Since.Seq is set to the latest sequence processed (lastSeq) when the user has access to a doc, or at the bottom of the loop. However, if all documents returned by a query batch are greater than the since value, and do not require revocation, they don't increment lastSeq (because of the use of continue).

      Evidence suggesting this bug is seen in the logs from https://www.couchbase.com/forums/t/sync-gateway-not-syncing-documents-with-cb-lite-replicator-stuck-on-busy/36738/19, where the following is seen in the logs when the client reports being 'stuck':

      2023-08-08T23:11:52.858+02:00 [INF] Cache:   Querying 'channels' for "<ud>dn_a838a898-b6bc-40c6-b3cb-8b4ca166f59c</ud>" (start=#1, end=#18446744073709551615, limit=5000)
      2023-08-08T23:11:52.901+02:00 [INF] Cache:     Got 5000 rows from query for "<ud>dn_a838a898-b6bc-40c6-b3cb-8b4ca166f59c</ud>": #140216 ... #1158673
      2023-08-08T23:11:52.901+02:00 [DBG] Changes+: [revocationChangesFeed] Found 5000 changes for channel "<ud>dn_a838a898-b6bc-40c6-b3cb-8b4ca166f59c</ud>"
      ...
       
      2023-08-08T23:12:17.937+02:00 [INF] Cache:   Querying 'channels' for "<ud>dn_a838a898-b6bc-40c6-b3cb-8b4ca166f59c</ud>" (start=#1, end=#18446744073709551615, limit=5000)
      2023-08-08T23:12:17.989+02:00 [INF] Cache:     Got 5000 rows from query for "<ud>dn_a838a898-b6bc-40c6-b3cb-8b4ca166f59c</ud>": #140216 ... #1158673
      2023-08-08T23:12:17.989+02:00 [DBG] Changes+: [revocationChangesFeed] Found 5000 changes for channel "<ud>dn_a838a898-b6bc-40c6-b3cb-8b4ca166f59c</ud>"
      

      It's not definitive that this is the same request (since we don't log request context here), but it seems likely based on the rest of the log context.

      Need to write a unit test to repro to confirm. Unit test needs to:
      1. Change the channel query pagination limit to a lower value for testing (e.g. 10)
      2. Write n documents to channel ABC, where n > pagination limit.
      3. Grant user access to channel ABC
      4. Revoke user access to channel ABC
      5. Issue a changes feed request for the user with since=0, check if revocation feed gets stuck in a loop.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            tor.colvin Tor Colvin
            adamf Adam Fraser
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty