MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Olav Sandstaa Date:May 26 2009 4:33pm
Subject:Re: bzr commit into mysql-6.0-falcon-team branch
(lars-erik.bjork:2712) Bug#43630
View as plain text  
Hi,

Based on your description of the problem in the commit message and in 
the bug report this patch seems to fix this problem. OK to push.

Just for being curious:

Do you have any idea about what the cost of calling node.expandKey() 
also in the case of the first page? If this was collectible  it would 
make the code simpler by not having to introduce the extra bool variable.

Thanks for fixing this important bug.

Olav

Lars-Erik.Bjork@stripped wrote:
> #At file:///home/lb200670/mysql/clean/ based on
> revid:kevin.lewis@stripped
>
>  2712 lars-erik.bjork@stripped	2009-05-25
>       This is the second of two patches for bug#43630
>       A SELECT using ORDER BY and LIMIT sometimes returns no rows
>       
>       When we look at the first index entry of a page, the following piece of code is
> executed:
>       
>       for (;; first = true)
>       	{
>       	if (first)
>       		{
>       		first = false;
>       		recordNumber = node.getNumber();
>       		
>       		if (recordNumber >= 0)
>       			{
>       			return recordNumber;
>       			}
>       
>       We return the recordNumber without setting up indexKey to reflect the first
> index entry on
>       the page. This will only work in two scenarioes:
>       
>       1: If the key value of the END_BUCKET node on the previous page is the same as
> the key
>       value of the first index node on the current page
>       
>       2: If this is the first page we look at during the search
>       
>       With a lot of UPDATE/DELETE statements, the prerequisites for scenario 1 to be
> correct,
>       may easily be broken, and we will get wrong results.
>       
>       The fix is to call node.expandKey(&indexKey) if this is the first node on
> the page. This
>       is however not necessary if it is the first page we look at during the search,
> as this has
>       already been done in IndexRootPage::positionIndex
>       modified:
>         storage/falcon/WalkIndex.cpp
>         storage/falcon/WalkIndex.h
>
> per-file messages:
>   storage/falcon/WalkIndex.cpp
>     Added a call to node.expandKey(&indexKey) if this is the first valid node on
> a page that is not the first page of the search
>   storage/falcon/WalkIndex.h
>     Added a bool saying if this is the first page in the search. Initialized to
> 'true' in the WalkIndex constructor
> === modified file 'storage/falcon/WalkIndex.cpp'
> --- a/storage/falcon/WalkIndex.cpp	2009-05-09 11:25:17 +0000
> +++ b/storage/falcon/WalkIndex.cpp	2009-05-25 11:10:37 +0000
> @@ -43,6 +43,7 @@ WalkIndex::WalkIndex(Index *index, Trans
>  	
>  	nodes = new UCHAR[transaction->database->dbb->pageSize];
>  	key = indexKey.key;
> +	firstPageInSearch = true;
>  }
>  
>  WalkIndex::~WalkIndex(void)
> @@ -89,6 +90,25 @@ int32 WalkIndex::getNextNode(void)
>  			
>  			if (recordNumber >= 0)
>  				{
> +
> +				if (firstPageInSearch)
> +					{
> +
> +					// indexKey already reflects the first index 
> +					// entry on the page
> +
> +					firstPageInSearch = false;
> +					}
> +				else 
> +					{
> +
> +					// We cannot assume that the key is the same
> +					// as the END_BUCKET key of the previous page, 
> +					// as these values may diverge
> +
> +					node.expandKey(&indexKey);
> +					}
> +
>  				return recordNumber;
>  				}
>  			else if (recordNumber == END_BUCKET)
>
> === modified file 'storage/falcon/WalkIndex.h'
> --- a/storage/falcon/WalkIndex.h	2008-05-07 22:37:18 +0000
> +++ b/storage/falcon/WalkIndex.h	2009-05-25 11:10:37 +0000
> @@ -41,6 +41,7 @@ public:
>  	IndexKey	indexKey;
>  	Btn			*endNodes;
>  	int32		nextPage;
> +	bool		firstPageInSearch;
>  };
>  
>  #endif
>
>
>   

Thread
bzr commit into mysql-6.0-falcon-team branch (lars-erik.bjork:2712) Bug#43630lars-erik.bjork25 May
  • Re: bzr commit into mysql-6.0-falcon-team branch(lars-erik.bjork:2712) Bug#43630Olav Sandstaa26 May