Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-34320

Embedded service does not support creating indexes

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.7.4
    • Component/s: Internal Code
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible
    • Epic Link:
    • Sprint:
      Platforms 2018-04-09

      Description

      When using the Java driver to create an index on an embedded MongoDB cluster with the following code:

      MongoClient mongoClient = /* code to get the client */;
      MongoCollection items = mongoClient.getDatabase("todo").getCollection("items");
      items.createIndex(Indexes.ascending("task"));
      

      I get the following exception:

      com.mongodb.MongoCommandException: Command failed with error 238: 'Not implemented for embedded: operator()' on server 127.0.0.1:27017. The full response is { "ok" : 0.0, "errmsg" : "Not implemented for embedded: operator()", "code" : 238, "codeName" : "NotImplemented" }
      

      I'm able to replicate the error using the following runCommand

      MongoDatabase todoDB = mongoClient.getDatabase("todo");
      todoDB.runCommand(new Document()
                  .append("createIndexes", "items")
                  .append("indexes", Arrays.asList(new Document()
                      .append("key", new Document()
                          .append("task", 1))
                      .append("name", "task_1"))
                  ));
      

      Equivalent to

      db.runCommand(
        {
          createIndexes: "items",
          indexes: [
              {
                  key: {
                      "task": 1,
                  },
                  name: "task_1"
              }
          ]
        }
      )
      

      It seems to be an issue with the creation of any index, and I suspect it's hitting this line of code, but I haven't confirmed this: https://github.com/mongodb/mongo/blob/master/src/mongo/client/embedded/replication_coordinator_embedded.cpp#L331

      If it would help, here's the full stacktrace:

      Caused by: com.mongodb.MongoCommandException: Command failed with error 238: 'Not implemented for embedded: operator()' on server 127.0.0.1:27017. The full response is { "ok" : 0.0, "errmsg" : "Not implemented for embedded: operator()", "code" : 238, "codeName" : "NotImplemented" }
                                                                            at com.mongodb.internal.connection.ProtocolHelper.getCommandFailureException(ProtocolHelper.java:164)
                                                                            at com.mongodb.internal.connection.InternalStreamConnection.receiveCommandMessageResponse(InternalStreamConnection.java:293)
                                                                            at com.mongodb.internal.connection.InternalStreamConnection.sendAndReceive(InternalStreamConnection.java:254)
                                                                            at com.mongodb.internal.connection.CommandProtocolImpl.execute(CommandProtocolImpl.java:72)
                                                                            at com.mongodb.embedded.client.EmbeddedServer$DefaultServerProtocolExecutor.execute(EmbeddedServer.java:141)
                                                                            at com.mongodb.internal.connection.DefaultServerConnection.executeProtocol(DefaultServerConnection.java:269)
                                                                            at com.mongodb.internal.connection.DefaultServerConnection.command(DefaultServerConnection.java:131)
                                                                            at com.mongodb.internal.connection.DefaultServerConnection.command(DefaultServerConnection.java:123)
                                                                            at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:226)
                                                                            at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:217)
                                                                            at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:154)
                                                                            at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:147)
                                                                            at com.mongodb.operation.CreateIndexesOperation$1.call(CreateIndexesOperation.java:174)
                                                                            at com.mongodb.operation.CreateIndexesOperation$1.call(CreateIndexesOperation.java:169)
                                                                            at com.mongodb.operation.OperationHelper.withConnectionSource(OperationHelper.java:462)
                                                                            at com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:424)
                                                                            at com.mongodb.operation.CreateIndexesOperation.execute(CreateIndexesOperation.java:169)
                                                                            at com.mongodb.operation.CreateIndexesOperation.execute(CreateIndexesOperation.java:70)
                                                                            at com.mongodb.client.internal.MongoClientDelegate$DelegateOperationExecutor.execute(MongoClientDelegate.java:151)
                                                                            at com.mongodb.client.internal.MongoCollectionImpl.executeCreateIndexes(MongoCollectionImpl.java:739)
                                                                            at com.mongodb.client.internal.MongoCollectionImpl.createIndexes(MongoCollectionImpl.java:722)
                                                                            at com.mongodb.client.internal.MongoCollectionImpl.createIndexes(MongoCollectionImpl.java:717)
                                                                            at com.mongodb.client.internal.MongoCollectionImpl.createIndex(MongoCollectionImpl.java:702)
                                                                            at com.mongodb.client.internal.MongoCollectionImpl.createIndex(MongoCollectionImpl.java:697)
                                                                            at com.mongodb.todo.TodoListActivity.onCreate(TodoListActivity.java:47)
      

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: