Uploaded image for project: 'Couchbase Server'
  1. Couchbase Server
  2. MB-38202

Possible loss of item count if competition runs at the same time as the flusher

    XMLWordPrintable

Details

    • Untriaged
    • Unknown

    Description

      This is a theatrical bug that might occur in the future if we allow compaction to occur at the same time that the PersistenceCallback's are being called after a flush. This could cause us to potentially lose an increment or decrements to the onDiskTotalItems counter. Thus meaning in full eviction our "current item count" would be incorrect.

      This is due to a race occurring between one of the PersistenceCallback s incrementing or decrementing the count and EPBucket::compactionCompletionCallback setting the value as setNumTotalItems() isn't thread safe and blindly sets the value of onDiskTotalItems thus we should perform an atomic subtraction on onDiskTotalItems of value ctx.stats.collectionsItemsPurged.

      void EPBucket::compactionCompletionCallback(compaction_ctx& ctx) {
          auto vb = getVBucket(ctx.compactConfig.db_file_id);
          if (!vb) {
              return;
          }
       
          vb->setPurgeSeqno(ctx.max_purged_seq);
          vb->setNumTotalItems(vb->getNumTotalItems() -
                               ctx.stats.collectionsItemsPurged);
      }
      

      This code was originally first added in a different form in commit 4d6df4c1e177ffc5673b8cefc44cecbf5fa42477.

      Attachments

        Issue Links

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

          Activity

            People

              richard.demellow Richard deMellow
              richard.demellow Richard deMellow
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty