Skip to content

Commit b797f21

Browse files
committed
Merge 10.5 into 10.6
2 parents 9ec3cd9 + f0f47cb commit b797f21

File tree

3 files changed

+8
-115
lines changed

3 files changed

+8
-115
lines changed

storage/innobase/buf/buf0buf.cc

Lines changed: 2 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,13 +1296,6 @@ void buf_pool_t::close()
12961296
ut_free(chunks);
12971297
chunks= nullptr;
12981298
page_hash.free();
1299-
while (page_hash_table *old_page_hash= freed_page_hash)
1300-
{
1301-
freed_page_hash= static_cast<page_hash_table*>
1302-
(old_page_hash->array[1].node);
1303-
old_page_hash->free();
1304-
UT_DELETE(old_page_hash);
1305-
}
13061299
zip_hash.free();
13071300

13081301
io_buf.close();
@@ -1581,57 +1574,6 @@ inline bool buf_pool_t::withdraw_blocks()
15811574
return(false);
15821575
}
15831576

1584-
/** resize page_hash and zip_hash */
1585-
inline void buf_pool_t::resize_hash()
1586-
{
1587-
page_hash_table *new_page_hash= UT_NEW_NOKEY(page_hash_table());
1588-
new_page_hash->create(2 * buf_pool.curr_size);
1589-
new_page_hash->write_lock_all();
1590-
1591-
for (auto i= page_hash.pad(page_hash.n_cells); i--; )
1592-
{
1593-
static_assert(!((page_hash_table::ELEMENTS_PER_LATCH + 1) &
1594-
page_hash_table::ELEMENTS_PER_LATCH),
1595-
"must be one less than a power of 2");
1596-
if (!(i & page_hash_table::ELEMENTS_PER_LATCH))
1597-
{
1598-
ut_ad(reinterpret_cast<page_hash_latch*>
1599-
(&page_hash.array[i])->is_write_locked());
1600-
continue;
1601-
}
1602-
while (buf_page_t *bpage= static_cast<buf_page_t*>
1603-
(page_hash.array[i].node))
1604-
{
1605-
ut_ad(bpage->in_page_hash);
1606-
const ulint fold= bpage->id().fold();
1607-
HASH_DELETE(buf_page_t, hash, &buf_pool.page_hash, fold, bpage);
1608-
HASH_INSERT(buf_page_t, hash, new_page_hash, fold, bpage);
1609-
}
1610-
}
1611-
1612-
buf_pool.page_hash.array[1].node= freed_page_hash;
1613-
std::swap(buf_pool.page_hash, *new_page_hash);
1614-
freed_page_hash= new_page_hash;
1615-
1616-
/* recreate zip_hash */
1617-
hash_table_t new_hash;
1618-
new_hash.create(2 * buf_pool.curr_size);
1619-
1620-
for (ulint i= 0; i < buf_pool.zip_hash.n_cells; i++)
1621-
{
1622-
while (buf_page_t *bpage= static_cast<buf_page_t*>
1623-
(HASH_GET_FIRST(&buf_pool.zip_hash, i)))
1624-
{
1625-
const ulint fold= BUF_POOL_ZIP_FOLD_BPAGE(bpage);
1626-
HASH_DELETE(buf_page_t, hash, &buf_pool.zip_hash, fold, bpage);
1627-
HASH_INSERT(buf_page_t, hash, &new_hash, fold, bpage);
1628-
}
1629-
}
1630-
1631-
std::swap(buf_pool.zip_hash.array, new_hash.array);
1632-
buf_pool.zip_hash.n_cells= new_hash.n_cells;
1633-
new_hash.free();
1634-
}
16351577

16361578

16371579
inline void buf_pool_t::page_hash_table::write_lock_all()
@@ -1656,26 +1598,6 @@ inline void buf_pool_t::page_hash_table::write_unlock_all()
16561598
}
16571599

16581600

1659-
inline void buf_pool_t::write_lock_all_page_hash()
1660-
{
1661-
mysql_mutex_assert_owner(&mutex);
1662-
page_hash.write_lock_all();
1663-
for (page_hash_table *old_page_hash= freed_page_hash; old_page_hash;
1664-
old_page_hash= static_cast<page_hash_table*>
1665-
(old_page_hash->array[1].node))
1666-
old_page_hash->write_lock_all();
1667-
}
1668-
1669-
1670-
inline void buf_pool_t::write_unlock_all_page_hash()
1671-
{
1672-
page_hash.write_unlock_all();
1673-
for (page_hash_table *old_page_hash= freed_page_hash; old_page_hash;
1674-
old_page_hash= static_cast<page_hash_table*>
1675-
(old_page_hash->array[1].node))
1676-
old_page_hash->write_unlock_all();
1677-
}
1678-
16791601
namespace
16801602
{
16811603

@@ -1848,7 +1770,7 @@ inline void buf_pool_t::resize()
18481770
resizing.store(true, std::memory_order_relaxed);
18491771

18501772
mysql_mutex_lock(&mutex);
1851-
write_lock_all_page_hash();
1773+
page_hash.write_lock_all();
18521774

18531775
chunk_t::map_reg = UT_NEW_NOKEY(chunk_t::map());
18541776

@@ -2004,16 +1926,8 @@ inline void buf_pool_t::resize()
20041926
= srv_buf_pool_base_size > srv_buf_pool_size * 2
20051927
|| srv_buf_pool_base_size * 2 < srv_buf_pool_size;
20061928

2007-
/* Normalize page_hash and zip_hash,
2008-
if the new size is too different */
2009-
if (!warning && new_size_too_diff) {
2010-
buf_resize_status("Resizing hash table");
2011-
resize_hash();
2012-
ib::info() << "hash tables were resized";
2013-
}
2014-
20151929
mysql_mutex_unlock(&mutex);
2016-
write_unlock_all_page_hash();
1930+
page_hash.write_unlock_all();
20171931

20181932
UT_DELETE(chunk_map_old);
20191933

storage/innobase/buf/buf0flu.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ buf_flush_relocate_on_flush_list(
305305
/* FIXME: Can we avoid holding buf_pool.mutex here? */
306306
ut_ad(dpage->oldest_modification() == lsn);
307307

308-
if (const lsn_t o_lsn = bpage->oldest_modification()) {
308+
if (ut_d(const lsn_t o_lsn =) bpage->oldest_modification()) {
309309
ut_ad(o_lsn == lsn);
310310

311311
/* Important that we adjust the hazard pointer before removing
@@ -324,7 +324,7 @@ buf_flush_relocate_on_flush_list(
324324
}
325325

326326
if (lsn == 1) {
327-
buf_pool.stat.flush_list_bytes -= bpage->physical_size();
327+
buf_pool.stat.flush_list_bytes -= dpage->physical_size();
328328
was_clean:
329329
dpage->list.prev = nullptr;
330330
dpage->list.next = nullptr;

storage/innobase/include/buf0buf.h

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1795,22 +1795,14 @@ class buf_pool_t
17951795
page_hash_latch *lock_get(ulint fold) const
17961796
{ return lock_get(fold, n_cells); }
17971797

1798-
/** Acquire an array latch, tolerating concurrent buf_pool_t::resize()
1798+
/** Acquire an array latch.
17991799
@tparam exclusive whether the latch is to be acquired exclusively
18001800
@param fold hash bucket key */
18011801
template<bool exclusive> page_hash_latch *lock(ulint fold)
18021802
{
1803-
for (;;)
1804-
{
1805-
auto n= n_cells;
1806-
page_hash_latch *latch= lock_get(fold, n);
1807-
latch->acquire<exclusive>();
1808-
/* Our latch prevents n_cells from changing. */
1809-
if (UNIV_LIKELY(n == n_cells))
1810-
return latch;
1811-
/* Retry, because buf_pool_t::resize_hash() affected us. */
1812-
latch->release<exclusive>();
1813-
}
1803+
page_hash_latch *latch= lock_get(fold, n_cells);
1804+
latch->acquire<exclusive>();
1805+
return latch;
18141806
}
18151807

18161808
/** Exclusively aqcuire all latches */
@@ -1820,19 +1812,6 @@ class buf_pool_t
18201812
inline void write_unlock_all();
18211813
};
18221814

1823-
private:
1824-
/** Former page_hash that has been deleted during resize();
1825-
singly-linked list via freed_page_hash->array[1] */
1826-
page_hash_table *freed_page_hash;
1827-
1828-
/** Lock all page_hash, also freed_page_hash. */
1829-
inline void write_lock_all_page_hash();
1830-
/** Release all page_hash, also freed_page_hash. */
1831-
inline void write_unlock_all_page_hash();
1832-
/** Resize page_hash and zip_hash. */
1833-
inline void resize_hash();
1834-
1835-
public:
18361815
/** Hash table of file pages (buf_page_t::in_file() holds),
18371816
indexed by page_id_t. Protected by both mutex and page_hash.lock_get(). */
18381817
page_hash_table page_hash;

0 commit comments

Comments
 (0)