diff --git a/maxutils/maxbase/include/maxbase/worker.hh b/maxutils/maxbase/include/maxbase/worker.hh index 5412bf4f8..88525ea7e 100644 --- a/maxutils/maxbase/include/maxbase/worker.hh +++ b/maxutils/maxbase/include/maxbase/worker.hh @@ -300,7 +300,8 @@ public: IDLE, POLLING, PROCESSING, - ZPROCESSING + ZPROCESSING, + FINISHED }; enum execute_mode_t diff --git a/maxutils/maxbase/src/worker.cc b/maxutils/maxbase/src/worker.cc index 5c6cb2172..e1231b251 100644 --- a/maxutils/maxbase/src/worker.cc +++ b/maxutils/maxbase/src/worker.cc @@ -523,9 +523,9 @@ bool Worker::post_message(uint32_t msg_id, intptr_t arg1, intptr_t arg2) // TODO: Enable and fix this in develop and/or 2.4: The deletion of rworker_local is done after the // workers have stopped and it triggers this assertion. - // mxb_assert(state() != Worker::STOPPED); + // mxb_assert(state() != Worker::FINISHED); - if (state() != Worker::STOPPED) + if (state() != Worker::FINISHED) { MessageQueue::Message message(msg_id, arg1, arg2); rval = m_pQueue->post(message); @@ -536,7 +536,7 @@ bool Worker::post_message(uint32_t msg_id, intptr_t arg1, intptr_t arg2) void Worker::run(mxb::Semaphore* pSem) { - mxb_assert(m_state == STOPPED); + mxb_assert(m_state == STOPPED || m_state == FINISHED); this_thread.pCurrent_worker = this; if (pre_run()) @@ -550,7 +550,7 @@ void Worker::run(mxb::Semaphore* pSem) poll_waitevents(); - m_state = STOPPED; + m_state = FINISHED; post_run(); MXB_INFO("Worker %p has shut down.", this); diff --git a/server/core/monitor.cc b/server/core/monitor.cc index 1d2fb6828..a96816507 100644 --- a/server/core/monitor.cc +++ b/server/core/monitor.cc @@ -2566,7 +2566,11 @@ bool MonitorInstance::start(const MXS_CONFIG_PARAMETER* pParams) // not exist during program start/stop. mxb_assert(mxs_rworker_get_current() == NULL || mxs_rworker_get_current() == mxs_rworker_get(MXS_RWORKER_MAIN)); - mxb_assert(Worker::state() == Worker::STOPPED); + + // This can be a bit confusing as the workers are considered to be "finished" when the stop processing. A + // better distinction between workers that temporarily stop and permanently stop should be implemented. + mxb_assert(Worker::state() == Worker::STOPPED || Worker::state() == Worker::FINISHED); + mxb_assert(monitor_state() == MONITOR_STATE_STOPPED); mxb_assert(m_thread_running.load() == false);