Status OperationContext::checkForInterruptNoAssert() noexcept {
    // TODO: Remove the MONGO_likely(getClient()) once all operation contexts are constructed with
    // clients.
    if (MONGO_likely(getClient() && getServiceContext()) &&
        getServiceContext()->getKillAllOperations()) {
        return Status(ErrorCodes::InterruptedAtShutdown, "interrupted at shutdown");
    }

    if (hasDeadlineExpired()) {
        if (!_hasArtificialDeadline) {
            markKilled(_timeoutError);
        }
        return Status(_timeoutError, "operation exceeded time limit");
    }

    if (_ignoreInterrupts) {
        return Status::OK();
    }

    MONGO_FAIL_POINT_BLOCK(checkForInterruptFail, scopedFailPoint) {
        if (opShouldFail(getClient(), scopedFailPoint.getData())) {
            log() << "set pending kill on op " << getOpID() << ", for checkForInterruptFail";
            markKilled();
        }
    }

    const auto killStatus = getKillStatus();
    if (killStatus != ErrorCodes::OK) {
        return Status(killStatus, "operation was interrupted");
    }

    return Status::OK();
}
Ejemplo n.º 2
0
    Status OperationContextImpl::checkForInterruptNoAssert() const {
        if (getGlobalEnvironment()->getKillAllOperations()) {
            return Status(ErrorCodes::InterruptedAtShutdown, "interrupted at shutdown");
        }

        Client* c = getClient();
        if (c->curop()->maxTimeHasExpired()) {
            c->curop()->kill();
            return Status(ErrorCodes::ExceededTimeLimit, "operation exceeded time limit");
        }

        MONGO_FAIL_POINT_BLOCK(checkForInterruptFail, scopedFailPoint) {
            if (opShouldFail(*c, scopedFailPoint.getData())) {
                log() << "set pending kill on " << (c->curop()->parent() ? "nested" : "top-level")
                      << " op " << c->curop()->opNum() << ", for checkForInterruptFail";
                c->curop()->kill();
            }
        }

        if (c->curop()->killPending()) {
            return Status(ErrorCodes::Interrupted, "operation was interrupted");
        }

        return Status::OK();
    }
Ejemplo n.º 3
0
    void KillCurrentOp::checkForInterrupt(bool heedMutex) {
        Client& c = cc();

        if (heedMutex && Lock::somethingWriteLocked() && c.hasWrittenSinceCheckpoint()) {
            return;
        }

        uassert(ErrorCodes::InterruptedAtShutdown, "interrupted at shutdown", !_globalKill);

        if (c.curop()->maxTimeHasExpired()) {
            c.curop()->kill();
            notifyAllWaiters();
            uasserted(ErrorCodes::ExceededTimeLimit, "operation exceeded time limit");
        }
        MONGO_FAIL_POINT_BLOCK(checkForInterruptFail, scopedFailPoint) {
            if (opShouldFail(c, scopedFailPoint.getData())) {
                log() << "set pending kill on " << (c.curop()->parent() ? "nested" : "top-level")
                      << " op " << c.curop()->opNum().get() << ", for checkForInterruptFail";
                c.curop()->kill();
            }
        }
        if (c.curop()->killPending()) {
            notifyAllWaiters();
            uasserted(11601, "operation was interrupted");
        }
    }
Ejemplo n.º 4
0
    const char * KillCurrentOp::checkForInterruptNoAssert() {
        Client& c = cc();

        if (_globalKill) {
            return "interrupted at shutdown";
        }
        if (c.curop()->maxTimeHasExpired()) {
            c.curop()->kill();
            return "exceeded time limit";
        }
        MONGO_FAIL_POINT_BLOCK(checkForInterruptFail, scopedFailPoint) {
            if (opShouldFail(c, scopedFailPoint.getData())) {
                log() << "set pending kill on " << (c.curop()->parent() ? "nested" : "top-level")
                      << " op " << c.curop()->opNum().get() << ", for checkForInterruptFail";
                c.curop()->kill();
            }
        }
        if (c.curop()->killPending()) {
            return "interrupted";
        }
        return "";
    }