Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When run on Azure Cosmos for Mongodb API, liquibase cannot identify DATABASECHANGELOG collection. #581

Open
nischay13may opened this issue Nov 25, 2024 · 0 comments

Comments

@nischay13may
Copy link

Since mongodb has a default cursor limit of 101, if the DATABASECHANGELOG collection falls outside of firstBatch of results, liquibase is unable to identify collection.
Liquibase runs this command to filter and check if DATABASECHANGELOG collection exists, but somehow this command doesn't work, probably because of the cursor size limit set to 101, and DATABASECHANGELOG collection falling outside of the firstBatch of results.
db.runCommand({ listCollections: 1, filter: { name: "DATABASECHANGELOG"}, authorizedCollections: true, nameOnly: true });

If we try this then it works:

db.runCommand({ listCollections: 1, filter: { name: "DATABASECHANGELOG"}, cursor: { batchSize: 500 }, authorizedCollections: true, nameOnly: true });

INFO: Create Database Change Log Collection
Nov 22, 2024 3:11:07 PM liquibase.ext
INFO: Creating database history collection with name: schema.DATABASECHANGELOG
[main] INFO org.mongodb.driver.connection - Closed connection [connectionId{localValue:5, serverValue:171294252}] to because the pool has been closed.
Nov 22, 2024 3:11:08 PM liquibase.command
INFO: Logging exception.
ERROR: Exception Details
Nov 22, 2024 3:11:08 PM liquibase.ui
INFO: ERROR: Exception Details
ERROR: Exception Primary Class: MongoCommandException
Nov 22, 2024 3:11:08 PM liquibase.ui
INFO: ERROR: Exception Primary Class: MongoCommandException
ERROR: Exception Primary Reason: Command failed with error 48 (NamespaceExists): 'a collection 'schema.DATABASECHANGELOG' already exists' on server . The full response is {"ok": 0.0, "errmsg": "a collection 'schema.DATABASECHANGELOG' already exists", "code": 48, "codeName": "NamespaceExists"}
Nov 22, 2024 3:11:08 PM liquibase.ui
INFO: ERROR: Exception Primary Reason: Command failed with error 48 (NamespaceExists): 'a collection 'schema.DATABASECHANGELOG' already exists' on server . The full response is {"ok": 0.0, "errmsg": "a collection 'schema.DATABASECHANGELOG' already exists", "code": 48, "codeName": "NamespaceExists"}
ERROR: Exception Primary Source: MongoDB 0
Nov 22, 2024 3:11:08 PM liquibase.ui
INFO: ERROR: Exception Primary Source: MongoDB 0
Nov 22, 2024 3:11:08 PM liquibase.command
INFO: Command execution complete
Nov 22, 2024 3:11:08 PM liquibase.integration
SEVERE: Could not execute

  • Caused by: Command failed with error 48 (NamespaceExists): 'a collection 'DATABASECHANGELOG' already exists' on server . The full response is {"ok": 0.0, "errmsg": "a collection 'DATABASECHANGELOG' already exists", "code": 48, "codeName": "NamespaceExists"}
    liquibase.exception.CommandExecutionException: liquibase.exception.DatabaseException: Could not execute
    at liquibase.command.CommandScope.execute(CommandScope.java:258)
    at liquibase.integration.commandline.CommandRunner.call(CommandRunner.java:51)
    at liquibase.integration.commandline.CommandRunner.call(CommandRunner.java:21)
    at picocli.CommandLine.executeUserObject(CommandLine.java:2045)
    at picocli.CommandLine.access$1500(CommandLine.java:148)
    at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2465)
    at picocli.CommandLine$RunLast.handle(CommandLine.java:2457)
    at picocli.CommandLine$RunLast.handle(CommandLine.java:2419)
    at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2277)
    at picocli.CommandLine$RunLast.execute(CommandLine.java:2421)
    at picocli.CommandLine.execute(CommandLine.java:2174)
    at liquibase.integration.commandline.LiquibaseCommandLine.lambda$execute$2(LiquibaseCommandLine.java:404)
    at liquibase.Scope.child(Scope.java:200)
    at liquibase.Scope.child(Scope.java:176)
    at liquibase.integration.commandline.LiquibaseCommandLine.lambda$execute$3(LiquibaseCommandLine.java:379)
    at liquibase.Scope.child(Scope.java:200)
    at liquibase.Scope.child(Scope.java:176)
    at liquibase.integration.commandline.LiquibaseCommandLine.execute(LiquibaseCommandLine.java:376)
    at liquibase.integration.commandline.LiquibaseCommandLine.main(LiquibaseCommandLine.java:97)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at liquibase.integration.commandline.LiquibaseLauncher.main(LiquibaseLauncher.java:116)
    Caused by: liquibase.exception.DatabaseException: Could not execute
    at liquibase.nosql.executor.NoSqlExecutor.execute(NoSqlExecutor.java:194)
    at liquibase.nosql.executor.NoSqlExecutor.execute(NoSqlExecutor.java:185)
    at liquibase.ext.mongodb.changelog.MongoHistoryService.createRepository(MongoHistoryService.java:105)
    at liquibase.nosql.changelog.AbstractNoSqlHistoryService.init(AbstractNoSqlHistoryService.java:126)
    at liquibase.command.core.helpers.DatabaseChangelogCommandStep.checkLiquibaseTables(DatabaseChangelogCommandStep.java:141)
    at liquibase.command.core.helpers.DatabaseChangelogCommandStep.run(DatabaseChangelogCommandStep.java:91)
    at liquibase.command.CommandScope.execute(CommandScope.java:220)
    ... 23 more
    Caused by: com.mongodb.MongoCommandException: Command failed with error 48 (NamespaceExists): 'a collection 'schema.DATABASECHANGELOG' already exists' on server . The full response is {"ok": 0.0, "errmsg": "a collection 'schema.DATABASECHANGELOG' already exists", "code": 48, "codeName": "NamespaceExists"}
    at com.mongodb.internal.connection.ProtocolHelper.getCommandFailureException(ProtocolHelper.java:175)
    at com.mongodb.internal.connection.InternalStreamConnection.receiveCommandMessageResponse(InternalStreamConnection.java:358)
    at com.mongodb.internal.connection.InternalStreamConnection.sendAndReceive(InternalStreamConnection.java:279)
    at com.mongodb.internal.connection.UsageTrackingInternalConnection.sendAndReceive(UsageTrackingInternalConnection.java:100)
    at com.mongodb.internal.connection.DefaultConnectionPool$PooledConnection.sendAndReceive(DefaultConnectionPool.java:490)
    at com.mongodb.internal.connection.CommandProtocolImpl.execute(CommandProtocolImpl.java:71)
    at com.mongodb.internal.connection.DefaultServer$DefaultServerProtocolExecutor.execute(DefaultServer.java:253)
    at com.mongodb.internal.connection.DefaultServerConnection.executeProtocol(DefaultServerConnection.java:202)
    at com.mongodb.internal.connection.DefaultServerConnection.command(DefaultServerConnection.java:118)
    at com.mongodb.internal.connection.DefaultServerConnection.command(DefaultServerConnection.java:110)
    at com.mongodb.internal.operation.CommandOperationHelper.executeCommand(CommandOperationHelper.java:345)
    at com.mongodb.internal.operation.CommandOperationHelper.executeCommand(CommandOperationHelper.java:336)
    at com.mongodb.internal.operation.CommandOperationHelper.executeCommandWithConnection(CommandOperationHelper.java:222)
    at com.mongodb.internal.operation.CommandOperationHelper$5.call(CommandOperationHelper.java:208)
    at com.mongodb.internal.operation.OperationHelper.withReadConnectionSource(OperationHelper.java:583)
    at com.mongodb.internal.operation.CommandOperationHelper.executeCommand(CommandOperationHelper.java:205)
    at com.mongodb.internal.operation.CommandOperationHelper.executeCommand(CommandOperationHelper.java:200)
    at com.mongodb.internal.operation.CommandReadOperation.execute(CommandReadOperation.java:58)
    at com.mongodb.client.internal.MongoClientDelegate$DelegateOperationExecutor.execute(MongoClientDelegate.java:170)
    at com.mongodb.client.internal.MongoDatabaseImpl.executeCommand(MongoDatabaseImpl.java:194)
    at com.mongodb.client.internal.MongoDatabaseImpl.runCommand(MongoDatabaseImpl.java:163)
    at com.mongodb.client.internal.MongoDatabaseImpl.runCommand(MongoDatabaseImpl.java:158)
    at com.mongodb.client.internal.MongoDatabaseImpl.runCommand(MongoDatabaseImpl.java:148)
    at liquibase.ext.mongodb.statement.AbstractRunCommandStatement.run(AbstractRunCommandStatement.java:59)
    at liquibase.ext.mongodb.statement.AbstractRunCommandStatement.run(AbstractRunCommandStatement.java:55)
    at liquibase.ext.mongodb.statement.AbstractRunCommandStatement.execute(AbstractRunCommandStatement.java:51)
    at liquibase.ext.mongodb.statement.AbstractRunCommandStatement.execute(AbstractRunCommandStatement.java:36)
    at liquibase.nosql.executor.NoSqlExecutor.execute(NoSqlExecutor.java:192)
    ... 29 more

Unexpected error running Liquibase: Could not execute

  • Caused by: Command failed with error 48 (NamespaceExists): 'a collection 'schema.DATABASECHANGELOG' already exists' on server . The full response is {"ok": 0.0, "errmsg": "a collection 'schema.DATABASECHANGELOG' already exists", "code": 48, "codeName": "NamespaceExists"}

liquibase.exception.CommandExecutionException: liquibase.exception.DatabaseException: Could not execute
at liquibase.command.CommandScope.execute(CommandScope.java:258)
at liquibase.integration.commandline.CommandRunner.call(CommandRunner.java:51)
at liquibase.integration.commandline.CommandRunner.call(CommandRunner.java:21)
at picocli.CommandLine.executeUserObject(CommandLine.java:2045)
at picocli.CommandLine.access$1500(CommandLine.java:148)
at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2465)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2457)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2419)
at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2277)
at picocli.CommandLine$RunLast.execute(CommandLine.java:2421)
at picocli.CommandLine.execute(CommandLine.java:2174)
at liquibase.integration.commandline.LiquibaseCommandLine.lambda$execute$2(LiquibaseCommandLine.java:404)
at liquibase.Scope.child(Scope.java:200)
at liquibase.Scope.child(Scope.java:176)
at liquibase.integration.commandline.LiquibaseCommandLine.lambda$execute$3(LiquibaseCommandLine.java:379)
at liquibase.Scope.child(Scope.java:200)
at liquibase.Scope.child(Scope.java:176)
at liquibase.integration.commandline.LiquibaseCommandLine.execute(LiquibaseCommandLine.java:376)
at liquibase.integration.commandline.LiquibaseCommandLine.main(LiquibaseCommandLine.java:97)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at liquibase.integration.commandline.LiquibaseLauncher.main(LiquibaseLauncher.java:116)
Caused by: liquibase.exception.DatabaseException: Could not execute
at liquibase.nosql.executor.NoSqlExecutor.execute(NoSqlExecutor.java:194)
at liquibase.nosql.executor.NoSqlExecutor.execute(NoSqlExecutor.java:185)
at liquibase.ext.mongodb.changelog.MongoHistoryService.createRepository(MongoHistoryService.java:105)
at liquibase.nosql.changelog.AbstractNoSqlHistoryService.init(AbstractNoSqlHistoryService.java:126)
at liquibase.command.core.helpers.DatabaseChangelogCommandStep.checkLiquibaseTables(DatabaseChangelogCommandStep.java:141)
at liquibase.command.core.helpers.DatabaseChangelogCommandStep.run(DatabaseChangelogCommandStep.java:91)
at liquibase.command.CommandScope.execute(CommandScope.java:220)
... 23 more
Caused by: com.mongodb.MongoCommandException: Command failed with error 48 (NamespaceExists): 'a collection 'schema.DATABASECHANGELOG' already exists' on server . The full response is {"ok": 0.0, "errmsg": "a collection 'schema.DATABASECHANGELOG' already exists", "code": 48, "codeName": "NamespaceExists"}
at com.mongodb.internal.connection.ProtocolHelper.getCommandFailureException(ProtocolHelper.java:175)
at com.mongodb.internal.connection.InternalStreamConnection.receiveCommandMessageResponse(InternalStreamConnection.java:358)
at com.mongodb.internal.connection.InternalStreamConnection.sendAndReceive(InternalStreamConnection.java:279)
at com.mongodb.internal.connection.UsageTrackingInternalConnection.sendAndReceive(UsageTrackingInternalConnection.java:100)
at com.mongodb.internal.connection.DefaultConnectionPool$PooledConnection.sendAndReceive(DefaultConnectionPool.java:490)
at com.mongodb.internal.connection.CommandProtocolImpl.execute(CommandProtocolImpl.java:71)
at com.mongodb.internal.connection.DefaultServer$DefaultServerProtocolExecutor.execute(DefaultServer.java:253)
at com.mongodb.internal.connection.DefaultServerConnection.executeProtocol(DefaultServerConnection.java:202)
at com.mongodb.internal.connection.DefaultServerConnection.command(DefaultServerConnection.java:118)
at com.mongodb.internal.connection.DefaultServerConnection.command(DefaultServerConnection.java:110)
at com.mongodb.internal.operation.CommandOperationHelper.executeCommand(CommandOperationHelper.java:345)
at com.mongodb.internal.operation.CommandOperationHelper.executeCommand(CommandOperationHelper.java:336)
at com.mongodb.internal.operation.CommandOperationHelper.executeCommandWithConnection(CommandOperationHelper.java:222)
at com.mongodb.internal.operation.CommandOperationHelper$5.call(CommandOperationHelper.java:208)
at com.mongodb.internal.operation.OperationHelper.withReadConnectionSource(OperationHelper.java:583)
at com.mongodb.internal.operation.CommandOperationHelper.executeCommand(CommandOperationHelper.java:205)
at com.mongodb.internal.operation.CommandOperationHelper.executeCommand(CommandOperationHelper.java:200)
at com.mongodb.internal.operation.CommandReadOperation.execute(CommandReadOperation.java:58)
at com.mongodb.client.internal.MongoClientDelegate$DelegateOperationExecutor.execute(MongoClientDelegate.java:170)
at com.mongodb.client.internal.MongoDatabaseImpl.executeCommand(MongoDatabaseImpl.java:194)
at com.mongodb.client.internal.MongoDatabaseImpl.runCommand(MongoDatabaseImpl.java:163)
at com.mongodb.client.internal.MongoDatabaseImpl.runCommand(MongoDatabaseImpl.java:158)
at com.mongodb.client.internal.MongoDatabaseImpl.runCommand(MongoDatabaseImpl.java:148)
at liquibase.ext.mongodb.statement.AbstractRunCommandStatement.run(AbstractRunCommandStatement.java:59)
at liquibase.ext.mongodb.statement.AbstractRunCommandStatement.run(AbstractRunCommandStatement.java:55)
at liquibase.ext.mongodb.statement.AbstractRunCommandStatement.execute(AbstractRunCommandStatement.java:51)
at liquibase.ext.mongodb.statement.AbstractRunCommandStatement.execute(AbstractRunCommandStatement.java:36)
at liquibase.nosql.executor.NoSqlExecutor.execute(NoSqlExecutor.java:192)
... 29 more

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant