jstests/sharding/libs/resharding_test_fixture.js
/**
     * Wrapper around invoking a 0-argument function to make test failures less confusing.
     *
     * This helper attempts to disable the reshardingPauseCoordinatorBeforeBlockingWrites
     * failpoint when an exception is thrown to prevent the mongo shell from hanging (really the
     * config server) on top of having a JavaScript error.
     *
     * This helper attempts to interrupt and join the resharding thread when an exception is thrown
     * to prevent the mongo shell from aborting on top of having a JavaScript error.
     *
     * @private
     */
Wrapper around invoking a 0-argument function to make test failures less confusing.
This helper attempts to disable the reshardingPauseCoordinatorBeforeBlockingWrites
failpoint when an exception is thrown to prevent the mongo shell from hanging (really the
config server) on top of having a JavaScript error.

This helper attempts to interrupt and join the resharding thread when an exception is thrown
to prevent the mongo shell from aborting on top of having a JavaScript error.

@private
Wrapper around invoking a 0 - argument function to make test failures less confusing . This helper attempts to disable the reshardingPauseCoordinatorBeforeBlockingWrites failpoint when an exception is thrown to prevent the mongo shell from hanging ( really the config server ) on top of having a JavaScript error . This helper attempts to interrupt and join the resharding thread when an exception is thrown to prevent the mongo shell from aborting on top of having a JavaScript error . @private
_callFunctionSafely(fn) {
        try {
            fn();
        } catch (duringReshardingError) {
            for (const fp of [this._pauseCoordinatorBeforeBlockingWrites,
                              this._pauseCoordinatorBeforeDecisionPersistedFailpoint,
                              this._pauseCoordinatorBeforeCompletionFailpoint]) {
                try {
                    fp.off();
                } catch (disableFailpointError) {
                    print(`Ignoring error from disabling the resharding coordinator failpoint: ${
                        tojson(disableFailpointError)}`);
                    print(
                        "The config server primary and the mongo shell along with it are expected" +
                        " to hang due to the resharding coordinator being left uninterrupted");
                }
            }
            try {
                const op = this._findReshardingCommandOp();
                if (op !== undefined) {
                    assert.commandWorked(this._st.admin.killOp(op.opid));
                }
                try {
                    this._reshardingThread.join();
                } catch (joinError) {
                    print(`Ignoring error from the resharding thread: ${tojson(joinError)}`);
                }
                this._isReshardingActive = false;
            } catch (killOpError) {
                print(`Ignoring error from sending killOp to the reshardCollection command: ${
                    tojson(killOpError)}`);
                print("The mongo shell is expected to abort due to the resharding thread being" +
                      " left unjoined");
            }
            throw duringReshardingError;
        }
    }
_callFunctionSafely ( fn ) { try { fn ( ) ; } catch ( duringReshardingError ) { for ( const fp of [ this . _pauseCoordinatorBeforeBlockingWrites , this . _pauseCoordinatorBeforeDecisionPersistedFailpoint , this . _pauseCoordinatorBeforeCompletionFailpoint ] ) { try { fp . off ( ) ; } catch ( disableFailpointError ) { print ( ` ${ tojson ( disableFailpointError ) } ` ) ; print ( "The config server primary and the mongo shell along with it are expected" + " to hang due to the resharding coordinator being left uninterrupted" ) ; } } try { const op = this . _findReshardingCommandOp ( ) ; if ( op !== undefined ) { assert . commandWorked ( this . _st . admin . killOp ( op . opid ) ) ; } try { this . _reshardingThread . join ( ) ; } catch ( joinError ) { print ( ` ${ tojson ( joinError ) } ` ) ; } this . _isReshardingActive = false ; } catch ( killOpError ) { print ( ` ${ tojson ( killOpError ) } ` ) ; print ( "The mongo shell is expected to abort due to the resharding thread being" + " left unjoined" ) ; } throw duringReshardingError ; } }
Wrapper around invoking a 0-argument function to make test failures less confusing.
Wrapper around invoking a 0 - argument function to make test failures less confusing .