Skip to content

Creating indexes from the console with an empty DB crashes with "ns does not exist" #47

@Startouf

Description

@Startouf

Context : starting a mongoid container/pod on kubernetes and trying to seed the database with

::Mongoid::Tasks::Database.create_indexes
# or rails db:create_indexes

I am not sure whether this is due to a Mongoid update or something else I am missing.
Backtrace

rails aborted!
Mongo::Error::OperationFailure: ns does not exist: my_db_production.mongoid_fulltext.index_collection_name_0 (26) (on mongodb.staging.svc.cluster.local, modern retry, attempt 1)
/usr/local/bundle/gems/mongo-2.14.0/lib/mongo/operation/result.rb:343:in `raise_operation_failure'
/usr/local/bundle/gems/mongo-2.14.0/lib/mongo/operation/indexes/result.rb:86:in `validate!'
/usr/local/bundle/gems/mongo-2.14.0/lib/mongo/operation/shared/response_handling.rb:29:in `block (3 levels) in validate_result'
/usr/local/bundle/gems/mongo-2.14.0/lib/mongo/operation/shared/response_handling.rb:96:in `add_server_diagnostics'
/usr/local/bundle/gems/mongo-2.14.0/lib/mongo/operation/shared/response_handling.rb:28:in `block (2 levels) in validate_result'
/usr/local/bundle/gems/mongo-2.14.0/lib/mongo/operation/shared/response_handling.rb:43:in `add_error_labels'
/usr/local/bundle/gems/mongo-2.14.0/lib/mongo/operation/shared/response_handling.rb:27:in `block in validate_result'
/usr/local/bundle/gems/mongo-2.14.0/lib/mongo/operation/shared/response_handling.rb:82:in `unpin_maybe'
/usr/local/bundle/gems/mongo-2.14.0/lib/mongo/operation/shared/response_handling.rb:26:in `validate_result'
/usr/local/bundle/gems/mongo-2.14.0/lib/mongo/operation/shared/executable.rb:46:in `block in execute'
/usr/local/bundle/gems/mongo-2.14.0/lib/mongo/operation/shared/executable.rb:45:in `tap'
/usr/local/bundle/gems/mongo-2.14.0/lib/mongo/operation/shared/executable.rb:45:in `execute'
/usr/local/bundle/gems/mongo-2.14.0/lib/mongo/operation/shared/op_msg_or_list_indexes_command.rb:29:in `block 

The faulty lines of code (School collection is empty)

School.all.each(&:save)
::School.create_indexes

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions