why not check "if (heap->bh_size >= heap->bh_space)" outside this function to avoid calling this function when not necessary? This check was there in code before the patch.
patch 0003:
+/* + * The threshold of the number of transactions in the max-heap (rb->txn_heap) + * to switch the state. + */ +#define REORDE_BUFFER_MEM_TRACK_THRESHOLD 1024