aboutsummaryrefslogtreecommitdiffstats
path: root/storage/src/vespa/storage/storageserver/service_layer_error_listener.cpp
blob: e41a947b6fbda5e7871e2e73c1aa73e82cbdea3c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "service_layer_error_listener.h"
#include <vespa/storage/common/storagecomponent.h>
#include <vespa/storage/storageserver/mergethrottler.h>

#include <vespa/log/log.h>
LOG_SETUP(".node.errorlistener");

namespace storage {

void ServiceLayerErrorListener::on_fatal_error(vespalib::stringref message) {
    bool expected = false;
    if (_shutdown_initiated.compare_exchange_strong(expected, true)) {
        LOG(info,
            "Received FATAL_ERROR from persistence provider, "
            "shutting down node: %s",
            vespalib::string(message).c_str());
        _component.requestShutdown(message); // Thread safe
    } else {
        LOG(debug,
            "Received FATAL_ERROR from persistence provider: %s. "
            "Node has already been instructed to shut down so "
            "not doing anything now.",
            vespalib::string(message).c_str());
    }
}

void ServiceLayerErrorListener::on_resource_exhaustion_error(vespalib::stringref message) {
    LOG(debug, "SPI reports resource exhaustion ('%s'). "
                "Applying back-pressure to merge throttler",
        vespalib::string(message).c_str());
    _merge_throttler.apply_timed_backpressure(); // Thread safe
}

}