1529
1529
mutex_exit(&(recv_sys->mutex));
1532
/* This page is allocated from the buffer pool and used in the function
1534
static page_t* recv_backup_application_page = NULL;
1536
/***********************************************************************
1537
Applies log records in the hash table to a backup. */
1540
recv_apply_log_recs_for_backup(void)
1541
/*================================*/
1543
recv_addr_t* recv_addr;
1551
recv_sys->apply_log_recs = TRUE;
1552
recv_sys->apply_batch_on = TRUE;
1554
if (recv_backup_application_page == NULL) {
1555
recv_backup_application_page = buf_frame_alloc();
1558
page = recv_backup_application_page;
1560
fputs("InnoDB: Starting an apply batch of log records"
1561
" to the database...\n"
1562
"InnoDB: Progress in percents: ", stderr);
1564
n_hash_cells = hash_get_n_cells(recv_sys->addr_hash);
1566
for (i = 0; i < n_hash_cells; i++) {
1567
/* The address hash table is externally chained */
1568
recv_addr = hash_get_nth_cell(recv_sys->addr_hash, i)->node;
1570
while (recv_addr != NULL) {
1572
if (!fil_tablespace_exists_in_mem(recv_addr->space)) {
1575
"InnoDB: Warning: cannot apply"
1577
" tablespace %lu page %lu,\n"
1578
"InnoDB: because tablespace with"
1579
" that id does not exist.\n",
1580
recv_addr->space, recv_addr->page_no);
1582
recv_addr->state = RECV_PROCESSED;
1584
ut_a(recv_sys->n_addrs);
1585
recv_sys->n_addrs--;
1587
goto skip_this_recv_addr;
1590
/* We simulate a page read made by the buffer pool, to
1591
make sure the recovery apparatus works ok, for
1592
example, the buf_frame_align() function. We must init
1593
the block corresponding to buf_pool->frame_zero
1596
buf_page_init_for_backup_restore(
1597
recv_addr->space, recv_addr->page_no,
1598
buf_block_align(page));
1600
/* Extend the tablespace's last file if the page_no
1601
does not fall inside its bounds; we assume the last
1602
file is auto-extending, and ibbackup copied the file
1603
when it still was smaller */
1605
success = fil_extend_space_to_desired_size(
1607
recv_addr->space, recv_addr->page_no + 1);
1610
"InnoDB: Fatal error: cannot extend"
1611
" tablespace %lu to hold %lu pages\n",
1612
recv_addr->space, recv_addr->page_no);
1617
/* Read the page from the tablespace file using the
1618
fil0fil.c routines */
1620
error = fil_io(OS_FILE_READ, TRUE, recv_addr->space,
1621
recv_addr->page_no, 0, UNIV_PAGE_SIZE,
1623
if (error != DB_SUCCESS) {
1625
"InnoDB: Fatal error: cannot read"
1627
" %lu page number %lu\n",
1628
(ulong) recv_addr->space,
1629
(ulong) recv_addr->page_no);
1634
/* Apply the log records to this page */
1635
recv_recover_page(TRUE, FALSE, page, recv_addr->space,
1636
recv_addr->page_no);
1638
/* Write the page back to the tablespace file using the
1639
fil0fil.c routines */
1641
buf_flush_init_for_writing(
1642
page, mach_read_from_8(page + FIL_PAGE_LSN),
1643
recv_addr->space, recv_addr->page_no);
1645
error = fil_io(OS_FILE_WRITE, TRUE, recv_addr->space,
1646
recv_addr->page_no, 0, UNIV_PAGE_SIZE,
1648
skip_this_recv_addr:
1649
recv_addr = HASH_GET_NEXT(addr_hash, recv_addr);
1652
if ((100 * i) / n_hash_cells
1653
!= (100 * (i + 1)) / n_hash_cells) {
1654
fprintf(stderr, "%lu ",
1655
(ulong) ((100 * i) / n_hash_cells));
1660
recv_sys_empty_hash();
1533
1663
/***********************************************************************
1534
1664
Tries to parse a single log record and returns its length. */