mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-23 13:45:04 +02:00
Merge pull request #8730 from Icinga/bugfix/ido-stop-progstat-8727
IDO: update program status on stop
This commit is contained in:
commit
bee83ead8b
@ -87,8 +87,6 @@ void DbConnection::Resume()
|
|||||||
|
|
||||||
void DbConnection::Pause()
|
void DbConnection::Pause()
|
||||||
{
|
{
|
||||||
ConfigObject::Pause();
|
|
||||||
|
|
||||||
Log(LogInformation, "DbConnection")
|
Log(LogInformation, "DbConnection")
|
||||||
<< "Pausing IDO connection: " << GetName();
|
<< "Pausing IDO connection: " << GetName();
|
||||||
|
|
||||||
@ -105,7 +103,9 @@ void DbConnection::Pause()
|
|||||||
|
|
||||||
query1.Fields = new Dictionary({
|
query1.Fields = new Dictionary({
|
||||||
{ "instance_id", 0 }, /* DbConnection class fills in real ID */
|
{ "instance_id", 0 }, /* DbConnection class fills in real ID */
|
||||||
{ "program_end_time", DbValue::FromTimestamp(Utility::GetTime()) }
|
{ "program_end_time", DbValue::FromTimestamp(Utility::GetTime()) },
|
||||||
|
{ "is_currently_running", 0 },
|
||||||
|
{ "process_id", Empty }
|
||||||
});
|
});
|
||||||
|
|
||||||
query1.Priority = PriorityHigh;
|
query1.Priority = PriorityHigh;
|
||||||
@ -113,6 +113,13 @@ void DbConnection::Pause()
|
|||||||
ExecuteQuery(query1);
|
ExecuteQuery(query1);
|
||||||
|
|
||||||
NewTransaction();
|
NewTransaction();
|
||||||
|
|
||||||
|
m_QueryQueue.Enqueue([this]() { Disconnect(); }, PriorityLow);
|
||||||
|
|
||||||
|
/* Work on remaining tasks but never delete the threads, for HA resuming later. */
|
||||||
|
m_QueryQueue.Join();
|
||||||
|
|
||||||
|
ConfigObject::Pause();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DbConnection::InitializeDbTimer()
|
void DbConnection::InitializeDbTimer()
|
||||||
|
@ -75,6 +75,7 @@ protected:
|
|||||||
virtual void CleanUpExecuteQuery(const String& table, const String& time_column, double max_age);
|
virtual void CleanUpExecuteQuery(const String& table, const String& time_column, double max_age);
|
||||||
virtual void FillIDCache(const DbType::Ptr& type) = 0;
|
virtual void FillIDCache(const DbType::Ptr& type) = 0;
|
||||||
virtual void NewTransaction() = 0;
|
virtual void NewTransaction() = 0;
|
||||||
|
virtual void Disconnect() = 0;
|
||||||
|
|
||||||
void UpdateObject(const ConfigObject::Ptr& object);
|
void UpdateObject(const ConfigObject::Ptr& object);
|
||||||
void UpdateAllObjects();
|
void UpdateAllObjects();
|
||||||
|
@ -105,11 +105,6 @@ void IdoMysqlConnection::Pause()
|
|||||||
<< "Rescheduling disconnect task.";
|
<< "Rescheduling disconnect task.";
|
||||||
#endif /* I2_DEBUG */
|
#endif /* I2_DEBUG */
|
||||||
|
|
||||||
m_QueryQueue.Enqueue([this]() { Disconnect(); }, PriorityLow);
|
|
||||||
|
|
||||||
/* Work on remaining tasks but never delete the threads, for HA resuming later. */
|
|
||||||
m_QueryQueue.Join();
|
|
||||||
|
|
||||||
Log(LogInformation, "IdoMysqlConnection")
|
Log(LogInformation, "IdoMysqlConnection")
|
||||||
<< "'" << GetName() << "' paused.";
|
<< "'" << GetName() << "' paused.";
|
||||||
|
|
||||||
@ -152,7 +147,7 @@ void IdoMysqlConnection::Disconnect()
|
|||||||
|
|
||||||
void IdoMysqlConnection::NewTransaction()
|
void IdoMysqlConnection::NewTransaction()
|
||||||
{
|
{
|
||||||
if (IsPaused())
|
if (IsPaused() && GetPauseCalled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#ifdef I2_DEBUG /* I2_DEBUG */
|
#ifdef I2_DEBUG /* I2_DEBUG */
|
||||||
@ -845,7 +840,9 @@ bool IdoMysqlConnection::FieldToEscapedString(const String& key, const Value& va
|
|||||||
|
|
||||||
Value rawvalue = DbValue::ExtractValue(value);
|
Value rawvalue = DbValue::ExtractValue(value);
|
||||||
|
|
||||||
if (rawvalue.IsObjectType<ConfigObject>()) {
|
if (rawvalue.GetType() == ValueEmpty) {
|
||||||
|
*result = "NULL";
|
||||||
|
} else if (rawvalue.IsObjectType<ConfigObject>()) {
|
||||||
DbObject::Ptr dbobjcol = DbObject::GetOrCreateByObject(rawvalue);
|
DbObject::Ptr dbobjcol = DbObject::GetOrCreateByObject(rawvalue);
|
||||||
|
|
||||||
if (!dbobjcol) {
|
if (!dbobjcol) {
|
||||||
@ -906,7 +903,7 @@ bool IdoMysqlConnection::FieldToEscapedString(const String& key, const Value& va
|
|||||||
|
|
||||||
void IdoMysqlConnection::ExecuteQuery(const DbQuery& query)
|
void IdoMysqlConnection::ExecuteQuery(const DbQuery& query)
|
||||||
{
|
{
|
||||||
if (IsPaused())
|
if (IsPaused() && GetPauseCalled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ASSERT(query.Category != DbCatInvalid);
|
ASSERT(query.Category != DbCatInvalid);
|
||||||
@ -958,9 +955,6 @@ bool IdoMysqlConnection::CanExecuteQuery(const DbQuery& query)
|
|||||||
for (const Dictionary::Pair& kv : query.Fields) {
|
for (const Dictionary::Pair& kv : query.Fields) {
|
||||||
Value value;
|
Value value;
|
||||||
|
|
||||||
if (kv.second.IsEmpty() && !kv.second.IsString())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!FieldToEscapedString(kv.first, kv.second, &value))
|
if (!FieldToEscapedString(kv.first, kv.second, &value))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1009,7 +1003,7 @@ void IdoMysqlConnection::InternalExecuteQuery(const DbQuery& query, int typeOver
|
|||||||
{
|
{
|
||||||
AssertOnWorkQueue();
|
AssertOnWorkQueue();
|
||||||
|
|
||||||
if (IsPaused()) {
|
if (IsPaused() && GetPauseCalled()) {
|
||||||
DecreasePendingQueries(1);
|
DecreasePendingQueries(1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1137,9 +1131,6 @@ void IdoMysqlConnection::InternalExecuteQuery(const DbQuery& query, int typeOver
|
|||||||
for (const Dictionary::Pair& kv : query.Fields) {
|
for (const Dictionary::Pair& kv : query.Fields) {
|
||||||
Value value;
|
Value value;
|
||||||
|
|
||||||
if (kv.second.IsEmpty() && !kv.second.IsString())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!FieldToEscapedString(kv.first, kv.second, &value)) {
|
if (!FieldToEscapedString(kv.first, kv.second, &value)) {
|
||||||
|
|
||||||
#ifdef I2_DEBUG /* I2_DEBUG */
|
#ifdef I2_DEBUG /* I2_DEBUG */
|
||||||
|
@ -51,6 +51,7 @@ protected:
|
|||||||
void CleanUpExecuteQuery(const String& table, const String& time_key, double time_value) override;
|
void CleanUpExecuteQuery(const String& table, const String& time_key, double time_value) override;
|
||||||
void FillIDCache(const DbType::Ptr& type) override;
|
void FillIDCache(const DbType::Ptr& type) override;
|
||||||
void NewTransaction() override;
|
void NewTransaction() override;
|
||||||
|
void Disconnect() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DbReference m_InstanceID;
|
DbReference m_InstanceID;
|
||||||
@ -82,7 +83,6 @@ private:
|
|||||||
void InternalActivateObject(const DbObject::Ptr& dbobj);
|
void InternalActivateObject(const DbObject::Ptr& dbobj);
|
||||||
void InternalDeactivateObject(const DbObject::Ptr& dbobj);
|
void InternalDeactivateObject(const DbObject::Ptr& dbobj);
|
||||||
|
|
||||||
void Disconnect();
|
|
||||||
void Reconnect();
|
void Reconnect();
|
||||||
|
|
||||||
void AssertOnWorkQueue();
|
void AssertOnWorkQueue();
|
||||||
|
@ -104,11 +104,6 @@ void IdoPgsqlConnection::Pause()
|
|||||||
|
|
||||||
m_ReconnectTimer.reset();
|
m_ReconnectTimer.reset();
|
||||||
|
|
||||||
m_QueryQueue.Enqueue([this]() { Disconnect(); }, PriorityLow);
|
|
||||||
|
|
||||||
/* Work on remaining tasks but never delete the threads, for HA resuming later. */
|
|
||||||
m_QueryQueue.Join();
|
|
||||||
|
|
||||||
Log(LogInformation, "IdoPgsqlConnection")
|
Log(LogInformation, "IdoPgsqlConnection")
|
||||||
<< "'" << GetName() << "' paused.";
|
<< "'" << GetName() << "' paused.";
|
||||||
}
|
}
|
||||||
@ -659,7 +654,9 @@ bool IdoPgsqlConnection::FieldToEscapedString(const String& key, const Value& va
|
|||||||
|
|
||||||
Value rawvalue = DbValue::ExtractValue(value);
|
Value rawvalue = DbValue::ExtractValue(value);
|
||||||
|
|
||||||
if (rawvalue.IsObjectType<ConfigObject>()) {
|
if (rawvalue.GetType() == ValueEmpty) {
|
||||||
|
*result = "NULL";
|
||||||
|
} else if (rawvalue.IsObjectType<ConfigObject>()) {
|
||||||
DbObject::Ptr dbobjcol = DbObject::GetOrCreateByObject(rawvalue);
|
DbObject::Ptr dbobjcol = DbObject::GetOrCreateByObject(rawvalue);
|
||||||
|
|
||||||
if (!dbobjcol) {
|
if (!dbobjcol) {
|
||||||
@ -720,7 +717,7 @@ bool IdoPgsqlConnection::FieldToEscapedString(const String& key, const Value& va
|
|||||||
|
|
||||||
void IdoPgsqlConnection::ExecuteQuery(const DbQuery& query)
|
void IdoPgsqlConnection::ExecuteQuery(const DbQuery& query)
|
||||||
{
|
{
|
||||||
if (IsPaused())
|
if (IsPaused() && GetPauseCalled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ASSERT(query.Category != DbCatInvalid);
|
ASSERT(query.Category != DbCatInvalid);
|
||||||
@ -762,9 +759,6 @@ bool IdoPgsqlConnection::CanExecuteQuery(const DbQuery& query)
|
|||||||
for (const Dictionary::Pair& kv : query.Fields) {
|
for (const Dictionary::Pair& kv : query.Fields) {
|
||||||
Value value;
|
Value value;
|
||||||
|
|
||||||
if (kv.second.IsEmpty() && !kv.second.IsString())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!FieldToEscapedString(kv.first, kv.second, &value))
|
if (!FieldToEscapedString(kv.first, kv.second, &value))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -805,7 +799,7 @@ void IdoPgsqlConnection::InternalExecuteQuery(const DbQuery& query, int typeOver
|
|||||||
{
|
{
|
||||||
AssertOnWorkQueue();
|
AssertOnWorkQueue();
|
||||||
|
|
||||||
if (IsPaused()) {
|
if (IsPaused() && GetPauseCalled()) {
|
||||||
DecreasePendingQueries(1);
|
DecreasePendingQueries(1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -918,9 +912,6 @@ void IdoPgsqlConnection::InternalExecuteQuery(const DbQuery& query, int typeOver
|
|||||||
Value value;
|
Value value;
|
||||||
bool first = true;
|
bool first = true;
|
||||||
for (const Dictionary::Pair& kv : query.Fields) {
|
for (const Dictionary::Pair& kv : query.Fields) {
|
||||||
if (kv.second.IsEmpty() && !kv.second.IsString())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!FieldToEscapedString(kv.first, kv.second, &value)) {
|
if (!FieldToEscapedString(kv.first, kv.second, &value)) {
|
||||||
m_QueryQueue.Enqueue([this, query]() { InternalExecuteQuery(query, -1); }, query.Priority);
|
m_QueryQueue.Enqueue([this, query]() { InternalExecuteQuery(query, -1); }, query.Priority);
|
||||||
return;
|
return;
|
||||||
|
@ -44,6 +44,7 @@ protected:
|
|||||||
void CleanUpExecuteQuery(const String& table, const String& time_key, double time_value) override;
|
void CleanUpExecuteQuery(const String& table, const String& time_key, double time_value) override;
|
||||||
void FillIDCache(const DbType::Ptr& type) override;
|
void FillIDCache(const DbType::Ptr& type) override;
|
||||||
void NewTransaction() override;
|
void NewTransaction() override;
|
||||||
|
void Disconnect() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DbReference m_InstanceID;
|
DbReference m_InstanceID;
|
||||||
@ -67,7 +68,6 @@ private:
|
|||||||
void InternalActivateObject(const DbObject::Ptr& dbobj);
|
void InternalActivateObject(const DbObject::Ptr& dbobj);
|
||||||
void InternalDeactivateObject(const DbObject::Ptr& dbobj);
|
void InternalDeactivateObject(const DbObject::Ptr& dbobj);
|
||||||
|
|
||||||
void Disconnect();
|
|
||||||
void InternalNewTransaction();
|
void InternalNewTransaction();
|
||||||
void Reconnect();
|
void Reconnect();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user