Commit 4f47daf0 authored by Marko Mäkelä's avatar Marko Mäkelä Committed by Thirunarayanan Balathandayuthapani

Update copyright years, and clean up some things

parent 44e06efa
...@@ -4,7 +4,7 @@ MariaBackup: hot backup tool for InnoDB ...@@ -4,7 +4,7 @@ MariaBackup: hot backup tool for InnoDB
Originally Created 3/3/2009 Yasufumi Kinoshita Originally Created 3/3/2009 Yasufumi Kinoshita
Written by Alexey Kopytov, Aleksandr Kuzminsky, Stewart Smith, Vadim Tkachenko, Written by Alexey Kopytov, Aleksandr Kuzminsky, Stewart Smith, Vadim Tkachenko,
Yasufumi Kinoshita, Ignacio Nin and Baron Schwartz. Yasufumi Kinoshita, Ignacio Nin and Baron Schwartz.
(c) 2017, 2019, MariaDB Corporation. (c) 2017, 2020, MariaDB Corporation.
Portions written by Marko Mäkelä. Portions written by Marko Mäkelä.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
......
/***************************************************************************** /*****************************************************************************
Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2015, 2019, MariaDB Corporation. Copyright (c) 2015, 2020, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software the terms of the GNU General Public License as published by the Free Software
...@@ -766,8 +766,7 @@ buf_read_recv_pages( ...@@ -766,8 +766,7 @@ buf_read_recv_pages(
ulint count = 0; ulint count = 0;
buf_pool = buf_pool_get(cur_page_id); buf_pool = buf_pool_get(cur_page_id);
while (buf_pool->n_pend_reads while (buf_pool->n_pend_reads >= recv_sys.max_log_blocks / 2) {
>= recv_sys.max_log_blocks / 2) {
os_thread_sleep(10000); os_thread_sleep(10000);
......
/***************************************************************************** /*****************************************************************************
Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, 2019, MariaDB Corporation. Copyright (c) 2017, 2020, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software the terms of the GNU General Public License as published by the Free Software
...@@ -284,7 +284,9 @@ struct recv_sys_t{ ...@@ -284,7 +284,9 @@ struct recv_sys_t{
time_t progress_time; time_t progress_time;
using map = std::map<const page_id_t, page_recv_t, using map = std::map<const page_id_t, page_recv_t,
std::less<const page_id_t>>; std::less<const page_id_t>,
ut_allocator
<std::pair<const page_id_t, page_recv_t>>>;
/** buffered records waiting to be applied to pages */ /** buffered records waiting to be applied to pages */
map pages; map pages;
...@@ -355,25 +357,20 @@ struct recv_sys_t{ ...@@ -355,25 +357,20 @@ struct recv_sys_t{
return true; return true;
} }
/** Get the memory block for storing recv_t and redo log data /** Get the memory block for storing recv_t and redo log data
@param[in] len length of the data to be stored @param[in] len length of the data to be stored
@param[in] store_data whether to store overflow block (recv_t::datat) @return pointer to len bytes of memory (never NULL) */
@return pointer to len bytes of memory (never NULL) */ inline byte *alloc(uint32_t len);
byte *alloc(uint32_t len
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
, bool store_data=false /** Find the redo_list element corresponding to a redo log record.
@param[in] data pointer to buffer returned by alloc()
@return redo list element */
buf_block_t *find_block(const void *data) const;
#endif #endif
);
/** Get the free length of the latest block which is the
first block of redo list. Blocks are allocated by alloc().
@return free length */
inline ulong get_free_len() const;
/** Find the redo_list element corresponding to a redo log record. /** @return the free length of the latest alloc() block, in bytes */
@param[in] data redo log record inline ulong get_free_len() const;
@return redo list element */
buf_block_t *get_block(const void *data) const;
}; };
/** The recovery system */ /** The recovery system */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
Copyright (c) 1997, 2017, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1997, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc. Copyright (c) 2012, Facebook Inc.
Copyright (c) 2013, 2019, MariaDB Corporation. Copyright (c) 2013, 2020, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software the terms of the GNU General Public License as published by the Free Software
...@@ -816,6 +816,8 @@ void recv_sys_t::create() ...@@ -816,6 +816,8 @@ void recv_sys_t::create()
inline void recv_sys_t::clear() inline void recv_sys_t::clear()
{ {
ut_ad(mutex_own(&mutex)); ut_ad(mutex_own(&mutex));
apply_log_recs= false;
apply_batch_on= false;
pages.clear(); pages.clear();
buf_block_t *prev_block= nullptr; buf_block_t *prev_block= nullptr;
...@@ -824,6 +826,7 @@ inline void recv_sys_t::clear() ...@@ -824,6 +826,7 @@ inline void recv_sys_t::clear()
{ {
prev_block= UT_LIST_GET_PREV(unzip_LRU, block); prev_block= UT_LIST_GET_PREV(unzip_LRU, block);
ut_ad(buf_block_get_state(block) == BUF_BLOCK_MEMORY); ut_ad(buf_block_get_state(block) == BUF_BLOCK_MEMORY);
ut_ad(block->page.buf_fix_count == 0);
UT_LIST_REMOVE(redo_list, block); UT_LIST_REMOVE(redo_list, block);
buf_block_free(block); buf_block_free(block);
} }
...@@ -860,79 +863,42 @@ inline ulong recv_sys_t::get_free_len() const ...@@ -860,79 +863,42 @@ inline ulong recv_sys_t::get_free_len() const
return srv_page_size - UT_LIST_GET_FIRST(redo_list)->modify_clock; return srv_page_size - UT_LIST_GET_FIRST(redo_list)->modify_clock;
} }
byte* recv_sys_t::alloc(uint32_t len inline byte* recv_sys_t::alloc(uint32_t len)
#ifdef UNIV_DEBUG
,bool store_data
#endif
)
{ {
buf_block_t *block= UT_LIST_GET_FIRST(redo_list); ut_ad(mutex_own(&mutex));
uint64_t free_offset= !block ? 0:block->modify_clock; ut_ad(len);
ut_ad(len <= srv_page_size);
if (!store_data &&
(free_offset + len + sizeof(recv_t::data) + 1) >= srv_page_size)
goto create_block;
if (!UT_LIST_GET_LEN(redo_list)) buf_block_t *block= UT_LIST_GET_FIRST(redo_list);
goto create_block; if (UNIV_UNLIKELY(!block))
if (free_offset + len <= srv_page_size)
{
#ifdef UNIV_DEBUG
if (store_data)
block->page.fix();
#endif
block->modify_clock+= len;
}
else
{ {
create_block: create_block:
buf_block_t *new_block= buf_block_alloc(nullptr); block= buf_block_alloc(nullptr);
new_block->modify_clock= 0; block->modify_clock= len;
UT_LIST_ADD_FIRST(redo_list, new_block); UT_LIST_ADD_FIRST(redo_list, block);
return block->frame;
#ifdef UNIV_DEBUG
if (store_data)
new_block->page.fix();
#endif
if (len < srv_page_size)
new_block->modify_clock+= len;
else
new_block->modify_clock= srv_page_size;
return new_block->frame;
} }
uint64_t free_offset= block->modify_clock;
ut_ad(free_offset <= srv_page_size);
free_offset+= len;
if (free_offset > srv_page_size)
goto create_block;
block->modify_clock+= len;
return block->frame + free_offset; return block->frame + free_offset;
} }
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
static void validate_redo_blocks() inline buf_block_t *recv_sys_t::find_block(const void* data) const
{
buf_block_t *prev_block= nullptr;
for (buf_block_t *block= UT_LIST_GET_LAST(recv_sys.redo_list);
block != nullptr;)
{
prev_block= UT_LIST_GET_PREV(unzip_LRU, block);
if (0 == Atomic_counter<uint32_t>(block->page.buf_fix_count))
{
UT_LIST_REMOVE(recv_sys.redo_list, block);
buf_block_free(block);
}
block= prev_block;
}
}
#endif
buf_block_t *recv_sys_t::get_block(const void* page) const
{ {
data= page_align(data);
for (buf_block_t *block= UT_LIST_GET_LAST(redo_list); for (buf_block_t *block= UT_LIST_GET_LAST(redo_list);
block; block = UT_LIST_GET_PREV(unzip_LRU, block)) block; block = UT_LIST_GET_PREV(unzip_LRU, block))
if (block->frame == page_align(page)) if (block->frame == data)
return block; return block;
ut_ad(0);
return nullptr; return nullptr;
} }
#endif
/** Read a log segment to log_sys.buf. /** Read a log segment to log_sys.buf.
@param[in,out] start_lsn in: read area start, @param[in,out] start_lsn in: read area start,
...@@ -1829,18 +1795,15 @@ inline void recv_sys_t::add(mlog_id_t type, const page_id_t page_id, ...@@ -1829,18 +1795,15 @@ inline void recv_sys_t::add(mlog_id_t type, const page_id_t page_id,
heap grows into the buffer pool. */ heap grows into the buffer pool. */
uint32_t len= uint32_t(rec_end - body); uint32_t len= uint32_t(rec_end - body);
recv_t* recv = new (alloc(sizeof(recv_t))) recv_t *recv= new (alloc(sizeof(recv_t))) recv_t(len, type, lsn, end_lsn);
recv_t(len, type, lsn, end_lsn);
recs.log.append(recv); recs.log.append(recv);
for (recv_t::data_t *prev= NULL;;) { for (recv_t::data_t *prev= nullptr;;) {
uint32_t data_free_limit = get_free_len() - sizeof(recv_t::data); uint32_t data_free_limit = get_free_len() - sizeof(recv_t::data);
const uint32_t l= std::min(len, data_free_limit); const uint32_t l= std::min(len, data_free_limit);
recv_t::data_t *d= new (alloc(sizeof(recv_t::data) + l recv_t::data_t *d= new (alloc(sizeof(recv_t::data) + l))
#ifdef UNIV_DEBUG recv_t::data_t(body, l);
, true ut_d(find_block(d)->fix());
#endif
))recv_t::data_t(body, l);
if (prev) if (prev)
prev->append(d); prev->append(d);
else else
...@@ -1891,24 +1854,22 @@ recv_data_copy_to_buf( ...@@ -1891,24 +1854,22 @@ recv_data_copy_to_buf(
const recv_t& recv) /*!< in: log record */ const recv_t& recv) /*!< in: log record */
{ {
const recv_t::data_t* recv_data = recv.data; const recv_t::data_t* recv_data = recv.data;
page_t* initial_page = page_align(recv_data);
ulint len = recv.len; ulint len = recv.len;
do { do {
ulint offset = page_offset(recv_data + 1); ulint offset = page_offset(recv_data + 1);
buf_block_t* block = recv_sys.get_block(recv_data);
const ulint chunk_limit = (srv_page_size - offset); const ulint chunk_limit = (srv_page_size - offset);
const ulint l = std::min(len, chunk_limit); const ulint l = std::min(len, chunk_limit);
memcpy(buf, reinterpret_cast<const byte*>(recv_data + 1), l); memcpy(buf, reinterpret_cast<const byte*>(recv_data + 1), l);
recv_data = recv_data->next;
buf += l;
len -= l;
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
if (initial_page != block->frame) { if ((ulint(recv.data) ^ ulint(recv_data))
block->page.unfix(); & (srv_page_size - 1)) {
recv_sys.find_block(recv_data)->unfix();
} }
#endif #endif
recv_data = recv_data->next;
buf += l;
len -= l;
} while (len); } while (len);
} }
...@@ -1998,8 +1959,6 @@ static void recv_recover_page(buf_block_t* block, mtr_t& mtr, ...@@ -1998,8 +1959,6 @@ static void recv_recover_page(buf_block_t* block, mtr_t& mtr,
ulint data_offset = page_offset(recv->data + 1); ulint data_offset = page_offset(recv->data + 1);
byte* buf; byte* buf;
const byte* recs; const byte* recs;
ut_d(buf_block_t* first_block = recv_sys.get_block(
recv->data + 1););
if (srv_page_size - data_offset < recv->len) { if (srv_page_size - data_offset < recv->len) {
/* We have to copy the record body to /* We have to copy the record body to
...@@ -2017,7 +1976,7 @@ static void recv_recover_page(buf_block_t* block, mtr_t& mtr, ...@@ -2017,7 +1976,7 @@ static void recv_recover_page(buf_block_t* block, mtr_t& mtr,
recv->type, recs, recs + recv->len, recv->type, recs, recs + recv->len,
block->page.id, true, block, &mtr); block->page.id, true, block, &mtr);
ut_d(first_block->page.unfix()); ut_d(recv_sys.find_block(recv)->unfix());
ut_free(buf); ut_free(buf);
end_lsn = recv->start_lsn + recv->len; end_lsn = recv->start_lsn + recv->len;
...@@ -2381,15 +2340,8 @@ void recv_apply_hashed_log_recs(bool last_batch) ...@@ -2381,15 +2340,8 @@ void recv_apply_hashed_log_recs(bool last_batch)
mlog_init.mark_ibuf_exist(mtr); mlog_init.mark_ibuf_exist(mtr);
} }
recv_sys.apply_log_recs = false;
recv_sys.apply_batch_on = false;
recv_sys.clear(); recv_sys.clear();
#ifdef UNIV_DEBUG
validate_redo_blocks();
#endif
mutex_exit(&recv_sys.mutex); mutex_exit(&recv_sys.mutex);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment