~vlad-lesin/percona-server/pintables

« back to all changes in this revision

Viewing changes to innodb_adaptive_hash_index_partitions.patch

  • Committer: Laurynas Biveinis
  • Date: 2011-06-21 02:36:36 UTC
  • mfrom: (123 merge)
  • mto: This revision was merged to the branch mainline in revision 124.
  • Revision ID: laurynas.biveinis@percona.com-20110621023636-ccp1iyyrncj181zt
MergeĀ fromĀ lp:percona-server

Show diffs side-by-side

added added

removed removed

Lines of Context:
516
516
+               }
517
517
+               if (UNIV_LIKELY(!block->is_hashed)) {
518
518
+                       rw_lock_s_unlock(btr_search_latch);
519
 
+                       return;
 
519
+                       goto retry;
520
520
+               }
521
521
+               index = block->index;
522
522
+               ut_a(btr_search_latch == btr_search_get_latch(index->id));
1008
1008
 #endif /* UNIV_SYNC_DEBUG */
1009
1009
        ut_ad(!btr_search_enabled);
1010
1010
 
1011
 
@@ -2633,6 +2638,7 @@
 
1011
@@ -2632,6 +2637,7 @@
1012
1012
 {
1013
1013
        block->check_index_page_at_flush = FALSE;
1014
1014
        block->index            = NULL;
1019
1019
diff -ruN a/storage/innobase/buf/buf0lru.c b/storage/innobase/buf/buf0lru.c
1020
1020
--- a/storage/innobase/buf/buf0lru.c    2010-12-04 15:35:29.137347521 +0900
1021
1021
+++ b/storage/innobase/buf/buf0lru.c    2010-12-04 16:12:48.658550840 +0900
1022
 
@@ -1796,7 +1796,7 @@
 
1022
@@ -1798,7 +1798,7 @@
1023
1023
 
1024
1024
                UNIV_MEM_VALID(((buf_block_t*) bpage)->frame,
1025
1025
                               UNIV_PAGE_SIZE);
1031
1031
diff -ruN a/storage/innobase/dict/dict0dict.c b/storage/innobase/dict/dict0dict.c
1032
1032
--- a/storage/innobase/dict/dict0dict.c 2010-12-04 15:52:23.398513916 +0900
1033
1033
+++ b/storage/innobase/dict/dict0dict.c 2010-12-04 16:12:48.662550715 +0900
1034
 
@@ -1812,7 +1812,7 @@
 
1034
@@ -1811,7 +1811,7 @@
1035
1035
        zero. */
1036
1036
 
1037
1037
        for (;;) {
1056
1056
diff -ruN a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
1057
1057
--- a/storage/innobase/handler/ha_innodb.cc     2010-12-04 16:12:20.185850734 +0900
1058
1058
+++ b/storage/innobase/handler/ha_innodb.cc     2010-12-04 16:12:48.674552412 +0900
1059
 
@@ -11695,6 +11695,11 @@
 
1059
@@ -11702,6 +11702,11 @@
1060
1060
   "Disable with --skip-innodb-adaptive-hash-index.",
1061
1061
   NULL, innodb_adaptive_hash_index_update, TRUE);
1062
1062
 
1063
1063
+static MYSQL_SYSVAR_ULONG(adaptive_hash_index_partitions, btr_search_index_num,
1064
1064
+  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
1065
1065
+  "Number of InnoDB adaptive hash index partitions (default 1: disable partitioning)",
1066
 
+  NULL, NULL, 1, 1, 32, 0);
 
1066
+  NULL, NULL, 1, 1, sizeof(ulint) * 8, 0);
1067
1067
+
1068
1068
 static MYSQL_SYSVAR_ULONG(replication_delay, srv_replication_delay,
1069
1069
   PLUGIN_VAR_RQCMDARG,
1070
1070
   "Replication thread delay (ms) on the slave server if "
1071
 
@@ -12060,6 +12065,7 @@
 
1071
@@ -12068,6 +12073,7 @@
1072
1072
   MYSQL_SYSVAR(use_sys_stats_table),
1073
1073
   MYSQL_SYSVAR(stats_sample_pages),
1074
1074
   MYSQL_SYSVAR(adaptive_hash_index),
1264
1264
diff -ruN a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h
1265
1265
--- a/storage/innobase/include/buf0buf.h        2010-12-15 19:00:07.713604580 +0900
1266
1266
+++ b/storage/innobase/include/buf0buf.h        2010-12-15 20:58:03.546839883 +0900
1267
 
@@ -1547,7 +1547,7 @@
 
1267
@@ -1546,7 +1546,7 @@
1268
1268
                                        pointers in the adaptive hash index
1269
1269
                                        pointing to this frame */
1270
1270
 #endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
1273
1273
                                        already been built on this
1274
1274
                                        page; note that it does not
1275
1275
                                        guarantee that the index is
1276
 
@@ -1561,6 +1561,7 @@
 
1276
@@ -1560,6 +1560,7 @@
1277
1277
        unsigned        curr_left_side:1;/*!< TRUE or FALSE in hash indexing */
1278
1278
        dict_index_t*   index;          /*!< Index for which the adaptive
1279
1279
                                        hash index has been created. */
1389
1389
 #ifdef UNIV_SEARCH_DEBUG
1390
1390
        ulint           cnt                             = 0;
1391
1391
 #endif /* UNIV_SEARCH_DEBUG */
1392
 
@@ -3441,18 +3443,32 @@
 
1392
@@ -3446,18 +3448,33 @@
1393
1393
        /* PHASE 0: Release a possible s-latch we are holding on the
1394
1394
        adaptive hash index latch if there is someone waiting behind */
1395
1395
 
1397
1397
-           && trx->has_search_latch) {
1398
1398
+       should_release = 0;
1399
1399
+       for (i = 0; i < btr_search_index_num; i++) {
1400
 
+               if ((trx->has_search_latch & ((ulint)1 << i))
1401
 
+                   && rw_lock_get_writer(btr_search_latch_part[i])
1402
 
+                               != RW_LOCK_NOT_LOCKED) {
 
1400
+               /* we should check all latches (fix Bug#791030) */
 
1401
+               if (rw_lock_get_writer(btr_search_latch_part[i])
 
1402
+                   != RW_LOCK_NOT_LOCKED) {
1403
1403
+                       should_release |= ((ulint)1 << i);
1404
1404
+               }
1405
1405
+       }
1414
1414
-               rw_lock_s_unlock(&btr_search_latch);
1415
1415
-               trx->has_search_latch = FALSE;
1416
1416
+               for (i = 0; i < btr_search_index_num; i++) {
1417
 
+                       if (should_release & ((ulint)1 << i)) {
 
1417
+                       /* we should release all s-latches (fix Bug#791030) */
 
1418
+                       if (trx->has_search_latch & ((ulint)1 << i)) {
1418
1419
+                               rw_lock_s_unlock(btr_search_latch_part[i]);
1419
 
+                               trx->has_search_latch &= ~((ulint)1 << i);
 
1420
+                               trx->has_search_latch &= (~((ulint)1 << i));
1420
1421
+                       }
1421
1422
+               }
1422
1423
 
1426
1427
        }
1427
1428
 
1428
1429
        /* Reset the new record lock info if srv_locks_unsafe_for_binlog
1429
 
@@ -3603,9 +3619,11 @@
 
1430
@@ -3608,9 +3625,28 @@
1430
1431
                        hash index semaphore! */
1431
1432
 
1432
1433
 #ifndef UNIV_SEARCH_DEBUG
1435
1436
-                               trx->has_search_latch = TRUE;
1436
1437
+                       if (!(trx->has_search_latch
1437
1438
+                             & ((ulint)1 << (index->id % btr_search_index_num)))) {
1438
 
+                               rw_lock_s_lock(btr_search_get_latch(index->id));
1439
 
+                               trx->has_search_latch |=
1440
 
+                                       (ulint)1 << (index->id % btr_search_index_num);
 
1439
+                               if (trx->has_search_latch
 
1440
+                                   < ((ulint)1 << (index->id % btr_search_index_num))) {
 
1441
+                                       rw_lock_s_lock(btr_search_get_latch(index->id));
 
1442
+                                       trx->has_search_latch |=
 
1443
+                                               ((ulint)1 << (index->id % btr_search_index_num));
 
1444
+                               } else {
 
1445
+                                       /* should re-lock to obay latch-order */
 
1446
+                                       for (i = 0; i < btr_search_index_num; i++) {
 
1447
+                                               if (trx->has_search_latch & ((ulint)1 << i)) {
 
1448
+                                                       rw_lock_s_unlock(btr_search_latch_part[i]);
 
1449
+                                               }
 
1450
+                                       }
 
1451
+                                       trx->has_search_latch |=
 
1452
+                                               ((ulint)1 << (index->id % btr_search_index_num));
 
1453
+                                       for (i = 0; i < btr_search_index_num; i++) {
 
1454
+                                               if (trx->has_search_latch & ((ulint)1 << i)) {
 
1455
+                                                       rw_lock_s_lock(btr_search_latch_part[i]);
 
1456
+                                               }
 
1457
+                                       }
 
1458
+                               }
1441
1459
                        }
1442
1460
 #endif
1443
1461
                        switch (row_sel_try_search_shortcut_for_mysql(
1444
 
@@ -3666,7 +3684,11 @@
 
1462
@@ -3671,7 +3707,11 @@
1445
1463
 
1446
1464
                                        trx->search_latch_timeout--;
1447
1465
 
1454
1472
                                        trx->has_search_latch = FALSE;
1455
1473
                                }
1456
1474
 
1457
 
@@ -3690,7 +3712,12 @@
 
1475
@@ -3695,7 +3735,12 @@
1458
1476
        /* PHASE 3: Open or restore index cursor position */
1459
1477
 
1460
1478
        if (trx->has_search_latch) {
1471
1489
diff -ruN a/storage/innobase/srv/srv0srv.c b/storage/innobase/srv/srv0srv.c
1472
1490
--- a/storage/innobase/srv/srv0srv.c    2010-12-04 16:12:20.231484679 +0900
1473
1491
+++ b/storage/innobase/srv/srv0srv.c    2010-12-04 16:12:48.726551018 +0900
1474
 
@@ -2035,7 +2035,9 @@
 
1492
@@ -2045,7 +2045,9 @@
1475
1493
              "-------------------------------------\n", file);
1476
1494
        ibuf_print(file);
1477
1495
 
1482
1500
 
1483
1501
        fprintf(file,
1484
1502
                "%.2f hash searches/s, %.2f non-hash searches/s\n",
1485
 
@@ -2060,14 +2062,15 @@
 
1503
@@ -2070,14 +2072,15 @@
1486
1504
                        ut_total_allocated_memory,
1487
1505
                        mem_pool_get_reserved(mem_comm_pool));
1488
1506
        /* Calcurate reserved memories */
1502
1520
 
1503
1521
        lock_sys_subtotal = 0;
1504
1522
        if (trx_sys) {
1505
 
@@ -2093,10 +2096,10 @@
 
1523
@@ -2103,10 +2106,10 @@
1506
1524
                        "    Recovery system     %lu \t(%lu + %lu)\n",
1507
1525
 
1508
1526
                        (ulong) (btr_search_sys
1518
1536
diff -ruN a/storage/innobase/sync/sync0sync.c b/storage/innobase/sync/sync0sync.c
1519
1537
--- a/storage/innobase/sync/sync0sync.c 2010-12-03 17:36:44.300986571 +0900
1520
1538
+++ b/storage/innobase/sync/sync0sync.c 2010-12-04 16:12:48.729513564 +0900
1521
 
@@ -1178,7 +1178,6 @@
 
1539
@@ -1223,7 +1223,6 @@
1522
1540
        case SYNC_OUTER_ANY_LATCH:
1523
1541
        case SYNC_FILE_FORMAT_TAG:
1524
1542
        case SYNC_DOUBLEWRITE:
1526
1544
        case SYNC_SEARCH_SYS_CONF:
1527
1545
        case SYNC_TRX_LOCK_HEAP:
1528
1546
        case SYNC_KERNEL:
1529
 
@@ -1199,6 +1198,7 @@
 
1547
@@ -1244,6 +1243,7 @@
1530
1548
                        ut_error;
1531
1549
                }
1532
1550
                break;
1537
1555
diff -ruN a/storage/innobase/trx/trx0trx.c b/storage/innobase/trx/trx0trx.c
1538
1556
--- a/storage/innobase/trx/trx0trx.c    2010-12-03 17:49:11.623953784 +0900
1539
1557
+++ b/storage/innobase/trx/trx0trx.c    2010-12-04 16:12:48.731513275 +0900
1540
 
@@ -266,8 +266,14 @@
 
1558
@@ -265,8 +265,14 @@
1541
1559
 /*=================================*/
1542
1560
        trx_t*     trx) /*!< in: transaction */
1543
1561
 {