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

Review usages of `ErrorCodes::MovePrimaryInProgress` and `assertNoMovePrimaryInProgress`

    • Type: Icon: Task Task
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Catalog and Routing

      The movePrimary DDL operation is acquiring a DDL lock in MOVE_X on the database being moved, hence other operations requiring a database DDL lock can't possibly conflict with it.

      At the time of writing this ticket, there are several references to MovePrimaryInProgress under src/mongo, some probably in codepath that can't be reached or where the error can't be thrown/hit.

      For example, both collMod and dropIndexes acquire a DDL lock, despite that they seem to be actively checking that no move primary is in progress:

      $ git grep MovePrimaryInProgress src/mongo/
      src/mongo/base/error_codes.yml:  - {code: 319, name: MovePrimaryInProgress}
      src/mongo/db/catalog/coll_mod.cpp:void assertNoMovePrimaryInProgress(OperationContext* opCtx, NamespaceString const& nss) {
      src/mongo/db/catalog/coll_mod.cpp:            if (scopedDss->isMovePrimaryInProgress()) {
      src/mongo/db/catalog/coll_mod.cpp:                LOGV2(4945200, "assertNoMovePrimaryInProgress", logAttrs(nss));
      src/mongo/db/catalog/coll_mod.cpp:                uasserted(ErrorCodes::MovePrimaryInProgress,
      src/mongo/db/catalog/coll_mod.cpp:        if (ex.toStatus() != ErrorCodes::MovePrimaryInProgress) {
      src/mongo/db/catalog/database_impl.cpp:void assertNoMovePrimaryInProgress(OperationContext* opCtx, NamespaceString const& nss) {
      src/mongo/db/catalog/database_impl.cpp:    if (scopedDss->isMovePrimaryInProgress()) {
      src/mongo/db/catalog/database_impl.cpp:        LOGV2(4909100, "assertNoMovePrimaryInProgress", logAttrs(nss));
      src/mongo/db/catalog/database_impl.cpp:        uasserted(ErrorCodes::MovePrimaryInProgress,
      src/mongo/db/catalog/database_impl.cpp:    assertNoMovePrimaryInProgress(opCtx, nss);
      src/mongo/db/catalog/database_impl.cpp:    assertNoMovePrimaryInProgress(opCtx, fromNss);
      src/mongo/db/catalog/database_impl.cpp:    assertNoMovePrimaryInProgress(opCtx, nss);
      src/mongo/db/catalog/drop_indexes.cpp:void assertNoMovePrimaryInProgress(OperationContext* opCtx, const NamespaceString& nss) {
      src/mongo/db/catalog/drop_indexes.cpp:            if (scopedDss->isMovePrimaryInProgress()) {
      src/mongo/db/catalog/drop_indexes.cpp:                LOGV2(4976500, "assertNoMovePrimaryInProgress", logAttrs(nss));
      src/mongo/db/catalog/drop_indexes.cpp:                uasserted(ErrorCodes::MovePrimaryInProgress,
      src/mongo/db/catalog/drop_indexes.cpp:        if (ex.toStatus() != ErrorCodes::MovePrimaryInProgress) {
      src/mongo/db/catalog/drop_indexes.cpp:            assertNoMovePrimaryInProgress(opCtx, collNs);
      src/mongo/db/commands/create_indexes_cmd.cpp:void assertNoMovePrimaryInProgress(OperationContext* opCtx, const NamespaceString& nss) {
      src/mongo/db/commands/create_indexes_cmd.cpp:            if (scopedDss->isMovePrimaryInProgress()) {
      src/mongo/db/commands/create_indexes_cmd.cpp:                LOGV2(4909200, "assertNoMovePrimaryInProgress", logAttrs(nss));
      src/mongo/db/commands/create_indexes_cmd.cpp:                uasserted(ErrorCodes::MovePrimaryInProgress,
      src/mongo/db/commands/create_indexes_cmd.cpp:        if (ex.toStatus() != ErrorCodes::MovePrimaryInProgress) {
      src/mongo/db/commands/create_indexes_cmd.cpp:            assertNoMovePrimaryInProgress(opCtx, ns);
      src/mongo/db/s/database_sharding_state.cpp:void DatabaseShardingState::setMovePrimaryInProgress(OperationContext* opCtx) {
      src/mongo/db/s/database_sharding_state.cpp:void DatabaseShardingState::unsetMovePrimaryInProgress(OperationContext* opCtx) {
      src/mongo/db/s/database_sharding_state.h:    bool isMovePrimaryInProgress() const {
      src/mongo/db/s/database_sharding_state.h:     * operations on this database to fail with the `MovePrimaryInProgress` error.
      src/mongo/db/s/database_sharding_state.h:    void setMovePrimaryInProgress(OperationContext* opCtx);
      src/mongo/db/s/database_sharding_state.h:    void unsetMovePrimaryInProgress(OperationContext* opCtx);
      src/mongo/db/s/migration_chunk_cloner_source_op_observer.cpp:void MigrationChunkClonerSourceOpObserver::assertNoMovePrimaryInProgress(
      src/mongo/db/s/migration_chunk_cloner_source_op_observer.cpp:    if (scopedDss->isMovePrimaryInProgress()) {
      src/mongo/db/s/migration_chunk_cloner_source_op_observer.cpp:        LOGV2(4908600, "assertNoMovePrimaryInProgress", logAttrs(nss));
      src/mongo/db/s/migration_chunk_cloner_source_op_observer.cpp:        uasserted(ErrorCodes::MovePrimaryInProgress,
      src/mongo/db/s/migration_chunk_cloner_source_op_observer.cpp:        MigrationChunkClonerSourceOpObserver::assertNoMovePrimaryInProgress(opCtx, nss);
      src/mongo/db/s/migration_chunk_cloner_source_op_observer.cpp:        MigrationChunkClonerSourceOpObserver::assertNoMovePrimaryInProgress(opCtx, nss);
      src/mongo/db/s/migration_chunk_cloner_source_op_observer.cpp:        assertNoMovePrimaryInProgress(opCtx, nss);
      src/mongo/db/s/migration_chunk_cloner_source_op_observer.h:    static void assertNoMovePrimaryInProgress(OperationContext* opCtx, const NamespaceString& nss);
      src/mongo/db/s/move_primary_coordinator.cpp:    scopedDss->setMovePrimaryInProgress(opCtx);
      src/mongo/db/s/move_primary_coordinator.cpp:    scopedDss->unsetMovePrimaryInProgress(opCtx);
      src/mongo/db/s/move_primary_coordinator.h:     * `MovePrimaryInProgress` error.
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            pierlauro.sciarelli@mongodb.com Pierlauro Sciarelli
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: