]> git.pld-linux.org Git - packages/mysql.git/blobdiff - innodb_pass_corrupt_table.patch
- rel 2; patches updated
[packages/mysql.git] / innodb_pass_corrupt_table.patch
index a4dd11ce845e6196df2717b40d634fd7ce2f6eb7..63b1c657585242136a287549965e350780df46f3 100644 (file)
@@ -7,7 +7,7 @@
 # should be done or reviewed by the maintainer!
 --- a/storage/innobase/btr/btr0btr.c
 +++ b/storage/innobase/btr/btr0btr.c
-@@ -692,6 +692,12 @@
+@@ -713,6 +713,12 @@
  
        block = btr_block_get(space, zip_size, root_page_no, RW_X_LATCH,
                              index, mtr);
 +      }
 +      ut_a(block);
 +
-       ut_a((ibool)!!page_is_comp(buf_block_get_frame(block))
-            == dict_table_is_comp(index->table));
+       btr_assert_not_corrupted(block, index);
  #ifdef UNIV_BTR_DEBUG
-@@ -978,6 +984,12 @@
+       if (!dict_index_is_ibuf(index)) {
+@@ -998,6 +1004,12 @@
  
        root = btr_root_get(index, &mtr);
  
@@ -33,7 +33,7 @@
        if (flag == BTR_N_LEAF_PAGES) {
                seg_header = root + PAGE_HEADER + PAGE_BTR_SEG_LEAF;
  
-@@ -1437,6 +1449,13 @@
+@@ -1457,6 +1469,13 @@
  
        root = btr_page_get(space, zip_size, root_page_no, RW_X_LATCH,
                            NULL, &mtr);
@@ -47,7 +47,7 @@
  #ifdef UNIV_BTR_DEBUG
        ut_a(btr_root_fseg_validate(FIL_PAGE_DATA + PAGE_BTR_SEG_LEAF
                                    + root, space));
-@@ -1460,6 +1479,12 @@
+@@ -1480,6 +1499,12 @@
  
        root = btr_page_get(space, zip_size, root_page_no, RW_X_LATCH,
                            NULL, &mtr);
@@ -60,7 +60,7 @@
  #ifdef UNIV_BTR_DEBUG
        ut_a(btr_root_fseg_validate(FIL_PAGE_DATA + PAGE_BTR_SEG_TOP
                                    + root, space));
-@@ -1493,6 +1518,11 @@
+@@ -1513,6 +1538,11 @@
        block = btr_block_get(space, zip_size, root_page_no, RW_X_LATCH,
                              NULL, mtr);
  
  #ifdef UNIV_BTR_DEBUG
                ut_a(page_is_comp(get_block->frame) == page_is_comp(page));
  #endif /* UNIV_BTR_DEBUG */
-@@ -590,6 +620,19 @@
+@@ -595,6 +625,19 @@
                file, line, mtr);
  
        if (block == NULL) {
                /* This must be a search to perform an insert/delete
                mark/ delete; try using the insert/delete buffer */
  
-@@ -664,6 +707,16 @@
+@@ -669,6 +712,16 @@
        block->check_index_page_at_flush = TRUE;
        page = buf_block_get_frame(block);
  
        if (rw_latch != RW_NO_LATCH) {
  #ifdef UNIV_ZIP_DEBUG
                const page_zip_des_t*   page_zip
-@@ -857,6 +910,17 @@
+@@ -862,6 +915,17 @@
                                         RW_NO_LATCH, NULL, BUF_GET,
                                         file, line, mtr);
                page = buf_block_get_frame(block);
                ut_ad(index->id == btr_page_get_index_id(page));
  
                block->check_index_page_at_flush = TRUE;
-@@ -977,6 +1041,14 @@
+@@ -982,6 +1046,14 @@
                                         RW_NO_LATCH, NULL, BUF_GET,
                                         file, line, mtr);
                page = buf_block_get_frame(block);
                ut_ad(index->id == btr_page_get_index_id(page));
  
                if (height == ULINT_UNDEFINED) {
-@@ -1190,6 +1262,12 @@
+@@ -1195,6 +1267,12 @@
        *big_rec = NULL;
  
        block = btr_cur_get_block(cursor);
        page = buf_block_get_frame(block);
        index = cursor->index;
        zip_size = buf_block_get_zip_size(block);
-@@ -2922,6 +3000,11 @@
+@@ -2927,6 +3005,11 @@
  
        block = btr_cur_get_block(cursor);
  
        ut_ad(page_is_leaf(buf_block_get_frame(block)));
  
        rec = btr_cur_get_rec(cursor);
-@@ -3630,6 +3713,11 @@
+@@ -3635,6 +3718,11 @@
  
                page = btr_cur_get_page(&cursor);
  
  /**************************************************************//**
  Allocates memory for a persistent cursor object and initializes the cursor.
  @return       own: persistent cursor */
-@@ -102,6 +102,12 @@
+@@ -114,6 +114,12 @@
        ut_ad(cursor->latch_mode != BTR_NO_LATCHES);
  
        block = btr_pcur_get_block(cursor);
        index = btr_cur_get_index(btr_pcur_get_btr_cur(cursor));
  
        page_cursor = btr_pcur_get_page_cur(cursor);
-@@ -397,6 +403,15 @@
+@@ -409,6 +415,15 @@
                                   cursor->latch_mode,
                                   btr_pcur_get_btr_cur(cursor)->index, mtr);
        next_page = buf_block_get_frame(next_block);
  
  /* prototypes for new functions added to ha_innodb.cc */
  trx_t* innobase_get_trx();
-@@ -1151,6 +1152,11 @@
+@@ -1150,6 +1151,11 @@
                        ready = buf_flush_ready_for_replace(&block->page);
                        mutex_exit(&block->mutex);
  
                        if (!ready) {
  
                                return(block);
-@@ -1945,6 +1951,13 @@
+@@ -1946,6 +1952,13 @@
                return(NULL);
        }
  
        block_mutex = buf_page_get_mutex_enter(bpage);
  
        rw_lock_s_unlock(&buf_pool->page_hash_latch);
-@@ -2524,6 +2537,13 @@
+@@ -2525,6 +2538,13 @@
                return(NULL);
        }
  
        switch (buf_block_get_state(block)) {
                buf_page_t*     bpage;
                ibool           success;
-@@ -3198,6 +3218,7 @@
+@@ -3199,6 +3219,7 @@
        bpage->newest_modification = 0;
        bpage->oldest_modification = 0;
        HASH_INVALIDATE(bpage, hash);
  #if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
        bpage->file_page_was_freed = FALSE;
  #endif /* UNIV_DEBUG_FILE_ACCESSES || UNIV_DEBUG */
-@@ -3836,6 +3857,7 @@
+@@ -3837,6 +3858,7 @@
                                (ulong) bpage->offset);
                }
  
                /* From version 3.23.38 up we store the page checksum
                to the 4 first bytes of the page end lsn field */
  
-@@ -3877,6 +3899,23 @@
+@@ -3878,6 +3900,23 @@
                              REFMAN "forcing-innodb-recovery.html\n"
                              "InnoDB: about forcing recovery.\n", stderr);
  
                        if (srv_force_recovery < SRV_FORCE_IGNORE_CORRUPT) {
                                /* If page space id is larger than TRX_SYS_SPACE
                                (0), we will attempt to mark the corresponding
-@@ -3893,6 +3932,7 @@
+@@ -3894,6 +3933,7 @@
                                }
                        }
                }
  
                if (recv_recovery_is_on()) {
                        /* Pages must be uncompressed for crash recovery. */
-@@ -3902,8 +3942,11 @@
+@@ -3903,8 +3943,11 @@
  
                if (uncompressed && !recv_no_ibuf_operations) {
                        ibuf_merge_or_delete_for_page(
                /* If table->ibd_file_missing == TRUE, this will
                print an error message and return without doing
                anything. */
-@@ -1293,7 +1294,7 @@
+@@ -1298,7 +1299,7 @@
                    + dict_sys->size) > srv_dict_size_limit ) {
                prev_table = UT_LIST_GET_PREV(table_LRU, table);
  
                        goto next_loop;
  
                cached_foreign_tables = 0;
-@@ -4367,6 +4368,12 @@
+@@ -4377,6 +4378,12 @@
        heap = mem_heap_create(1000);
  
        while (index) {
                size = btr_get_size(index, BTR_TOTAL_SIZE);
  
                index->stat_index_size = size;
-@@ -4514,6 +4521,12 @@
+@@ -4524,6 +4531,12 @@
        heap = mem_heap_create(1000);
  
        while (index) {
  /*===========================================*/
  {
        dict_table_t*   sys_stats;
-@@ -4706,6 +4719,13 @@
+@@ -4716,6 +4729,13 @@
                     || (srv_force_recovery < SRV_FORCE_NO_LOG_REDO
                         && dict_index_is_clust(index)))) {
                        ulint   size;
                        size = btr_get_size(index, BTR_TOTAL_SIZE);
  
                        index->stat_index_size = size;
-@@ -5685,4 +5705,42 @@
+@@ -5695,4 +5715,42 @@
  
        index->type |= DICT_CORRUPT;
  }
        UT_LIST_ADD_LAST(space_list, fil_system->space_list, space);
  
        mutex_exit(&fil_system->mutex);
-@@ -5277,6 +5280,34 @@
+@@ -5285,6 +5288,34 @@
        ut_a(byte_offset % OS_FILE_LOG_BLOCK_SIZE == 0);
        ut_a((len % OS_FILE_LOG_BLOCK_SIZE) == 0);
  
  #ifdef UNIV_HOTBACKUP
        /* In ibbackup do normal i/o, not aio */
        if (type == OS_FILE_READ) {
-@@ -5291,6 +5322,8 @@
+@@ -5299,6 +5330,8 @@
        ret = os_aio(type, mode | wake_later, node->name, node->handle, buf,
                     offset_low, offset_high, len, node, message, trx);
  #endif
        ut_a(ret);
  
        if (mode == OS_AIO_SYNC) {
-@@ -5791,3 +5824,46 @@
+@@ -5799,3 +5832,46 @@
                 return 0;
         }
  }
 +
 --- a/storage/innobase/fsp/fsp0fsp.c
 +++ b/storage/innobase/fsp/fsp0fsp.c
-@@ -369,6 +369,12 @@
+@@ -308,6 +308,12 @@
        ut_ad(id || !zip_size);
  
        block = buf_page_get(id, zip_size, 0, RW_X_LATCH, mtr);
        header = FSP_HEADER_OFFSET + buf_block_get_frame(block);
        buf_block_dbg_add_level(block, SYNC_FSP_PAGE);
  
-@@ -787,6 +793,12 @@
+@@ -726,6 +732,12 @@
        fsp_header_t*   sp_header;
  
        block = buf_page_get(space, zip_size, 0, RW_X_LATCH, mtr);
        buf_block_dbg_add_level(block, SYNC_FSP_PAGE);
  
        sp_header = FSP_HEADER_OFFSET + buf_block_get_frame(block);
-@@ -1866,6 +1878,11 @@
+@@ -1805,6 +1817,11 @@
  {
        fseg_inode_t*   inode;
  
        for (; i < FSP_SEG_INODES_PER_PAGE(zip_size); i++) {
  
                inode = fsp_seg_inode_page_get_nth_inode(
-@@ -1979,6 +1996,11 @@
+@@ -1918,6 +1935,11 @@
  
        page = buf_block_get_frame(block);
  
        n = fsp_seg_inode_page_find_free(page, 0, zip_size, mtr);
  
        ut_a(n != ULINT_UNDEFINED);
-@@ -2072,6 +2094,11 @@
+@@ -2011,6 +2033,11 @@
  
        inode = fut_get_ptr(space, zip_size, inode_addr, RW_X_LATCH, mtr);
  
        if (UNIV_UNLIKELY(!mach_read_from_8(inode + FSEG_ID))) {
  
                inode = NULL;
-@@ -2098,7 +2125,7 @@
+@@ -2037,7 +2064,7 @@
  {
        fseg_inode_t*   inode
                = fseg_inode_try_get(header, space, zip_size, mtr);
        return(inode);
  }
  
-@@ -3304,6 +3331,11 @@
+@@ -3243,6 +3270,11 @@
  
        descr = xdes_get_descriptor(space, zip_size, page, mtr);
  
        ut_a(descr);
        if (xdes_get_bit(descr, XDES_FREE_BIT, page % FSP_EXTENT_SIZE, mtr)) {
                fputs("InnoDB: Dump of the tablespace extent descriptor: ",
-@@ -3551,6 +3583,11 @@
+@@ -3490,6 +3522,11 @@
  
        descr = xdes_get_descriptor(space, zip_size, header_page, mtr);
  
        /* Check that the header resides on a page which has not been
        freed yet */
  
-@@ -3635,6 +3672,12 @@
+@@ -3574,6 +3611,12 @@
  
        inode = fseg_inode_get(header, space, zip_size, mtr);
  
        if (descr != NULL) {
 --- a/storage/innobase/handler/ha_innodb.cc
 +++ b/storage/innobase/handler/ha_innodb.cc
-@@ -4011,6 +4011,12 @@
+@@ -4024,6 +4024,12 @@
                DBUG_RETURN(1);
        }
  
 +              DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE);
 +      }
 +
-       /* Create buffers for packing the fields of a record. Why
-       table->reclength did not work here? Obviously, because char
-       fields when packed actually became 1 byte longer, when we also
-@@ -4038,6 +4044,19 @@
+       /* Will be allocated if it is needed in ::update_row() */
+       upd_buf = NULL;
+       upd_buf_size = 0;
+@@ -4043,6 +4049,17 @@
        /* Get pointer to a table object in InnoDB dictionary cache */
        ib_table = dict_table_get(norm_name, TRUE);
-       
 +      if (srv_pass_corrupt_table <= 1 && ib_table && ib_table->is_corrupt) {
 +              free_share(share);
-+              my_free(upd_buff);
++              my_free(upd_buf);
++              upd_buf = NULL;
++              upd_buf_size = 0;
 +
 +              DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE);
 +      }
 +
 +      share->ib_table = ib_table;
-+
-+
-+
-+
 +
        if (NULL == ib_table) {
                if (is_part && retries < 10) {
-                       ++retries;
-@@ -5187,6 +5206,10 @@
+                       /* MySQL partition engine hard codes the file name
+@@ -5263,6 +5280,10 @@
  
        ha_statistic_increment(&SSV::ha_write_count);
  
        if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_INSERT)
                table->timestamp_field->set_time();
  
-@@ -5403,6 +5426,10 @@
+@@ -5479,6 +5500,10 @@
  func_exit:
        innobase_active_small();
  
        DBUG_RETURN(error_result);
  }
  
-@@ -5580,6 +5607,10 @@
+@@ -5673,6 +5698,10 @@
  
        ha_statistic_increment(&SSV::ha_update_count);
  
        if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_UPDATE)
                table->timestamp_field->set_time();
  
-@@ -5668,6 +5699,10 @@
+@@ -5760,6 +5789,10 @@
  
        innobase_active_small();
  
        DBUG_RETURN(error);
  }
  
-@@ -5689,6 +5724,10 @@
+@@ -5781,6 +5814,10 @@
  
        ha_statistic_increment(&SSV::ha_delete_count);
  
        if (!prebuilt->upd_node) {
                row_get_prebuilt_update_vector(prebuilt);
        }
-@@ -5715,6 +5754,10 @@
+@@ -5807,6 +5844,10 @@
  
        innobase_active_small();
  
        DBUG_RETURN(error);
  }
  
-@@ -5954,6 +5997,10 @@
+@@ -6046,6 +6087,10 @@
  
        ha_statistic_increment(&SSV::ha_read_key_count);
  
        index = prebuilt->index;
  
        if (UNIV_UNLIKELY(index == NULL) || dict_index_is_corrupted(index)) {
-@@ -6022,6 +6069,10 @@
+@@ -6113,6 +6158,10 @@
                ret = DB_UNSUPPORTED;
        }
  
        switch (ret) {
        case DB_SUCCESS:
                error = 0;
-@@ -6137,6 +6188,10 @@
+@@ -6227,6 +6276,10 @@
  {
        DBUG_ENTER("change_active_index");
  
        ut_ad(user_thd == ha_thd());
        ut_a(prebuilt->trx == thd_to_trx(user_thd));
  
-@@ -6250,6 +6305,10 @@
+@@ -6340,6 +6393,10 @@
  
        DBUG_ENTER("general_fetch");
  
        ut_a(prebuilt->trx == thd_to_trx(user_thd));
  
        innodb_srv_conc_enter_innodb(prebuilt->trx);
-@@ -6259,6 +6318,10 @@
+@@ -6349,6 +6406,10 @@
  
        innodb_srv_conc_exit_innodb(prebuilt->trx);
  
        switch (ret) {
        case DB_SUCCESS:
                error = 0;
-@@ -7525,10 +7588,18 @@
+@@ -7615,10 +7676,18 @@
  
        update_thd(ha_thd());
  
        error = convert_error_code_to_mysql(error, prebuilt->table->flags,
                                            NULL);
  
-@@ -8040,6 +8111,16 @@
+@@ -8124,6 +8193,16 @@
        return(ranges + (double) rows / (double) total_rows * time_for_scan);
  }
  
  /*********************************************************************//**
  Calculates the key number used inside MySQL for an Innobase index. We will
  first check the "index translation table" for a match of the index to get
-@@ -8217,7 +8298,7 @@
+@@ -8301,7 +8380,7 @@
        ib_table = prebuilt->table;
  
        if (flag & HA_STATUS_TIME) {
                        /* In sql_show we call with this flag: update
                        then statistics so that they are up-to-date */
  
-@@ -8517,10 +8598,18 @@
+@@ -8601,10 +8680,18 @@
        THD*            thd,            /*!< in: connection thread handle */
        HA_CHECK_OPT*   check_opt)      /*!< in: currently ignored */
  {
        return(0);
  }
  
-@@ -8756,6 +8845,10 @@
+@@ -8840,6 +8927,10 @@
                my_error(ER_QUERY_INTERRUPTED, MYF(0));
        }
  
        DBUG_RETURN(is_ok ? HA_ADMIN_OK : HA_ADMIN_CORRUPT);
  }
  
-@@ -9526,6 +9619,10 @@
+@@ -9610,6 +9701,10 @@
  
        update_thd(thd);
  
        if (prebuilt->table->ibd_file_missing && !thd_tablespace_op(thd)) {
                ut_print_timestamp(stderr);
                fprintf(stderr,
-@@ -11990,6 +12087,26 @@
+@@ -12073,6 +12168,26 @@
    "dump file (if present). Disabled by default.",
    NULL, NULL, FALSE);
  
  static struct st_mysql_sys_var* innobase_system_variables[]= {
    MYSQL_SYSVAR(additional_mem_pool_size),
    MYSQL_SYSVAR(autoextend_increment),
-@@ -12083,6 +12200,7 @@
+@@ -12166,6 +12281,7 @@
  #ifdef UNIV_DEBUG
-   MYSQL_SYSVAR(flush_checkpoint_debug),
- #endif
+   MYSQL_SYSVAR(trx_rseg_n_slots_debug),
+ #endif /* UNIV_DEBUG */
 +  MYSQL_SYSVAR(corrupt_table_action),
    NULL
  };
  } INNOBASE_SHARE;
  
  
-@@ -135,6 +136,7 @@
+@@ -136,6 +137,7 @@
        int close(void);
        double scan_time();
        double read_time(uint index, uint ranges, ha_rows rows);
                        block, index != NULL && dict_index_is_ibuf(index)
 --- a/storage/innobase/include/buf0buf.h
 +++ b/storage/innobase/include/buf0buf.h
-@@ -1003,7 +1003,7 @@
+@@ -1023,7 +1023,7 @@
        const buf_block_t*      block)  /*!< in: pointer to the control block */
        __attribute__((pure));
  #else /* UNIV_DEBUG */
  #endif /* UNIV_DEBUG */
  /*********************************************************************//**
  Gets the space id of a block.
-@@ -1450,6 +1450,7 @@
+@@ -1470,6 +1470,7 @@
                                        0 if the block was never accessed
                                        in the buffer pool */
        /* @} */
  /*********************************************************************//**
  Gets the current size of buffer buf_pool in bytes.
  @return size in bytes */
-@@ -637,6 +637,12 @@
+@@ -681,6 +681,12 @@
  /*================*/
        const buf_block_t*      block)  /*!< in: pointer to the control block */
  {
  #ifdef UNIV_DEBUG
 --- a/storage/innobase/include/fil0fil.h
 +++ b/storage/innobase/include/fil0fil.h
-@@ -754,6 +754,19 @@
+@@ -759,6 +759,19 @@
  fil_system_hash_nodes(void);
  /*========================*/
  
  
 --- a/storage/innobase/row/row0sel.c
 +++ b/storage/innobase/row/row0sel.c
-@@ -3912,6 +3912,13 @@
+@@ -3919,6 +3919,13 @@
        /* PHASE 4: Look for matching records in a loop */
  
        rec = btr_pcur_get_rec(pcur);
        ut_ad(!!page_rec_is_comp(rec) == comp);
  #ifdef UNIV_SEARCH_DEBUG
        /*
-@@ -3989,7 +3996,13 @@
+@@ -3996,7 +4003,13 @@
        if (UNIV_UNLIKELY(next_offs >= UNIV_PAGE_SIZE - PAGE_DIR)) {
  
  wrong_offs:
                        ut_print_timestamp(stderr);
                        buf_page_print(page_align(rec), 0);
                        fprintf(stderr,
-@@ -4040,7 +4053,8 @@
+@@ -4047,7 +4060,8 @@
  
        offsets = rec_get_offsets(rec, index, offsets, ULINT_UNDEFINED, &heap);
  
  /*-------------------------------------------*/
 --- a/storage/innobase/srv/srv0start.c
 +++ b/storage/innobase/srv/srv0start.c
-@@ -2155,6 +2155,13 @@
+@@ -2175,6 +2175,13 @@
  
        os_fast_mutex_free(&srv_os_test_mutex);
  
This page took 0.055897 seconds and 4 git commands to generate.