Uploaded image for project: 'Couchbase Java Client'
  1. Couchbase Java Client
  2. JCBC-1940

Cleanup thread exits prematurely on NO_ACCESS error

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 3.3.0
    • None
    • transactions
    • None
    • 1

    Description

      This is kind of a variation of JCBC-1938:

      /**
       * User has both read and write permissions on default collection but only read permissions on custom collection
       * From default connection execute two failed transactions. One transaction has its ATR on default collection and other failed transaction has its ATR on metadata collection
       * Ensure  operations for both failed transactions are in default collection
       *
       * The cluster connection created for this user should clean up Transaction with ATR in default collection  but not Transaction with ATR in custom collection.
       */
      @Test
      void cleansupCollectionWithReadWritePerms_doesNotCleanupCollectionWithReadOnlyPerms() {
          String TEST_USER = "can_read_write_defaultCollection_only_read_customCollection";
          User user = new User(TEST_USER);
          user.password(Strings.RBAC_USER_PASSWORD);
          user.roles(
                  new Role("data_reader", shared.bucket().name(),CollectionIdentifier.DEFAULT_SCOPE,collection.name()),
                  new Role("data_writer", shared.bucket().name(),CollectionIdentifier.DEFAULT_SCOPE,collection.name()),
                  new Role("data_reader", shared.bucket().name(),CollectionIdentifier.DEFAULT_SCOPE,customCollection.name()));
          shared.cluster().users().upsertUser(user);
       
          try (var initiator = TransactionsInitiatorBuilder.definitelyMakeClusterConnection(shared,
                          shared.getClusterHostname(),
                          TEST_USER,
                          Strings.RBAC_USER_PASSWORD)
                  .cleanupCollectionList(Arrays.asList(collection,customCollection))
                  .cleanupLostAttempts(true)
                  .cleanupWindow(CLEANUP_WINDOW)
                  .sendToPerformerIfNeeded()) {
       
              //From default connection, create a failed transaction with ATR in default collection and txn ops in default collection
              String docId1 = TestUtils.docId();
              TransactionResult r1 = TransactionBuilder.create(shared)
                      .timeout(EXPECT_TO_EXPIRE)
                      .addHookAlways(HookPoint.AFTER_ATR_COMMIT, HookAction.FAIL_HARD)
                      .insert(docId1, initial)
                      .sendToPerformer();
              Util.waitUntilCondition(() -> {
                  long atrCount = ATRValidator.findAtrEntriesForTransaction(collection,r1.getTransactionId()).size();
                  return atrCount == 0;
              }, EXPECT_CONDITION_SATISFIED);
              DocValidator.assertDocExistsAndNotInTransactionAndContentEquals(collection, docId1,initial);
       
       
      *******************************The below transaction is not cleaned up as expected.So you can ignore this for this bug****************************
              //From default connection, create a failed transaction with ATR in custom collection
              String docId2 = TestUtils.docId();
              TransactionResult r2 = TransactionBuilder.create(shared)
                      .metadataCollection(customCollection)
                      .timeout(EXPECT_TO_EXPIRE)
                      .addHookAlways(HookPoint.AFTER_ATR_COMMIT, HookAction.FAIL_HARD)
                      .insert(docId2, initial)
                      .sendToPerformer();
              // Will keep polling for 3s to ensure ATR is not cleaned up
              CleanupSetValidator.assertATREntryNotCleanedupDuringWaitTime(customCollection,r2,waitTimeInSecs);
              DocValidator.assertInsertedDocIsStaged(shared,collection, docId2);
       
              initiator.setUsed();
          }
      } 

      Attachments

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

        Activity

          People

            graham.pople Graham Pople
            praneeth.bokka Praneeth Bokka (Inactive)
            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