Fix backend DCB writeq throttling

The callbacks iterated over all threads when only the local ones must be
iterated. This prevents a deadlock from occurring when multiple threads
start throttling at the same time.

Also fixed the gwbuf_append debug assertion.
This commit is contained in:
Markus Mäkelä
2018-10-19 13:44:21 +03:00
parent 4be5d9267d
commit f461ab428e
2 changed files with 5 additions and 4 deletions

View File

@ -450,6 +450,9 @@ int gwbuf_compare(const GWBUF* lhs, const GWBUF* rhs)
GWBUF* gwbuf_append(GWBUF* head, GWBUF* tail) GWBUF* gwbuf_append(GWBUF* head, GWBUF* tail)
{ {
mxb_assert(!head || head->owner == RoutingWorker::get_current_id());
mxb_assert(!tail || tail->owner == RoutingWorker::get_current_id());
if (!head) if (!head)
{ {
return tail; return tail;
@ -459,8 +462,6 @@ GWBUF* gwbuf_append(GWBUF* head, GWBUF* tail)
return head; return head;
} }
mxb_assert(head->owner == RoutingWorker::get_current_id()
&& tail->owner == RoutingWorker::get_current_id());
head->tail->next = tail; head->tail->next = tail;
head->tail = tail->tail; head->tail = tail->tail;

View File

@ -3768,11 +3768,11 @@ static int downstream_throttle_callback(DCB* dcb, DCB_REASON reason, void* userd
{ {
if (reason == DCB_REASON_HIGH_WATER) if (reason == DCB_REASON_HIGH_WATER)
{ {
dcb_foreach(backend_dcb_remove_func, dcb->session); dcb_foreach_local(backend_dcb_remove_func, dcb->session);
} }
else if (reason == DCB_REASON_LOW_WATER) else if (reason == DCB_REASON_LOW_WATER)
{ {
dcb_foreach(backend_dcb_add_func, dcb->session); dcb_foreach_local(backend_dcb_add_func, dcb->session);
} }
return 0; return 0;