Commit d963584d authored by Marko Mäkelä's avatar Marko Mäkelä

Merge 10.5 into 10.6

parents 4c16ec3e 78c9a12c
...@@ -404,7 +404,7 @@ static bool buf_page_decrypt_after_read(buf_page_t *bpage, ...@@ -404,7 +404,7 @@ static bool buf_page_decrypt_after_read(buf_page_t *bpage,
if (id.space() == SRV_TMP_SPACE_ID if (id.space() == SRV_TMP_SPACE_ID
&& innodb_encrypt_temporary_tables) { && innodb_encrypt_temporary_tables) {
slot = buf_pool.io_buf_reserve(); slot = buf_pool.io_buf_reserve(false);
slot->allocate(); slot->allocate();
bool ok = buf_tmp_page_decrypt(slot->crypt_buf, dst_frame); bool ok = buf_tmp_page_decrypt(slot->crypt_buf, dst_frame);
slot->release(); slot->release();
...@@ -426,7 +426,7 @@ static bool buf_page_decrypt_after_read(buf_page_t *bpage, ...@@ -426,7 +426,7 @@ static bool buf_page_decrypt_after_read(buf_page_t *bpage,
return false; return false;
} }
slot = buf_pool.io_buf_reserve(); slot = buf_pool.io_buf_reserve(false);
slot->allocate(); slot->allocate();
decompress_with_slot: decompress_with_slot:
...@@ -449,7 +449,7 @@ static bool buf_page_decrypt_after_read(buf_page_t *bpage, ...@@ -449,7 +449,7 @@ static bool buf_page_decrypt_after_read(buf_page_t *bpage,
return false; return false;
} }
slot = buf_pool.io_buf_reserve(); slot = buf_pool.io_buf_reserve(false);
slot->allocate(); slot->allocate();
/* decrypt using crypt_buf to dst_frame */ /* decrypt using crypt_buf to dst_frame */
...@@ -1307,14 +1307,17 @@ void buf_pool_t::io_buf_t::close() ...@@ -1307,14 +1307,17 @@ void buf_pool_t::io_buf_t::close()
n_slots= 0; n_slots= 0;
} }
buf_tmp_buffer_t *buf_pool_t::io_buf_t::reserve() buf_tmp_buffer_t *buf_pool_t::io_buf_t::reserve(bool wait_for_reads)
{ {
for (;;) for (;;)
{ {
for (buf_tmp_buffer_t *s= slots, *e= slots + n_slots; s != e; s++) for (buf_tmp_buffer_t *s= slots, *e= slots + n_slots; s != e; s++)
if (s->acquire()) if (s->acquire())
return s; return s;
buf_dblwr.flush_buffered_writes();
os_aio_wait_until_no_pending_writes(true); os_aio_wait_until_no_pending_writes(true);
if (!wait_for_reads)
continue;
for (buf_tmp_buffer_t *s= slots, *e= slots + n_slots; s != e; s++) for (buf_tmp_buffer_t *s= slots, *e= slots + n_slots; s != e; s++)
if (s->acquire()) if (s->acquire())
return s; return s;
......
...@@ -693,7 +693,7 @@ static byte *buf_page_encrypt(fil_space_t* space, buf_page_t* bpage, byte* s, ...@@ -693,7 +693,7 @@ static byte *buf_page_encrypt(fil_space_t* space, buf_page_t* bpage, byte* s,
ut_ad(!bpage->zip_size() || !page_compressed); ut_ad(!bpage->zip_size() || !page_compressed);
/* Find free slot from temporary memory array */ /* Find free slot from temporary memory array */
*slot= buf_pool.io_buf_reserve(); *slot= buf_pool.io_buf_reserve(true);
ut_a(*slot); ut_a(*slot);
(*slot)->allocate(); (*slot)->allocate();
......
...@@ -1884,7 +1884,8 @@ class buf_pool_t ...@@ -1884,7 +1884,8 @@ class buf_pool_t
a delete-buffering operation is pending. Protected by mutex. */ a delete-buffering operation is pending. Protected by mutex. */
buf_page_t watch[innodb_purge_threads_MAX + 1]; buf_page_t watch[innodb_purge_threads_MAX + 1];
/** Reserve a buffer. */ /** Reserve a buffer. */
buf_tmp_buffer_t *io_buf_reserve() { return io_buf.reserve(); } buf_tmp_buffer_t *io_buf_reserve(bool wait_for_reads)
{ return io_buf.reserve(wait_for_reads); }
private: private:
/** Remove a block from the flush list. */ /** Remove a block from the flush list. */
...@@ -1916,7 +1917,7 @@ class buf_pool_t ...@@ -1916,7 +1917,7 @@ class buf_pool_t
void close(); void close();
/** Reserve a buffer */ /** Reserve a buffer */
buf_tmp_buffer_t *reserve(); buf_tmp_buffer_t *reserve(bool wait_for_reads);
} io_buf; } io_buf;
/** whether resize() is in the critical path */ /** whether resize() is in the critical path */
......
...@@ -155,12 +155,11 @@ template<typename T> class cache ...@@ -155,12 +155,11 @@ template<typename T> class cache
{ {
mysql_mutex_lock(&m_mtx); mysql_mutex_lock(&m_mtx);
assert(!is_full()); assert(!is_full());
const bool was_empty= is_empty();
// put element to the logical end of the array // put element to the logical end of the array
m_cache[--m_pos] = ele; m_cache[--m_pos] = ele;
/* Notify waiters when the cache becomes if (was_empty || (is_full() && m_waiters))
not empty, or when it becomes full */
if (m_pos == 1 || (m_waiters && is_full()))
pthread_cond_broadcast(&m_cv); pthread_cond_broadcast(&m_cv);
mysql_mutex_unlock(&m_mtx); mysql_mutex_unlock(&m_mtx);
} }
......
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