mirror of https://github.com/Icinga/icinga2.git
Merge pull request #8915 from Icinga/bugfix/icingadb-prio-state
Icinga DB: priorize state > config
This commit is contained in:
commit
2d75bbd8ed
|
@ -136,10 +136,10 @@ void IcingaDB::UpdateAllConfigObjects()
|
||||||
std::vector<Type::Ptr> types = GetTypes();
|
std::vector<Type::Ptr> types = GetTypes();
|
||||||
|
|
||||||
m_Rcon->SuppressQueryKind(Prio::CheckResult);
|
m_Rcon->SuppressQueryKind(Prio::CheckResult);
|
||||||
m_Rcon->SuppressQueryKind(Prio::State);
|
m_Rcon->SuppressQueryKind(Prio::RuntimeStateSync);
|
||||||
|
|
||||||
Defer unSuppress ([this]() {
|
Defer unSuppress ([this]() {
|
||||||
m_Rcon->UnsuppressQueryKind(Prio::State);
|
m_Rcon->UnsuppressQueryKind(Prio::RuntimeStateSync);
|
||||||
m_Rcon->UnsuppressQueryKind(Prio::CheckResult);
|
m_Rcon->UnsuppressQueryKind(Prio::CheckResult);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1078,8 +1078,8 @@ void IcingaDB::UpdateState(const Checkable::Ptr& checkable)
|
||||||
|
|
||||||
Dictionary::Ptr stateAttrs = SerializeState(checkable);
|
Dictionary::Ptr stateAttrs = SerializeState(checkable);
|
||||||
|
|
||||||
m_Rcon->FireAndForgetQuery({"HSET", m_PrefixConfigObject + objectType + ":state", objectKey, JsonEncode(stateAttrs)}, Prio::State);
|
m_Rcon->FireAndForgetQuery({"HSET", m_PrefixConfigObject + objectType + ":state", objectKey, JsonEncode(stateAttrs)}, Prio::RuntimeStateSync);
|
||||||
m_Rcon->FireAndForgetQuery({"HSET", m_PrefixConfigCheckSum + objectType + ":state", objectKey, JsonEncode(new Dictionary({{"checksum", HashValue(stateAttrs)}}))}, Prio::State);
|
m_Rcon->FireAndForgetQuery({"HSET", m_PrefixConfigCheckSum + objectType + ":state", objectKey, JsonEncode(new Dictionary({{"checksum", HashValue(stateAttrs)}}))}, Prio::RuntimeStateSync);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1101,8 +1101,8 @@ void IcingaDB::SendConfigUpdate(const ConfigObject::Ptr& object, bool runtimeUpd
|
||||||
Dictionary::Ptr state = SerializeState(checkable);
|
Dictionary::Ptr state = SerializeState(checkable);
|
||||||
String checksum = HashValue(state);
|
String checksum = HashValue(state);
|
||||||
|
|
||||||
m_Rcon->FireAndForgetQuery({"HSET", m_PrefixConfigObject + typeName + ":state", objectKey, JsonEncode(state)}, Prio::State);
|
m_Rcon->FireAndForgetQuery({"HSET", m_PrefixConfigObject + typeName + ":state", objectKey, JsonEncode(state)}, Prio::RuntimeStateSync);
|
||||||
m_Rcon->FireAndForgetQuery({"HSET", m_PrefixConfigCheckSum + typeName + ":state", objectKey, JsonEncode(new Dictionary({{"checksum", checksum}}))}, Prio::State);
|
m_Rcon->FireAndForgetQuery({"HSET", m_PrefixConfigCheckSum + typeName + ":state", objectKey, JsonEncode(new Dictionary({{"checksum", checksum}}))}, Prio::RuntimeStateSync);
|
||||||
|
|
||||||
if (runtimeUpdate) {
|
if (runtimeUpdate) {
|
||||||
state->Set("checksum", checksum);
|
state->Set("checksum", checksum);
|
||||||
|
@ -1538,14 +1538,14 @@ void IcingaDB::SendStatusUpdate(const ConfigObject::Ptr& object, const CheckResu
|
||||||
objectAttrs->Set("runtime_type", "upsert");
|
objectAttrs->Set("runtime_type", "upsert");
|
||||||
objectAttrs->Set("checksum", HashValue(objectAttrs));
|
objectAttrs->Set("checksum", HashValue(objectAttrs));
|
||||||
|
|
||||||
std::vector<String> streamadd({"XADD", "icinga:runtime", "MAXLEN", "~", "1000000", "*"});
|
std::vector<String> streamadd({"XADD", "icinga:runtime:state", "MAXLEN", "~", "1000000", "*"});
|
||||||
ObjectLock olock(objectAttrs);
|
ObjectLock olock(objectAttrs);
|
||||||
for (const Dictionary::Pair& kv : objectAttrs) {
|
for (const Dictionary::Pair& kv : objectAttrs) {
|
||||||
streamadd.emplace_back(kv.first);
|
streamadd.emplace_back(kv.first);
|
||||||
streamadd.emplace_back(IcingaToStreamValue(kv.second));
|
streamadd.emplace_back(IcingaToStreamValue(kv.second));
|
||||||
}
|
}
|
||||||
|
|
||||||
m_Rcon->FireAndForgetQuery(std::move(streamadd), Prio::State);
|
m_Rcon->FireAndForgetQuery(std::move(streamadd), Prio::RuntimeStateStream);
|
||||||
|
|
||||||
int hard_state;
|
int hard_state;
|
||||||
if (!cr) {
|
if (!cr) {
|
||||||
|
|
|
@ -92,7 +92,7 @@ void IcingaDB::Start(bool runtimeCreated)
|
||||||
m_WorkQueue.SetName("IcingaDB");
|
m_WorkQueue.SetName("IcingaDB");
|
||||||
|
|
||||||
m_Rcon->SuppressQueryKind(Prio::CheckResult);
|
m_Rcon->SuppressQueryKind(Prio::CheckResult);
|
||||||
m_Rcon->SuppressQueryKind(Prio::State);
|
m_Rcon->SuppressQueryKind(Prio::RuntimeStateSync);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IcingaDB::ExceptionHandler(boost::exception_ptr exp)
|
void IcingaDB::ExceptionHandler(boost::exception_ptr exp)
|
||||||
|
|
|
@ -64,8 +64,9 @@ namespace icinga
|
||||||
enum class QueryPriority : unsigned char
|
enum class QueryPriority : unsigned char
|
||||||
{
|
{
|
||||||
Heartbeat,
|
Heartbeat,
|
||||||
Config,
|
RuntimeStateStream, // runtime state updates, doesn't affect initially synced states
|
||||||
State,
|
Config, // includes initially synced states
|
||||||
|
RuntimeStateSync, // updates initially synced states at runtime, in parallel to config dump, therefore must be < Config
|
||||||
History,
|
History,
|
||||||
CheckResult,
|
CheckResult,
|
||||||
SyncConnection = 255
|
SyncConnection = 255
|
||||||
|
|
Loading…
Reference in New Issue