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

Couchbase fails to create collection index right after the creation of a collection

    XMLWordPrintable

Details

    Description

       

      CollectionManager collectionManager = bucket.collections();
      try {
          CollectionSpec spec = CollectionSpec.create(CollectionNames.PROFILE, bucket.defaultScope().name());
          collectionManager.createCollection(spec);
          //Thread.sleep(10000);
      } catch (CollectionExistsException e){
          System.out.println(String.format("Collection <%s> already exists", CollectionNames.PROFILE));
      } catch (Exception e) {
          System.out.println(String.format("Generic error <%s>",e.getMessage()));
      }
       
      try {
          final QueryResult result = cluster.query("CREATE PRIMARY INDEX default_profile_index ON "+props.getBucketName()+"._default."+ CollectionNames.PROFILE);
          for (JsonObject row : result.rowsAsObject()){
              System.out.println(String.format("Index Creation Status %s",row.getObject("meta").getString("status")));
          }
      } catch (IndexExistsException e){
          System.out.println(String.format("Collection's primary index already exists"));
      } catch (Exception e){
          System.out.println(String.format("General error <%s> when trying to create index ",e.getMessage()));
      }
      

      We tried on multiple languages and we always get the same error:

       

       {"completed":true,"coreId":"0x1345501c00000001","errors":[{"code":12003,"message":"Keyspace not found in CB datastore: default:user_profile._default.profile"}],"idempotent":false,"lastDispatchedFrom":"127.0.0.1:63120","lastDispatchedTo":"localhost:8093","requestId":13,"requestType":"QueryRequest","retried":0,"service":{"operationId":"526fcd12-023b-4628-a510-1a250794725c","statement":"DELETE FROM user_profile._default.profile ","type":"query"},"timeoutMs":75000,"timings":{"dispatchMicros":1132,"totalDispatchMicros":1132,"totalMicros":1952}}
      
      

      But if we add a sleep of 10 seconds, the code works fine. Ideally, the SDK should only send the acknowledgment after the collection is created. 

      Attachments

        Issue Links

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

          Activity

            People

              chinhong Chin Hong
              denis.rosa Denis Rosa
              Votes:
              1 Vote for this issue
              Watchers:
              18 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty