1) The value in pins->stack_ends_here is actually incorrect. This value is
calculated when the thread is initialized in my_thread_init(). The problem is
that the value doesn't take into account existing stack usage and just adds the
thread stack size to calculate the beginning of the stack.

2) _lf_pinbox_real_free() is using alloca() in a very unsafe way. alloca()
should only be used by leaf functions, since you cannot predict the amount of
stack space that non-leaf functions will use. As pins->stack_ends_here is
calculated in wrong way and there is no window for the qsort() which is invoked
from _lf_pinbox_real_free() after alloca(), stack overflow can take place.

The solution:

1) Take into accout the current stack offset when stack size is calculated
in my_thread_init();

2) Don't allocate the whole free stack space in _lf_pinbox_real_free(),
take some window for qsort();

Prevent wsrep applier/replication threads from being counted towards connection_count, since it is meant for client connections than replication threads. This prevents the issue wherein high value of wsrep-slave-threads would cause max_connections threshold to be hit as "ERROR 1040 (HY000): Too many connections".

The fix has been partially ported from mariadb-5.5 tree where it was fixed as part of MDEV-6206.

Bug#1280828 wsrep_dump_rbr_buf in wsrep_apply_cb should be avoided for (ignored) TOI errors

This is required to avoid DOS-ing the applier nodes with GRA* files in
This is case of failed DDLs. particularly required for DDLs because they
This is are replicated as part of TOI before they are verified to be
This is correct or not.