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

DefaultPurgeInterval specified in days and used as though in hours

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 2.7.0, 2.8.0, 2.7.1, 2.7.2, 2.7.3
    • 3.0
    • SyncGateway
    • Security Level: Public
    • None
    • Hide
      Mandatory:
       - CBL / SG Version:
         - SG Config:
       - Steps to Reproduce:
       - Actual Result:
       - Expected Result:
       - Logs :
            SGW LOGS: sgcollect info
            CBL LOGS:
            Logcat LOGS: for Android tickets
       - Github link for the code:
       - Jenkins job failure link:
       - Pytest Command
       - What is the last build this test passed:
      Show
      Mandatory:  - CBL / SG Version:    - SG Config:  - Steps to Reproduce:  - Actual Result:  - Expected Result:  - Logs :       SGW LOGS: sgcollect info       CBL LOGS:       Logcat LOGS: for Android tickets  - Github link for the code:  - Jenkins job failure link:  - Pytest Command  - What is the last build this test passed:
    • CBG Sprint 61
    • 2

    Description

      When starting up, we try to retrieve the purge interval for the bucket (either set at a bucket or cluster level), and if we can't get this due to access we assume a default of 30 days:

      https://github.com/couchbase/sync_gateway/blob/master/db/database.go#L55
      https://github.com/couchbase/sync_gateway/blob/master/db/database.go#L466-L478

      The problem is we define the constant in days (which matches how you define the value in Couchbase Server), however everywhere we use it we treat it as hours:

      https://github.com/couchbase/sync_gateway/blob/master/db/database.go#L919-L922

      This is because when we get the value from Couchbase Server (if we're successful) we immediately munge it to be in hours, and then use this value in everything "Sync Gateway related":

      https://github.com/couchbase/sync_gateway/blob/master/base/bucket_gocb.go#L251-L253

      This should be as simple as adding a * 24 to the constant definition, but I wonder if it makes sense to pass around a time.Duration for all of this instead?

      Marking as critical, as in cases where this happens (which, reasonably will be the default - interval set at 3 days at the cluster level, and no user admin access to see it) we'll see documents prematurely purged from indexes based on this.

      Attachments

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

        Activity

          As an aside, the added complexity of managing all this does make me wonder if it should be done in the indexer itself...

          James Flather James Flather added a comment - As an aside, the added complexity of managing all this does make me wonder if it should be done in the indexer itself...
          adamf Adam Fraser added a comment -

          We've had in-depth discussions about having the indexer manage this with the kv-engine and indexer teams, and haven't come up with a viable approach (i.e. one that doesn't introduce significant overhead to non-tombstone indexing).

          I agree this should be fixed, although the workaround (ensuring Sync Gateway user has the correct RBAC access, as documented) makes me wonder if it's more critical than 'fix in the next release'.

          adamf Adam Fraser added a comment - We've had in-depth discussions about having the indexer manage this with the kv-engine and indexer teams, and haven't come up with a viable approach (i.e. one that doesn't introduce significant overhead to non-tombstone indexing). I agree this should be fixed, although the workaround (ensuring Sync Gateway user has the correct RBAC access, as documented) makes me wonder if it's more critical than 'fix in the next release'.

          Build sync_gateway-3.0.0-49 contains sync_gateway commit fcd8371 with commit message:
          CBG-1161 Fix DefaultPurgeInterval specified in days and used as though in hours (#4847)

          build-team Couchbase Build Team added a comment - Build sync_gateway-3.0.0-49 contains sync_gateway commit fcd8371 with commit message: CBG-1161 Fix DefaultPurgeInterval specified in days and used as though in hours (#4847)

          People

            sarath.kumarsivan Sarath Kumar Sivan (Inactive)
            James Flather James Flather
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty