Bug #59877 Wrong buffer pool selected in buf_read_ibuf_merge_pages()
Submitted: 1 Feb 2011 20:29 Modified: 4 Jan 2012 21:00
Reporter: Marko Mäkelä Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S2 (Serious)
Version:5.5 OS:Any
Assigned to: Marko Mäkelä CPU Architecture:Any
Tags: multi-buffer-pool

[1 Feb 2011 20:29] Marko Mäkelä
Description:
I noticed this when working on a fix on Bug #59733. The buf_pool_get() call in buf_read_ibuf_merge_pages() is passed space_versions[i] instead of page_nos[i] as the page number. This is obviously wrong and should lead to breakage when running with multiple buffer pools.

How to repeat:
Read the code. Or run a large test with multiple buffer pools, so that the workload does not entirely fit in the buffer pool and the change buffer gets some hammering.

Suggested fix:
=== modified file 'storage/innobase/buf/buf0rea.c'
--- storage/innobase/buf/buf0rea.c	revid:marko.makela@oracle.com-20110131115615-qfli2tcine0nrb7k
+++ storage/innobase/buf/buf0rea.c	2011-02-01 20:23:11 +0000
@@ -535,7 +535,7 @@ buf_read_ibuf_merge_pages(
 		buf_pool_t*	buf_pool;
 		ulint		zip_size = fil_space_get_zip_size(space_ids[i]);
 
-		buf_pool = buf_pool_get(space_ids[i], space_versions[i]);
+		buf_pool = buf_pool_get(space_ids[i], page_nos[i]);
 
 		while (buf_pool->n_pend_reads
 		       > buf_pool->curr_size / BUF_READ_AHEAD_PEND_LIMIT) {
[2 Feb 2011 0:51] MySQL Verification Team
what user-visible side effects does this bug have?  how to know if we're seeing it manifested?
[2 Feb 2011 7:19] Marko Mäkelä
On a closer look, the consequences are not that bad. The buffer pool is only used for choosing whether to have this .5 second delay:

		while (buf_pool->n_pend_reads
		       > buf_pool->curr_size / BUF_READ_AHEAD_PEND_LIMIT) {
			os_thread_sleep(500000);
		}

We can end up delaying even though our buffer pool is not having any pending reads, or not delaying even though there are many pending reads.
[10 Feb 2011 12:08] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/131029
[10 Feb 2011 12:09] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/131030