Skip to content

Commit

Permalink
DB IDO: Don't enqueue queries when the feature is paused (HA)
Browse files Browse the repository at this point in the history
fixes #5876
refs #6739
  • Loading branch information
Michael Friedrich committed Nov 13, 2018
1 parent 1a77d99 commit 0046dca
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
33 changes: 33 additions & 0 deletions lib/db_ido_mysql/idomysqlconnection.cpp
Expand Up @@ -162,6 +162,9 @@ void IdoMysqlConnection::TxTimerHandler()

void IdoMysqlConnection::NewTransaction()
{
if (IsPaused())
return;

#ifdef I2_DEBUG /* I2_DEBUG */
Log(LogDebug, "IdoMysqlConnection")
<< "Scheduling new transaction and finishing async queries.";
Expand Down Expand Up @@ -715,6 +718,9 @@ void IdoMysqlConnection::DiscardRows(const IdoMysqlResult& result)

void IdoMysqlConnection::ActivateObject(const DbObject::Ptr& dbobj)
{
if (IsPaused())
return;

#ifdef I2_DEBUG /* I2_DEBUG */
Log(LogDebug, "IdoMysqlConnection")
<< "Scheduling object activation task for '" << dbobj->GetName1() << "!" << dbobj->GetName2() << "'.";
Expand All @@ -727,6 +733,9 @@ void IdoMysqlConnection::InternalActivateObject(const DbObject::Ptr& dbobj)
{
AssertOnWorkQueue();

if (IsPaused())
return;

if (!GetConnected())
return;

Expand Down Expand Up @@ -754,6 +763,9 @@ void IdoMysqlConnection::InternalActivateObject(const DbObject::Ptr& dbobj)

void IdoMysqlConnection::DeactivateObject(const DbObject::Ptr& dbobj)
{
if (IsPaused())
return;

#ifdef I2_DEBUG /* I2_DEBUG */
Log(LogDebug, "IdoMysqlConnection")
<< "Scheduling object deactivation task for '" << dbobj->GetName1() << "!" << dbobj->GetName2() << "'.";
Expand All @@ -766,6 +778,9 @@ void IdoMysqlConnection::InternalDeactivateObject(const DbObject::Ptr& dbobj)
{
AssertOnWorkQueue();

if (IsPaused())
return;

if (!GetConnected())
return;

Expand Down Expand Up @@ -855,6 +870,9 @@ bool IdoMysqlConnection::FieldToEscapedString(const String& key, const Value& va

void IdoMysqlConnection::ExecuteQuery(const DbQuery& query)
{
if (IsPaused())
return;

ASSERT(query.Category != DbCatInvalid);

#ifdef I2_DEBUG /* I2_DEBUG */
Expand All @@ -867,6 +885,9 @@ void IdoMysqlConnection::ExecuteQuery(const DbQuery& query)

void IdoMysqlConnection::ExecuteMultipleQueries(const std::vector<DbQuery>& queries)
{
if (IsPaused())
return;

if (queries.empty())
return;

Expand Down Expand Up @@ -914,6 +935,9 @@ void IdoMysqlConnection::InternalExecuteMultipleQueries(const std::vector<DbQuer
{
AssertOnWorkQueue();

if (IsPaused())
return;

if (!GetConnected())
return;

Expand Down Expand Up @@ -942,6 +966,9 @@ void IdoMysqlConnection::InternalExecuteQuery(const DbQuery& query, int typeOver
{
AssertOnWorkQueue();

if (IsPaused())
return;

if (!GetConnected())
return;

Expand Down Expand Up @@ -1129,6 +1156,9 @@ void IdoMysqlConnection::FinishExecuteQuery(const DbQuery& query, int type, bool

void IdoMysqlConnection::CleanUpExecuteQuery(const String& table, const String& time_column, double max_age)
{
if (IsPaused())
return;

#ifdef I2_DEBUG /* I2_DEBUG */
Log(LogDebug, "IdoMysqlConnection")
<< "Rescheduling cleanup query for table '" << table << "' and column '"
Expand All @@ -1142,6 +1172,9 @@ void IdoMysqlConnection::InternalCleanUpExecuteQuery(const String& table, const
{
AssertOnWorkQueue();

if (IsPaused())
return;

if (!GetConnected())
return;

Expand Down
24 changes: 24 additions & 0 deletions lib/db_ido_pgsql/idopgsqlconnection.cpp
Expand Up @@ -163,6 +163,9 @@ void IdoPgsqlConnection::TxTimerHandler()

void IdoPgsqlConnection::NewTransaction()
{
if (IsPaused())
return;

m_QueryQueue.Enqueue(std::bind(&IdoPgsqlConnection::InternalNewTransaction, this), PriorityHigh, true);
}

Expand Down Expand Up @@ -569,6 +572,9 @@ Dictionary::Ptr IdoPgsqlConnection::FetchRow(const IdoPgsqlResult& result, int r

void IdoPgsqlConnection::ActivateObject(const DbObject::Ptr& dbobj)
{
if (IsPaused())
return;

m_QueryQueue.Enqueue(std::bind(&IdoPgsqlConnection::InternalActivateObject, this, dbobj), PriorityLow);
}

Expand Down Expand Up @@ -603,6 +609,9 @@ void IdoPgsqlConnection::InternalActivateObject(const DbObject::Ptr& dbobj)

void IdoPgsqlConnection::DeactivateObject(const DbObject::Ptr& dbobj)
{
if (IsPaused())
return;

m_QueryQueue.Enqueue(std::bind(&IdoPgsqlConnection::InternalDeactivateObject, this, dbobj), PriorityLow);
}

Expand Down Expand Up @@ -699,13 +708,19 @@ bool IdoPgsqlConnection::FieldToEscapedString(const String& key, const Value& va

void IdoPgsqlConnection::ExecuteQuery(const DbQuery& query)
{
if (IsPaused())
return;

ASSERT(query.Category != DbCatInvalid);

m_QueryQueue.Enqueue(std::bind(&IdoPgsqlConnection::InternalExecuteQuery, this, query, -1), query.Priority, true);
}

void IdoPgsqlConnection::ExecuteMultipleQueries(const std::vector<DbQuery>& queries)
{
if (IsPaused())
return;

if (queries.empty())
return;

Expand Down Expand Up @@ -748,6 +763,9 @@ void IdoPgsqlConnection::InternalExecuteMultipleQueries(const std::vector<DbQuer
{
AssertOnWorkQueue();

if (IsPaused())
return;

if (!GetConnected())
return;

Expand All @@ -769,6 +787,9 @@ void IdoPgsqlConnection::InternalExecuteQuery(const DbQuery& query, int typeOver
{
AssertOnWorkQueue();

if (IsPaused())
return;

if (!GetConnected())
return;

Expand Down Expand Up @@ -933,6 +954,9 @@ void IdoPgsqlConnection::InternalExecuteQuery(const DbQuery& query, int typeOver

void IdoPgsqlConnection::CleanUpExecuteQuery(const String& table, const String& time_column, double max_age)
{
if (IsPaused())
return;

m_QueryQueue.Enqueue(std::bind(&IdoPgsqlConnection::InternalCleanUpExecuteQuery, this, table, time_column, max_age), PriorityLow, true);
}

Expand Down

0 comments on commit 0046dca

Please sign in to comment.