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

Add mongodb statestore #85

Closed
wants to merge 1 commit into from
Closed

Conversation

sleipnir
Copy link
Member

@sleipnir sleipnir commented Oct 19, 2022

It looks like the library for Mongodb is out of date.

Run Mongodb Docker:

docker run --name eigr-mongodb -p 27017:27017 -e MONGO_INITDB_ROOT_USERNAME=admin -e MONGO_INITDB_ROOT_PASSWORD=admin -e MONGO_INITDB_DATABASE=eigr-function-db -d mongo:4.4.4

Run Proxy:

MIX_ENV=prod PROXY_CLUSTER_STRATEGY=epmd PROXY_DATABASE_TYPE=mongodb PROXY_DATABASE_USERNAME=admin PROXY_DATABASE_SECRET=admin PROXY_DATABASE_NAME=admin SPAWN_STATESTORE_KEY=3Jnb0hZiHIzHTOih7t2cTEPEpY98Tu1wvQkPfq/XwqE= iex --name [email protected] -S mix

Error on startup

2022-10-18 22:41:21.587 [[email protected]]:[pid=<0.810.0> ]:[error]:Could not create schema migrations table. This error usually happens due to the following:

  * The database does not exist
  * The "schema_migrations" table, which Ecto uses for managing
    migrations, was defined by another library
  * There is a deadlock while migrating (such as using concurrent
    indexes with a migration_lock)

To fix the first issue, run "mix ecto.create".

To address the second, you can run "mix ecto.drop" followed by
"mix ecto.create". Alternatively you may configure Ecto to use
another table and/or repository for managing migrations:

    config :statestores, Statestores.Adapters.MongoDB,
      migration_source: "some_other_table_for_schema_migrations",
      migration_repo: AnotherRepoForSchemaMigrations

The full error report is shown below.

2022-10-18 22:41:21.599 [[email protected]]:[pid=<0.44.0> ]:[notice]:Application spawn_federated_example exited: SpawnFederatedExample.Application.start(:normal, []) returned an error: shutdown: failed to start child: SpawnSdk.System.Supervisor
    ** (EXIT) shutdown: failed to start child: Sidecar.Supervisor
        ** (EXIT) shutdown: failed to start child: Statestores.Supervisor
            ** (EXIT) an exception was raised:
                ** (UndefinedFunctionError) function Mongo.Ecto.execute_ddl/3 is undefined or private
                    (mongodb_ecto 1.0.0-beta.2) Mongo.Ecto.execute_ddl(%{adapter: Mongo.Ecto, cache: #Reference<0.1218499883.92143617.7262>, opts: [queue_target: 10000, pool_size: 60, timeout: 15000], pid: #PID<0.812.0>, pool: {Statestores.Adapters.MongoDB.Pool, [pool_timeout: 5000, repo: Statestores.Adapters.MongoDB, queue_target: 10000, pool_size: 60, port: 27017, hostname: "localhost", password: "admin", username: "admin", database: "admin", telemetry_prefix: [:statestores, :adapters, :mongo_db], otp_app: :statestores, timeout: 15000]}, repo: Statestores.Adapters.MongoDB, telemetry: {Statestores.Adapters.MongoDB, :debug, [:statestores, :adapters, :mongo_db, :query]}}, {:create_if_not_exists, %Ecto.Migration.Table{name: :schema_migrations, prefix: nil, comment: nil, primary_key: true, engine: nil, options: nil}, [{:add, :version, :bigint, [primary_key: true]}, {:add, :inserted_at, :naive_datetime, []}]}, [timeout: :infinity, log: false, schema_migration: true, telemetry_options: [schema_migration: true]])
                    (ecto_sql 3.9.0) lib/ecto/migrator.ex:672: Ecto.Migrator.verbose_schema_migration/3
                    (ecto_sql 3.9.0) lib/ecto/migrator.ex:486: Ecto.Migrator.lock_for_migrations/4
                    (ecto_sql 3.9.0) lib/ecto/migrator.ex:398: Ecto.Migrator.run/4
                    (ecto_sql 3.9.0) lib/ecto/migrator.ex:146: Ecto.Migrator.with_repo/3
                    (statestores 0.1.0) lib/statestores/migrator/migrator.ex:9: Statestores.Migrator.migrate/0
                    (statestores 0.1.0) lib/statestores/supervisor.ex:20: Statestores.Supervisor.init/1
                    (stdlib 4.1) supervisor.erl:330: :supervisor.init/1
{"Kernel pid terminated",application_controller,"{application_start_failure,spawn_federated_example,{{shutdown,{failed_to_start_child,'Elixir.SpawnSdk.System.Supervisor',{shutdown,{failed_to_start_child,'Elixir.Sidecar.Supervisor',{shutdown,{failed_to_start_child,'Elixir.Statestores.Supervisor',{#{'__exception__' => true,'__struct__' => 'Elixir.UndefinedFunctionError',arity => 3,function => execute_ddl,message => nil,module => 'Elixir.Mongo.Ecto',reason => nil},[{'Elixir.Mongo.Ecto',execute_ddl,[#{adapter => 'Elixir.Mongo.Ecto',cache => #Ref<0.1218499883.92143617.7262>,opts => [{queue_target,10000},{pool_size,60},{timeout,15000}],pid => <0.812.0>,pool => {'Elixir.Statestores.Adapters.MongoDB.Pool',[{pool_timeout,5000},{repo,'Elixir.Statestores.Adapters.MongoDB'},{queue_target,10000},{pool_size,60},{port,27017},{hostname,<<\"localhost\">>},{password,<<\"admin\">>},{username,<<\"admin\">>},{database,<<\"admin\">>},{telemetry_prefix,[statestores,adapters,mongo_db]},{otp_app,statestores},{timeout,15000}]},repo => 'Elixir.Statestores.Adapters.MongoDB',telemetry => {'Elixir.Statestores.Adapters.MongoDB',debug,[statestores,adapters,mongo_db,query]}},{create_if_not_exists,#{'__struct__' => 'Elixir.Ecto.Migration.Table',comment => nil,engine => nil,name => schema_migrations,options => nil,prefix => nil,primary_key => true},[{add,version,bigint,[{primary_key,true}]},{add,inserted_at,naive_datetime,[]}]},[{timeout,infinity},{log,false},{schema_migration,true},{telemetry_options,[{schema_migration,true}]}]],[]},{'Elixir.Ecto.Migrator',verbose_schema_migration,3,[{file,\"lib/ecto/migrator.ex\"},{line,672}]},{'Elixir.Ecto.Migrator',lock_for_migrations,4,[{file,\"lib/ecto/migrator.ex\"},{line,486}]},{'Elixir.Ecto.Migrator',run,4,[{file,\"lib/ecto/migrator.ex\"},{line,398}]},{'Elixir.Ecto.Migrator',with_repo,3,[{file,\"lib/ecto/migrator.ex\"},{line,146}]},{'Elixir.Statestores.Migrator',migrate,0,[{file,\"lib/statestores/migrator/migrator.ex\"},{line,9}]},{'Elixir.Statestores.Supervisor',init,1,[{file,\"lib/statestores/supervisor.ex\"},{line,20}]},{supervisor,init,1,[{file,\"supervisor.erl\"},{line,330}]}]}}}}}}},{'Elixir.SpawnFederatedExample.Application',start,[normal,[]]}}}"}
Kernel pid terminated (application_controller) ({application_start_failure,spawn_federated_example,{{shutdown,{failed_to_start_child,'Elixir.SpawnSdk.System.Supervisor',{shutdown,{failed_to_start_child,'Elixir.Sidecar.Supervisor',{shutdown,{failed_to_start_child,'Elixir.Statestores.Supervisor',{#{'__exception__' => true,'__struct__' => 'Elixir.UndefinedFunctionError',arity => 3,function => execute_ddl,message => nil,module => 'Elixir.Mongo.Ecto',reason => nil},[{'Elixir.Mongo.Ecto',execute_ddl,[#{adapter => 'Elixir.Mongo.Ecto',cache => #Ref<0.1218499883.92143617.7262>,opts => [{queue_target,10000},{pool_size,60},{timeout,15000}],pid => <0.812.0>,pool => {'Elixir.Statestores.Adapters.MongoDB.Pool',[{pool_timeout,5000},{repo,'Elixir.Statestores.Adapters.MongoDB'},{queue_target,10000},{pool_size,60},{port,27017},{hostname,<<"localhost">>},{password,<<"admin">>},{username,<<"admin">>},{database,<<"admin">>},{telemetry_prefix,[statestores,adapters,mongo_db]},{otp_app,statestores},{timeout,15000}]},repo => 'Elixir

@sleipnir sleipnir added bug Something isn't working statestores proxy enhancement New feature or request help wanted Extra attention is needed labels Oct 19, 2022
@sleipnir sleipnir added this to the v1.0.0 milestone Oct 19, 2022
@sleipnir
Copy link
Member Author

Related to #86

@sleipnir sleipnir linked an issue Oct 19, 2022 that may be closed by this pull request
@sleipnir
Copy link
Member Author

sleipnir commented Nov 9, 2022

closed due to inactivity

@sleipnir sleipnir closed this Nov 9, 2022
@sleipnir
Copy link
Member Author

We will no longer support this statestore. #353

@sleipnir sleipnir deleted the feat/add-mongodb-statestore branch July 31, 2024 23:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request help wanted Extra attention is needed proxy statestores
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

MongoDB Support
1 participant