~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/log/log0recv.c

  • Committer: Brian Aker
  • Date: 2010-12-07 09:12:12 UTC
  • mto: This revision was merged to the branch mainline in revision 1985.
  • Revision ID: brian@tangent.org-20101207091212-1m0w20tck6z7632m
This is a fix for bug lp:686197

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*****************************************************************************
2
2
 
3
 
Copyright (C) 1997, 2010, Innobase Oy. All Rights Reserved.
 
3
Copyright (c) 1997, 2010, Innobase Oy. All Rights Reserved.
4
4
 
5
5
This program is free software; you can redistribute it and/or modify it under
6
6
the terms of the GNU General Public License as published by the Free Software
180
180
                return;
181
181
        }
182
182
 
183
 
        recv_sys = static_cast<recv_sys_t *>(mem_alloc(sizeof(*recv_sys)));
 
183
        recv_sys = mem_alloc(sizeof(*recv_sys));
184
184
        memset(recv_sys, 0x0, sizeof(*recv_sys));
185
185
 
186
186
        mutex_create(recv_sys_mutex_key, &recv_sys->mutex, SYNC_RECV);
327
327
                recv_n_pool_free_frames = 512;
328
328
        }
329
329
 
330
 
        recv_sys->buf = static_cast<byte *>(ut_malloc(RECV_PARSING_BUF_SIZE));
 
330
        recv_sys->buf = ut_malloc(RECV_PARSING_BUF_SIZE);
331
331
        recv_sys->len = 0;
332
332
        recv_sys->recovered_offset = 0;
333
333
 
337
337
        recv_sys->apply_log_recs = FALSE;
338
338
        recv_sys->apply_batch_on = FALSE;
339
339
 
340
 
        recv_sys->last_block_buf_start = static_cast<byte *>(mem_alloc(2 * OS_FILE_LOG_BLOCK_SIZE));
 
340
        recv_sys->last_block_buf_start = mem_alloc(2 * OS_FILE_LOG_BLOCK_SIZE);
341
341
 
342
 
        recv_sys->last_block = static_cast<byte *>(ut_align(recv_sys->last_block_buf_start,
343
 
                                        OS_FILE_LOG_BLOCK_SIZE));
 
342
        recv_sys->last_block = ut_align(recv_sys->last_block_buf_start,
 
343
                                        OS_FILE_LOG_BLOCK_SIZE);
344
344
        recv_sys->found_corrupt_log = FALSE;
345
345
 
346
346
        recv_max_page_lsn = 0;
569
569
        ib_uint64_t     start_lsn;
570
570
        ib_uint64_t     end_lsn;
571
571
        ib_uint64_t     recovered_lsn;
 
572
        ib_uint64_t     limit_lsn;
572
573
 
573
574
        recovered_lsn = recv_sys->recovered_lsn;
 
575
        limit_lsn = recv_sys->limit_lsn;
574
576
 
575
577
        /* Read the last recovered log block to the recovery system buffer:
576
578
        the block is always incomplete */
1319
1321
{
1320
1322
        recv_addr_t*    recv_addr;
1321
1323
 
1322
 
        recv_addr = static_cast<recv_addr_t *>(HASH_GET_FIRST(recv_sys->addr_hash,
1323
 
                                   recv_hash(space, page_no)));
 
1324
        recv_addr = HASH_GET_FIRST(recv_sys->addr_hash,
 
1325
                                   recv_hash(space, page_no));
1324
1326
        while (recv_addr) {
1325
1327
                if ((recv_addr->space == space)
1326
1328
                    && (recv_addr->page_no == page_no)) {
1328
1330
                        break;
1329
1331
                }
1330
1332
 
1331
 
                recv_addr = static_cast<recv_addr_t *>(HASH_GET_NEXT(addr_hash, recv_addr));
 
1333
                recv_addr = HASH_GET_NEXT(addr_hash, recv_addr);
1332
1334
        }
1333
1335
 
1334
1336
        return(recv_addr);
1363
1365
 
1364
1366
        len = rec_end - body;
1365
1367
 
1366
 
        recv = static_cast<recv_t *>(mem_heap_alloc(recv_sys->heap, sizeof(recv_t)));
 
1368
        recv = mem_heap_alloc(recv_sys->heap, sizeof(recv_t));
1367
1369
        recv->type = type;
1368
1370
        recv->len = rec_end - body;
1369
1371
        recv->start_lsn = start_lsn;
1372
1374
        recv_addr = recv_get_fil_addr_struct(space, page_no);
1373
1375
 
1374
1376
        if (recv_addr == NULL) {
1375
 
                recv_addr = static_cast<recv_addr_t *>(mem_heap_alloc(recv_sys->heap,
1376
 
                                           sizeof(recv_addr_t)));
 
1377
                recv_addr = mem_heap_alloc(recv_sys->heap,
 
1378
                                           sizeof(recv_addr_t));
1377
1379
                recv_addr->space = space;
1378
1380
                recv_addr->page_no = page_no;
1379
1381
                recv_addr->state = RECV_NOT_PROCESSED;
1405
1407
                        len = RECV_DATA_BLOCK_SIZE;
1406
1408
                }
1407
1409
 
1408
 
                recv_data = static_cast<recv_data_t *>(mem_heap_alloc(recv_sys->heap,
1409
 
                                           sizeof(recv_data_t) + len));
 
1410
                recv_data = mem_heap_alloc(recv_sys->heap,
 
1411
                                           sizeof(recv_data_t) + len);
1410
1412
                *prev_field = recv_data;
1411
1413
 
1412
1414
                memcpy(recv_data + 1, body, len);
1568
1570
                        /* We have to copy the record body to a separate
1569
1571
                        buffer */
1570
1572
 
1571
 
                        buf = static_cast<byte *>(mem_alloc(recv->len));
 
1573
                        buf = mem_alloc(recv->len);
1572
1574
 
1573
1575
                        recv_data_copy_to_buf(buf, recv);
1574
1576
                } else {
1589
1591
 
1590
1592
                if (recv->start_lsn >= page_lsn) {
1591
1593
 
1592
 
                        ib_uint64_t     page_end_lsn;
 
1594
                        ib_uint64_t     end_lsn;
1593
1595
 
1594
1596
                        if (!modification_to_page) {
1595
1597
 
1613
1615
                                                         buf + recv->len,
1614
1616
                                                         block, &mtr);
1615
1617
 
1616
 
                        page_end_lsn = recv->start_lsn + recv->len;
1617
 
                        mach_write_to_8(FIL_PAGE_LSN + page, page_end_lsn);
 
1618
                        end_lsn = recv->start_lsn + recv->len;
 
1619
                        mach_write_to_8(FIL_PAGE_LSN + page, end_lsn);
1618
1620
                        mach_write_to_8(UNIV_PAGE_SIZE
1619
1621
                                        - FIL_PAGE_END_LSN_OLD_CHKSUM
1620
 
                                        + page, page_end_lsn);
 
1622
                                        + page, end_lsn);
1621
1623
 
1622
1624
                        if (page_zip) {
1623
1625
                                mach_write_to_8(FIL_PAGE_LSN
1624
 
                                                + page_zip->data, page_end_lsn);
 
1626
                                                + page_zip->data, end_lsn);
1625
1627
                        }
1626
1628
                }
1627
1629
 
1657
1659
 
1658
1660
#ifndef UNIV_HOTBACKUP
1659
1661
        if (modification_to_page) {
 
1662
                buf_pool_t*     buf_pool;
 
1663
 
1660
1664
                ut_a(block);
1661
1665
 
 
1666
                buf_pool = buf_pool_from_block(block);
 
1667
 
1662
1668
                log_flush_order_mutex_enter();
1663
1669
                buf_flush_recv_note_modification(block, start_lsn, end_lsn);
1664
1670
                log_flush_order_mutex_exit();
1767
1773
 
1768
1774
        for (i = 0; i < hash_get_n_cells(recv_sys->addr_hash); i++) {
1769
1775
 
1770
 
                recv_addr = static_cast<recv_addr_t *>(HASH_GET_FIRST(recv_sys->addr_hash, i));
 
1776
                recv_addr = HASH_GET_FIRST(recv_sys->addr_hash, i);
1771
1777
 
1772
1778
                while (recv_addr) {
1773
1779
                        ulint   space = recv_addr->space;
1808
1814
                                mutex_enter(&(recv_sys->mutex));
1809
1815
                        }
1810
1816
 
1811
 
                        recv_addr = static_cast<recv_addr_t *>(HASH_GET_NEXT(addr_hash, recv_addr));
 
1817
                        recv_addr = HASH_GET_NEXT(addr_hash, recv_addr);
1812
1818
                }
1813
1819
 
1814
1820
                if (has_printed
2902
2908
        ib_uint64_t     old_scanned_lsn;
2903
2909
        ib_uint64_t     group_scanned_lsn= 0;
2904
2910
        ib_uint64_t     contiguous_lsn;
2905
 
#ifdef UNIV_LOG_ARCHIVE
2906
2911
        ib_uint64_t     archived_lsn;
2907
 
#endif /* UNIV_LOG_ARCHIVE */
2908
2912
        byte*           buf;
2909
2913
        byte            log_hdr_buf[LOG_FILE_HDR_SIZE];
2910
2914
        ulint           err;
2959
2963
 
2960
2964
        checkpoint_lsn = mach_read_from_8(buf + LOG_CHECKPOINT_LSN);
2961
2965
        checkpoint_no = mach_read_from_8(buf + LOG_CHECKPOINT_NO);
2962
 
#ifdef UNIV_LOG_ARCHIVE
2963
2966
        archived_lsn = mach_read_from_8(buf + LOG_CHECKPOINT_ARCHIVED_LSN);
2964
 
#endif /* UNIV_LOG_ARCHIVE */
2965
2967
 
2966
2968
        /* Read the first log file header to print a note if this is
2967
2969
        a recovery from a restored InnoDB Hot Backup */
3267
3269
        }
3268
3270
#endif /* UNIV_DEBUG */
3269
3271
 
 
3272
        if (recv_needed_recovery) {
 
3273
                trx_sys_print_mysql_master_log_pos();
 
3274
                trx_sys_print_mysql_binlog_offset();
 
3275
        }
 
3276
 
3270
3277
        if (recv_sys->found_corrupt_log) {
3271
3278
 
3272
3279
                fprintf(stderr,