You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

706 lines
19 KiB

  1. /*****************************************************************************
  2. Copyright (c) 2011, 2012, Oracle and/or its affiliates. All Rights Reserved.
  3. Portions of this file contain modifications contributed and copyrighted by
  4. Google, Inc. Those modifications are gratefully acknowledged and are described
  5. briefly in the InnoDB documentation. The contributions by Google are
  6. incorporated with their permission, and subject to the conditions contained in
  7. the file COPYING.Google.
  8. Portions of this file contain modifications contributed and copyrighted
  9. by Percona Inc.. Those modifications are
  10. gratefully acknowledged and are described briefly in the InnoDB
  11. documentation. The contributions by Percona Inc. are incorporated with
  12. their permission, and subject to the conditions contained in the file
  13. COPYING.Percona.
  14. This program is free software; you can redistribute it and/or modify it under
  15. the terms of the GNU General Public License as published by the Free Software
  16. Foundation; version 2 of the License.
  17. This program is distributed in the hope that it will be useful, but WITHOUT
  18. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  19. FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  20. You should have received a copy of the GNU General Public License along with
  21. this program; if not, write to the Free Software Foundation, Inc.,
  22. 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
  23. *****************************************************************************/
  24. /**************************************************//**
  25. @file srv/srv0conc.cc
  26. InnoDB concurrency manager
  27. Created 2011/04/18 Sunny Bains
  28. *******************************************************/
  29. #include "srv0srv.h"
  30. #include "sync0sync.h"
  31. #include "btr0types.h"
  32. #include "trx0trx.h"
  33. #include <mysql/plugin.h>
  34. #include <mysql/service_wsrep.h>
  35. /** Number of times a thread is allowed to enter InnoDB within the same
  36. SQL query after it has once got the ticket. */
  37. UNIV_INTERN ulong srv_n_free_tickets_to_enter = 500;
  38. #ifdef HAVE_ATOMIC_BUILTINS
  39. /** Maximum sleep delay (in micro-seconds), value of 0 disables it. */
  40. UNIV_INTERN ulong srv_adaptive_max_sleep_delay = 150000;
  41. #endif /* HAVE_ATOMIC_BUILTINS */
  42. UNIV_INTERN ulong srv_thread_sleep_delay = 10000;
  43. /** We are prepared for a situation that we have this many threads waiting for
  44. a semaphore inside InnoDB. innobase_start_or_create_for_mysql() sets the
  45. value. */
  46. UNIV_INTERN ulint srv_max_n_threads = 0;
  47. /** The following controls how many threads we let inside InnoDB concurrently:
  48. threads waiting for locks are not counted into the number because otherwise
  49. we could get a deadlock. Value of 0 will disable the concurrency check. */
  50. UNIV_INTERN ulong srv_thread_concurrency = 0;
  51. #ifndef HAVE_ATOMIC_BUILTINS
  52. /** This mutex protects srv_conc data structures */
  53. static os_fast_mutex_t srv_conc_mutex;
  54. /** Concurrency list node */
  55. typedef UT_LIST_NODE_T(struct srv_conc_slot_t) srv_conc_node_t;
  56. /** Slot for a thread waiting in the concurrency control queue. */
  57. struct srv_conc_slot_t{
  58. os_event_t event; /*!< event to wait */
  59. ibool reserved; /*!< TRUE if slot
  60. reserved */
  61. ibool wait_ended; /*!< TRUE when another thread has
  62. already set the event and the thread
  63. in this slot is free to proceed; but
  64. reserved may still be TRUE at that
  65. point */
  66. srv_conc_node_t srv_conc_queue; /*!< queue node */
  67. #ifdef WITH_WSREP
  68. void *thd; /*!< to see priority */
  69. #endif
  70. };
  71. /** Queue of threads waiting to get in */
  72. typedef UT_LIST_BASE_NODE_T(srv_conc_slot_t) srv_conc_queue_t;
  73. static srv_conc_queue_t srv_conc_queue;
  74. /** Array of wait slots */
  75. static srv_conc_slot_t* srv_conc_slots;
  76. #if defined(UNIV_PFS_MUTEX)
  77. /* Key to register srv_conc_mutex_key with performance schema */
  78. UNIV_INTERN mysql_pfs_key_t srv_conc_mutex_key;
  79. #endif /* UNIV_PFS_MUTEX */
  80. #endif /* !HAVE_ATOMIC_BUILTINS */
  81. /** Variables tracking the active and waiting threads. */
  82. struct srv_conc_t {
  83. char pad[64 - (sizeof(ulint) + sizeof(lint))];
  84. /** Number of transactions that have declared_to_be_inside_innodb set.
  85. It used to be a non-error for this value to drop below zero temporarily.
  86. This is no longer true. We'll, however, keep the lint datatype to add
  87. assertions to catch any corner cases that we may have missed. */
  88. volatile lint n_active;
  89. /** Number of OS threads waiting in the FIFO for permission to
  90. enter InnoDB */
  91. volatile lint n_waiting;
  92. };
  93. /* Control variables for tracking concurrency. */
  94. static srv_conc_t srv_conc;
  95. /*********************************************************************//**
  96. Initialise the concurrency management data structures */
  97. void
  98. srv_conc_init(void)
  99. /*===============*/
  100. {
  101. #ifndef HAVE_ATOMIC_BUILTINS
  102. ulint i;
  103. /* Init the server concurrency restriction data structures */
  104. os_fast_mutex_init(srv_conc_mutex_key, &srv_conc_mutex);
  105. UT_LIST_INIT(srv_conc_queue);
  106. srv_conc_slots = static_cast<srv_conc_slot_t*>(
  107. mem_zalloc(OS_THREAD_MAX_N * sizeof(*srv_conc_slots)));
  108. for (i = 0; i < OS_THREAD_MAX_N; i++) {
  109. srv_conc_slot_t* conc_slot = &srv_conc_slots[i];
  110. conc_slot->event = os_event_create();
  111. ut_a(conc_slot->event);
  112. #ifdef WITH_WSREP
  113. conc_slot->thd = NULL;
  114. #endif /* WITH_WSREP */
  115. }
  116. #endif /* !HAVE_ATOMIC_BUILTINS */
  117. }
  118. /*********************************************************************//**
  119. Free the concurrency management data structures */
  120. void
  121. srv_conc_free(void)
  122. /*===============*/
  123. {
  124. #ifndef HAVE_ATOMIC_BUILTINS
  125. os_fast_mutex_free(&srv_conc_mutex);
  126. mem_free(srv_conc_slots);
  127. srv_conc_slots = NULL;
  128. #endif /* !HAVE_ATOMIC_BUILTINS */
  129. }
  130. #ifdef HAVE_ATOMIC_BUILTINS
  131. /*********************************************************************//**
  132. Note that a user thread is entering InnoDB. */
  133. static
  134. void
  135. srv_enter_innodb_with_tickets(
  136. /*==========================*/
  137. trx_t* trx) /*!< in/out: transaction that wants
  138. to enter InnoDB */
  139. {
  140. trx->declared_to_be_inside_innodb = TRUE;
  141. trx->n_tickets_to_enter_innodb = srv_n_free_tickets_to_enter;
  142. }
  143. /*********************************************************************//**
  144. Handle the scheduling of a user thread that wants to enter InnoDB. Setting
  145. srv_adaptive_max_sleep_delay > 0 switches the adaptive sleep calibration to
  146. ON. When set, we want to wait in the queue for as little time as possible.
  147. However, very short waits will result in a lot of context switches and that
  148. is also not desirable. When threads need to sleep multiple times we increment
  149. os_thread_sleep_delay by one. When we see threads getting a slot without
  150. waiting and there are no other threads waiting in the queue, we try and reduce
  151. the wait as much as we can. Currently we reduce it by half each time. If the
  152. thread only had to wait for one turn before it was able to enter InnoDB we
  153. decrement it by one. This is to try and keep the sleep time stable around the
  154. "optimum" sleep time. */
  155. static
  156. void
  157. srv_conc_enter_innodb_with_atomics(
  158. /*===============================*/
  159. trx_t* trx) /*!< in/out: transaction that wants
  160. to enter InnoDB */
  161. {
  162. ulint n_sleeps = 0;
  163. ibool notified_mysql = FALSE;
  164. ut_a(!trx->declared_to_be_inside_innodb);
  165. for (;;) {
  166. ulint sleep_in_us;
  167. #ifdef WITH_WSREP
  168. if (wsrep_on(trx->mysql_thd) &&
  169. wsrep_trx_is_aborting(trx->mysql_thd)) {
  170. if (wsrep_debug)
  171. fprintf(stderr,
  172. "srv_conc_enter due to MUST_ABORT");
  173. srv_conc_force_enter_innodb(trx);
  174. return;
  175. }
  176. #endif /* WITH_WSREP */
  177. if (srv_conc.n_active < (lint) srv_thread_concurrency) {
  178. ulint n_active;
  179. /* Check if there are any free tickets. */
  180. n_active = os_atomic_increment_lint(
  181. &srv_conc.n_active, 1);
  182. if (n_active <= srv_thread_concurrency) {
  183. srv_enter_innodb_with_tickets(trx);
  184. if (notified_mysql) {
  185. (void) os_atomic_decrement_lint(
  186. &srv_conc.n_waiting, 1);
  187. thd_wait_end(trx->mysql_thd);
  188. }
  189. if (srv_adaptive_max_sleep_delay > 0) {
  190. if (srv_thread_sleep_delay > 20
  191. && n_sleeps == 1) {
  192. --srv_thread_sleep_delay;
  193. }
  194. if (srv_conc.n_waiting == 0) {
  195. srv_thread_sleep_delay >>= 1;
  196. }
  197. }
  198. return;
  199. }
  200. /* Since there were no free seats, we relinquish
  201. the overbooked ticket. */
  202. (void) os_atomic_decrement_lint(
  203. &srv_conc.n_active, 1);
  204. }
  205. if (!notified_mysql) {
  206. (void) os_atomic_increment_lint(
  207. &srv_conc.n_waiting, 1);
  208. /* Release possible search system latch this
  209. thread has */
  210. if (trx->has_search_latch) {
  211. trx_search_latch_release_if_reserved(trx);
  212. }
  213. thd_wait_begin(trx->mysql_thd, THD_WAIT_USER_LOCK);
  214. notified_mysql = TRUE;
  215. }
  216. trx->op_info = "sleeping before entering InnoDB";
  217. sleep_in_us = srv_thread_sleep_delay;
  218. /* Guard against overflow when adaptive sleep delay is on. */
  219. if (srv_adaptive_max_sleep_delay > 0
  220. && sleep_in_us > srv_adaptive_max_sleep_delay) {
  221. sleep_in_us = srv_adaptive_max_sleep_delay;
  222. srv_thread_sleep_delay = static_cast<ulong>(sleep_in_us);
  223. }
  224. os_thread_sleep(sleep_in_us);
  225. trx->innodb_que_wait_timer += sleep_in_us;
  226. trx->op_info = "";
  227. ++n_sleeps;
  228. if (srv_adaptive_max_sleep_delay > 0 && n_sleeps > 1) {
  229. ++srv_thread_sleep_delay;
  230. }
  231. }
  232. }
  233. /*********************************************************************//**
  234. Note that a user thread is leaving InnoDB code. */
  235. static
  236. void
  237. srv_conc_exit_innodb_with_atomics(
  238. /*==============================*/
  239. trx_t* trx) /*!< in/out: transaction */
  240. {
  241. trx->n_tickets_to_enter_innodb = 0;
  242. trx->declared_to_be_inside_innodb = FALSE;
  243. (void) os_atomic_decrement_lint(&srv_conc.n_active, 1);
  244. }
  245. #else
  246. /*********************************************************************//**
  247. Note that a user thread is leaving InnoDB code. */
  248. static
  249. void
  250. srv_conc_exit_innodb_without_atomics(
  251. /*=================================*/
  252. trx_t* trx) /*!< in/out: transaction */
  253. {
  254. srv_conc_slot_t* slot;
  255. os_fast_mutex_lock(&srv_conc_mutex);
  256. ut_ad(srv_conc.n_active > 0);
  257. srv_conc.n_active--;
  258. trx->declared_to_be_inside_innodb = FALSE;
  259. trx->n_tickets_to_enter_innodb = 0;
  260. slot = NULL;
  261. if (srv_conc.n_active < (lint) srv_thread_concurrency) {
  262. #ifdef WITH_WSREP
  263. srv_conc_slot_t* wsrep_slot;
  264. #endif
  265. /* Look for a slot where a thread is waiting and no other
  266. thread has yet released the thread */
  267. for (slot = UT_LIST_GET_FIRST(srv_conc_queue);
  268. slot != NULL && slot->wait_ended == TRUE;
  269. slot = UT_LIST_GET_NEXT(srv_conc_queue, slot)) {
  270. /* No op */
  271. }
  272. #ifdef WITH_WSREP
  273. /* look for aborting trx, they must be released asap */
  274. wsrep_slot= slot;
  275. while (wsrep_slot && (wsrep_slot->wait_ended == TRUE ||
  276. !wsrep_trx_is_aborting(wsrep_slot->thd))) {
  277. wsrep_slot = UT_LIST_GET_NEXT(srv_conc_queue, wsrep_slot);
  278. }
  279. if (wsrep_slot) {
  280. slot = wsrep_slot;
  281. if (wsrep_debug)
  282. fprintf(stderr, "WSREP: releasing aborting thd\n");
  283. }
  284. #endif
  285. if (slot != NULL) {
  286. slot->wait_ended = TRUE;
  287. /* We increment the count on behalf of the released
  288. thread */
  289. srv_conc.n_active++;
  290. }
  291. }
  292. os_fast_mutex_unlock(&srv_conc_mutex);
  293. if (slot != NULL) {
  294. os_event_set(slot->event);
  295. }
  296. }
  297. /*********************************************************************//**
  298. Handle the scheduling of a user thread that wants to enter InnoDB. */
  299. static
  300. void
  301. srv_conc_enter_innodb_without_atomics(
  302. /*==================================*/
  303. trx_t* trx) /*!< in/out: transaction that wants
  304. to enter InnoDB */
  305. {
  306. ulint i;
  307. srv_conc_slot_t* slot = NULL;
  308. ibool has_slept = FALSE;
  309. ib_uint64_t start_time = 0L;
  310. ib_uint64_t finish_time = 0L;
  311. ulint sec;
  312. ulint ms;
  313. os_fast_mutex_lock(&srv_conc_mutex);
  314. retry:
  315. if (UNIV_UNLIKELY(trx->declared_to_be_inside_innodb)) {
  316. os_fast_mutex_unlock(&srv_conc_mutex);
  317. ut_print_timestamp(stderr);
  318. fputs(" InnoDB: Error: trying to declare trx"
  319. " to enter InnoDB, but\n"
  320. "InnoDB: it already is declared.\n", stderr);
  321. trx_print(stderr, trx, 0);
  322. putc('\n', stderr);
  323. return;
  324. }
  325. ut_ad(srv_conc.n_active >= 0);
  326. if (srv_conc.n_active < (lint) srv_thread_concurrency) {
  327. srv_conc.n_active++;
  328. trx->declared_to_be_inside_innodb = TRUE;
  329. trx->n_tickets_to_enter_innodb = srv_n_free_tickets_to_enter;
  330. os_fast_mutex_unlock(&srv_conc_mutex);
  331. return;
  332. }
  333. #ifdef WITH_WSREP
  334. if (wsrep_on(trx->mysql_thd) &&
  335. wsrep_thd_is_brute_force(trx->mysql_thd)) {
  336. srv_conc_force_enter_innodb(trx);
  337. return;
  338. }
  339. #endif
  340. /* If the transaction is not holding resources, let it sleep
  341. for srv_thread_sleep_delay microseconds, and try again then */
  342. if (!has_slept && !trx->has_search_latch
  343. && NULL == UT_LIST_GET_FIRST(trx->lock.trx_locks)) {
  344. has_slept = TRUE; /* We let it sleep only once to avoid
  345. starvation */
  346. srv_conc.n_waiting++;
  347. os_fast_mutex_unlock(&srv_conc_mutex);
  348. trx->op_info = "sleeping before joining InnoDB queue";
  349. /* Peter Zaitsev suggested that we take the sleep away
  350. altogether. But the sleep may be good in pathological
  351. situations of lots of thread switches. Simply put some
  352. threads aside for a while to reduce the number of thread
  353. switches. */
  354. if (srv_thread_sleep_delay > 0) {
  355. os_thread_sleep(srv_thread_sleep_delay);
  356. trx->innodb_que_wait_timer += sleep_in_us;
  357. }
  358. trx->op_info = "";
  359. os_fast_mutex_lock(&srv_conc_mutex);
  360. srv_conc.n_waiting--;
  361. goto retry;
  362. }
  363. /* Too many threads inside: put the current thread to a queue */
  364. for (i = 0; i < OS_THREAD_MAX_N; i++) {
  365. slot = srv_conc_slots + i;
  366. if (!slot->reserved) {
  367. break;
  368. }
  369. }
  370. if (i == OS_THREAD_MAX_N) {
  371. /* Could not find a free wait slot, we must let the
  372. thread enter */
  373. srv_conc.n_active++;
  374. trx->declared_to_be_inside_innodb = TRUE;
  375. trx->n_tickets_to_enter_innodb = 0;
  376. os_fast_mutex_unlock(&srv_conc_mutex);
  377. return;
  378. }
  379. /* Release possible search system latch this thread has */
  380. if (trx->has_search_latch) {
  381. trx_search_latch_release_if_reserved(trx);
  382. }
  383. /* Add to the queue */
  384. slot->reserved = TRUE;
  385. slot->wait_ended = FALSE;
  386. #ifdef WITH_WSREP
  387. slot->thd = trx->mysql_thd;
  388. #endif
  389. UT_LIST_ADD_LAST(srv_conc_queue, srv_conc_queue, slot);
  390. os_event_reset(slot->event);
  391. srv_conc.n_waiting++;
  392. #ifdef WITH_WSREP
  393. if (wsrep_on(trx->mysql_thd) &&
  394. wsrep_trx_is_aborting(trx->mysql_thd)) {
  395. os_fast_mutex_unlock(&srv_conc_mutex);
  396. if (wsrep_debug)
  397. fprintf(stderr, "srv_conc_enter due to MUST_ABORT");
  398. trx->declared_to_be_inside_innodb = TRUE;
  399. trx->n_tickets_to_enter_innodb = srv_n_free_tickets_to_enter;
  400. return;
  401. }
  402. trx->wsrep_event = slot->event;
  403. #endif /* WITH_WSREP */
  404. os_fast_mutex_unlock(&srv_conc_mutex);
  405. /* Go to wait for the event; when a thread leaves InnoDB it will
  406. release this thread */
  407. ut_ad(!trx->has_search_latch);
  408. #ifdef UNIV_SYNC_DEBUG
  409. ut_ad(!sync_thread_levels_nonempty_trx(trx->has_search_latch));
  410. #endif /* UNIV_SYNC_DEBUG */
  411. if (UNIV_UNLIKELY(trx->take_stats)) {
  412. ut_usectime(&sec, &ms);
  413. start_time = (ib_uint64_t)sec * 1000000 + ms;
  414. } else {
  415. start_time = 0;
  416. }
  417. trx->op_info = "waiting in InnoDB queue";
  418. thd_wait_begin(trx->mysql_thd, THD_WAIT_USER_LOCK);
  419. os_event_wait(slot->event);
  420. thd_wait_end(trx->mysql_thd);
  421. #ifdef WITH_WSREP
  422. trx->wsrep_event = NULL;
  423. #endif /* WITH_WSREP */
  424. trx->op_info = "";
  425. if (UNIV_UNLIKELY(start_time != 0)) {
  426. ut_usectime(&sec, &ms);
  427. finish_time = (ib_uint64_t)sec * 1000000 + ms;
  428. trx->innodb_que_wait_timer += (ulint)(finish_time - start_time);
  429. }
  430. os_fast_mutex_lock(&srv_conc_mutex);
  431. srv_conc.n_waiting--;
  432. /* NOTE that the thread which released this thread already
  433. incremented the thread counter on behalf of this thread */
  434. slot->reserved = FALSE;
  435. #ifdef WITH_WSREP
  436. slot->thd = NULL;
  437. #endif
  438. UT_LIST_REMOVE(srv_conc_queue, srv_conc_queue, slot);
  439. trx->declared_to_be_inside_innodb = TRUE;
  440. trx->n_tickets_to_enter_innodb = srv_n_free_tickets_to_enter;
  441. os_fast_mutex_unlock(&srv_conc_mutex);
  442. }
  443. #endif /* HAVE_ATOMIC_BUILTINS */
  444. /*********************************************************************//**
  445. Puts an OS thread to wait if there are too many concurrent threads
  446. (>= srv_thread_concurrency) inside InnoDB. The threads wait in a FIFO queue. */
  447. UNIV_INTERN
  448. void
  449. srv_conc_enter_innodb(
  450. /*==================*/
  451. trx_t* trx) /*!< in: transaction object associated with the
  452. thread */
  453. {
  454. #ifdef UNIV_SYNC_DEBUG
  455. ut_ad(!sync_thread_levels_nonempty_trx(trx->has_search_latch));
  456. #endif /* UNIV_SYNC_DEBUG */
  457. #ifdef HAVE_ATOMIC_BUILTINS
  458. srv_conc_enter_innodb_with_atomics(trx);
  459. #else
  460. srv_conc_enter_innodb_without_atomics(trx);
  461. #endif /* HAVE_ATOMIC_BUILTINS */
  462. }
  463. /*********************************************************************//**
  464. This lets a thread enter InnoDB regardless of the number of threads inside
  465. InnoDB. This must be called when a thread ends a lock wait. */
  466. UNIV_INTERN
  467. void
  468. srv_conc_force_enter_innodb(
  469. /*========================*/
  470. trx_t* trx) /*!< in: transaction object associated with the
  471. thread */
  472. {
  473. #ifdef UNIV_SYNC_DEBUG
  474. ut_ad(!sync_thread_levels_nonempty_trx(trx->has_search_latch));
  475. #endif /* UNIV_SYNC_DEBUG */
  476. if (!srv_thread_concurrency) {
  477. return;
  478. }
  479. ut_ad(srv_conc.n_active >= 0);
  480. #ifdef HAVE_ATOMIC_BUILTINS
  481. (void) os_atomic_increment_lint(&srv_conc.n_active, 1);
  482. #else
  483. os_fast_mutex_lock(&srv_conc_mutex);
  484. ++srv_conc.n_active;
  485. os_fast_mutex_unlock(&srv_conc_mutex);
  486. #endif /* HAVE_ATOMIC_BUILTINS */
  487. trx->n_tickets_to_enter_innodb = 1;
  488. trx->declared_to_be_inside_innodb = TRUE;
  489. }
  490. /*********************************************************************//**
  491. This must be called when a thread exits InnoDB in a lock wait or at the
  492. end of an SQL statement. */
  493. UNIV_INTERN
  494. void
  495. srv_conc_force_exit_innodb(
  496. /*=======================*/
  497. trx_t* trx) /*!< in: transaction object associated with the
  498. thread */
  499. {
  500. if ((trx->mysql_thd != NULL
  501. && thd_is_replication_slave_thread(trx->mysql_thd))
  502. || trx->declared_to_be_inside_innodb == FALSE) {
  503. return;
  504. }
  505. #ifdef HAVE_ATOMIC_BUILTINS
  506. srv_conc_exit_innodb_with_atomics(trx);
  507. #else
  508. srv_conc_exit_innodb_without_atomics(trx);
  509. #endif /* HAVE_ATOMIC_BUILTINS */
  510. #ifdef UNIV_SYNC_DEBUG
  511. ut_ad(!sync_thread_levels_nonempty_trx(trx->has_search_latch));
  512. #endif /* UNIV_SYNC_DEBUG */
  513. }
  514. /*********************************************************************//**
  515. Get the count of threads waiting inside InnoDB. */
  516. UNIV_INTERN
  517. ulint
  518. srv_conc_get_waiting_threads(void)
  519. /*==============================*/
  520. {
  521. return(srv_conc.n_waiting);
  522. }
  523. /*********************************************************************//**
  524. Get the count of threads active inside InnoDB. */
  525. UNIV_INTERN
  526. ulint
  527. srv_conc_get_active_threads(void)
  528. /*==============================*/
  529. {
  530. return(srv_conc.n_active);
  531. }
  532. #ifdef WITH_WSREP
  533. UNIV_INTERN
  534. void
  535. wsrep_srv_conc_cancel_wait(
  536. /*==================*/
  537. trx_t* trx) /*!< in: transaction object associated with the
  538. thread */
  539. {
  540. #ifdef HAVE_ATOMIC_BUILTINS
  541. /* aborting transactions will enter innodb by force in
  542. srv_conc_enter_innodb_with_atomics(). No need to cancel here,
  543. thr will wake up after os_sleep and let to enter innodb
  544. */
  545. if (wsrep_debug)
  546. fprintf(stderr, "WSREP: conc slot cancel, no atomics\n");
  547. #else
  548. os_fast_mutex_lock(&srv_conc_mutex);
  549. if (trx->wsrep_event) {
  550. if (wsrep_debug)
  551. fprintf(stderr, "WSREP: conc slot cancel\n");
  552. os_event_set(trx->wsrep_event);
  553. }
  554. os_fast_mutex_unlock(&srv_conc_mutex);
  555. #endif
  556. }
  557. #endif /* WITH_WSREP */