~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

Merge initial InnoDB+ import.

This was applied by generating a patch between MySQL 5.1.50 InnoDB plugin and
the just-merged innodb+ from mysql-trunk revision-id: vasil.dimov@oracle.com-20100422110752-1zowoqxel5xx3z2e

Then, some manual merge resolving and it worked. This should make it much
easier to merge the rest of InnoDB 1.1 and 1.2 from the mysql tree using
my bzr-reapply script.

This takes us to InnoDB 1.1.1(ish).

Show diffs side-by-side

added added

removed removed

Lines of Context:
148
148
the recovery failed and the database may be corrupt. */
149
149
UNIV_INTERN ib_uint64_t recv_max_page_lsn;
150
150
 
 
151
#ifdef UNIV_PFS_THREAD
 
152
UNIV_INTERN mysql_pfs_key_t     trx_rollback_clean_thread_key;
 
153
#endif /* UNIV_PFS_THREAD */
 
154
 
 
155
#ifdef UNIV_PFS_MUTEX
 
156
UNIV_INTERN mysql_pfs_key_t     recv_sys_mutex_key;
 
157
#endif /* UNIV_PFS_MUTEX */
 
158
 
151
159
/* prototypes */
152
160
 
153
161
#ifndef UNIV_HOTBACKUP
175
183
        recv_sys = mem_alloc(sizeof(*recv_sys));
176
184
        memset(recv_sys, 0x0, sizeof(*recv_sys));
177
185
 
178
 
        mutex_create(&recv_sys->mutex, SYNC_RECV);
 
186
        mutex_create(recv_sys_mutex_key, &recv_sys->mutex, SYNC_RECV);
179
187
 
180
188
        recv_sys->heap = NULL;
181
189
        recv_sys->addr_hash = NULL;
296
304
                return;
297
305
        }
298
306
 
 
307
#ifndef UNIV_HOTBACKUP
299
308
        /* Initialize red-black tree for fast insertions into the
300
309
        flush_list during recovery process.
301
310
        As this initialization is done while holding the buffer pool
302
311
        mutex we perform it before acquiring recv_sys->mutex. */
303
 
#ifndef UNIV_HOTBACKUP
304
312
        buf_flush_init_flush_rbt();
 
313
#endif /* !UNIV_HOTBACKUP */
305
314
 
306
315
        mutex_enter(&(recv_sys->mutex));
307
316
 
 
317
#ifndef UNIV_HOTBACKUP
308
318
        recv_sys->heap = mem_heap_create_in_buffer(256);
309
319
#else /* !UNIV_HOTBACKUP */
310
320
        recv_sys->heap = mem_heap_create(256);
321
331
        recv_sys->len = 0;
322
332
        recv_sys->recovered_offset = 0;
323
333
 
324
 
        recv_sys->addr_hash = hash_create(available_memory / 512);
 
334
        recv_sys->addr_hash = hash_create(available_memory / 64);
325
335
        recv_sys->n_addrs = 0;
326
336
 
327
337
        recv_sys->apply_log_recs = FALSE;
361
371
        hash_table_free(recv_sys->addr_hash);
362
372
        mem_heap_empty(recv_sys->heap);
363
373
 
364
 
        recv_sys->addr_hash = hash_create(buf_pool_get_curr_size() / 512);
 
374
        recv_sys->addr_hash = hash_create(buf_pool_get_curr_size() / 256);
365
375
}
366
376
 
367
377
#ifndef UNIV_HOTBACKUP
1649
1659
 
1650
1660
#ifndef UNIV_HOTBACKUP
1651
1661
        if (modification_to_page) {
 
1662
                buf_pool_t*     buf_pool;
 
1663
 
1652
1664
                ut_a(block);
1653
1665
 
 
1666
                buf_pool = buf_pool_from_block(block);
 
1667
 
 
1668
                log_flush_order_mutex_enter();
1654
1669
                buf_flush_recv_note_modification(block, start_lsn, end_lsn);
 
1670
                log_flush_order_mutex_exit();
1655
1671
        }
1656
1672
#endif /* !UNIV_HOTBACKUP */
1657
1673
 
1836
1852
                mutex_exit(&(recv_sys->mutex));
1837
1853
                mutex_exit(&(log_sys->mutex));
1838
1854
 
1839
 
                n_pages = buf_flush_batch(BUF_FLUSH_LIST, ULINT_MAX,
1840
 
                                          IB_ULONGLONG_MAX);
1841
 
                ut_a(n_pages != ULINT_UNDEFINED);
1842
 
 
1843
 
                buf_flush_wait_batch_end(BUF_FLUSH_LIST);
 
1855
                n_pages = buf_flush_list(ULINT_MAX, IB_ULONGLONG_MAX);
 
1856
                ut_a(n_pages != ULINT_UNDEFINED);
 
1857
  
 
1858
                buf_flush_wait_batch_end(NULL, BUF_FLUSH_LIST);
1844
1859
 
1845
1860
                buf_pool_invalidate();
1846
1861
 
2750
2765
                recv_parse_log_recs(store_to_hash);
2751
2766
 
2752
2767
#ifndef UNIV_HOTBACKUP
2753
 
                if (store_to_hash && mem_heap_get_size(recv_sys->heap)
2754
 
                    > available_memory) {
 
2768
                if (store_to_hash
 
2769
                    && mem_heap_get_size(recv_sys->heap) > available_memory) {
2755
2770
 
2756
2771
                        /* Hash table of log records has grown too big:
2757
2772
                        empty it; FALSE means no ibuf operations
2803
2818
                                       group, start_lsn, end_lsn);
2804
2819
 
2805
2820
                finished = recv_scan_log_recs(
2806
 
                        (buf_pool->curr_size - recv_n_pool_free_frames)
2807
 
                        * UNIV_PAGE_SIZE, TRUE, log_sys->buf, RECV_SCAN_SIZE,
 
2821
                        (buf_pool_get_n_pages()
 
2822
                        - (recv_n_pool_free_frames * srv_buf_pool_instances))
 
2823
                        * UNIV_PAGE_SIZE,
 
2824
                        TRUE, log_sys->buf, RECV_SCAN_SIZE,
2808
2825
                        start_lsn, contiguous_lsn, group_scanned_lsn);
2809
2826
                start_lsn = end_lsn;
2810
2827
        }
3424
3441
                sprintf(name, "%s%s%lu", log_dir,
3425
3442
                        ib_logfile_basename, (ulong)i);
3426
3443
 
3427
 
                log_file = os_file_create_simple(name, OS_FILE_CREATE,
3428
 
                                                 OS_FILE_READ_WRITE, &success);
 
3444
                log_file = os_file_create_simple(innodb_file_log_key,
 
3445
                                                 name, OS_FILE_CREATE,
 
3446
                                                 OS_FILE_READ_WRITE,
 
3447
                                                 &success);
3429
3448
                if (!success) {
3430
3449
                        fprintf(stderr,
3431
3450
                                "InnoDB: Cannot create %s. Check that"
3464
3483
                                      LOG_BLOCK_HDR_SIZE);
3465
3484
        sprintf(name, "%s%s%lu", log_dir, ib_logfile_basename, (ulong)0);
3466
3485
 
3467
 
        log_file = os_file_create_simple(name, OS_FILE_OPEN,
 
3486
        log_file = os_file_create_simple(innodb_file_log_key,
 
3487
                                         name, OS_FILE_OPEN,
3468
3488
                                         OS_FILE_READ_WRITE, &success);
3469
3489
        if (!success) {
3470
3490
                fprintf(stderr, "InnoDB: Cannot open %s.\n", name);
3482
3502
#endif /* UNIV_HOTBACKUP */
3483
3503
 
3484
3504
#ifdef UNIV_LOG_ARCHIVE
 
3505
/* Dead code */
3485
3506
/******************************************************//**
3486
3507
Reads from the archive of a log group and performs recovery.
3487
3508
@return TRUE if no more complete consistent archive files */
3514
3535
 
3515
3536
        log_archived_file_name_gen(name, group->id, group->archived_file_no);
3516
3537
 
3517
 
        file_handle = os_file_create(name, OS_FILE_OPEN,
 
3538
        file_handle = os_file_create(innodb_file_log_key,
 
3539
                                     name, OS_FILE_OPEN,
3518
3540
                                     OS_FILE_LOG, OS_FILE_AIO, &ret);
3519
3541
 
3520
3542
        if (ret == FALSE) {
3646
3668
                       read_offset % UNIV_PAGE_SIZE, len, buf, NULL);
3647
3669
 
3648
3670
                ret = recv_scan_log_recs(
3649
 
                        (buf_pool->n_frames - recv_n_pool_free_frames)
 
3671
                        (buf_pool_get_n_pages()
 
3672
                        - (recv_n_pool_free_frames * srv_buf_pool_instances))
3650
3673
                        * UNIV_PAGE_SIZE, TRUE, buf, len, start_lsn,
3651
3674
                        &dummy_lsn, &scanned_lsn);
3652
3675