Bug #32554 Falcon; Max Key Lengths need to adjust with page size.
Submitted: 20 Nov 2007 22:45 Modified: 3 Dec 2007 14:13
Reporter: Kevin Lewis Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Falcon storage engine Severity:S3 (Non-critical)
Version: OS:Any
Assigned to: Kevin Lewis CPU Architecture:Any

[20 Nov 2007 22:45] Kevin Lewis
Description:
Falcon uses a fixed size for MAX_INDEX_KEY_LENGTH = 1100, defined in IndexKey.h.  This is too large for 1k and 2k pages.  The affect will be a crash similar to those found in Bug#23818.

How to repeat:
Set up a test similar to falcon_bug_23818_A but for 1k and 2k Page sizes.
[20 Nov 2007 23:57] Hakan Küçükyılmaz
falcon_page_size_1.test and falcon_page_size_2.test do fail if run on their own.

Best regards,

Hakan
[27 Nov 2007 20:05] Kevin Lewis
The problem is not as serious as I originally thought for smaller page sizes.  Even though Falcon did not have internal protections to keep the maximum key length from getting too big, it was reporting the correct maximums to the server.  So the server did the enforcing instead.  If the page size is larger than 4k, The server would allow longer keys, but Falcon enforced key lengths at the 4k page level.  So I could not create a testcase that actually caused a crash.  

Changing the Priority to P3.
[27 Nov 2007 21:21] Kevin Lewis
Pushed changes that allow Falcon's internal max key lengths to change according to page size.  There are about a dozen places where a key buffer is allocated on the stack, and these buffers now are much larger, just in case the page size is 32k.
[27 Nov 2007 22:15] Kevin Lewis
The previous comment was not too clear. The changes I pushed affect functions that need to know the maximum key length to protect against accessing the wrong memory.  

The key buffers I referred to on the stack used to be 1320 bytes in length, which is based on 4k page sizes.  
MAX_INDEX_KEY_LENGTH_4K = 1100, 
MAX_INDEX_KEY_RUN_LENGTH = 1100 * 6 / 5 = 1320.

Now, these buffers are 10809
MAX_INDEX_KEY_LENGTH_32K = 9000;
MAX_PHYSICAL_KEY_LENGTH	= (9000; * 6 / 5) + sizeof(int64) + 1 = 10809

Jim thinks these are not too big for the stack, which is quicker than getting them from the memory manager.  These temporary buffers are used quite often.

Just for reference, here are all the Falcon maximum key lengths;
MAX_INDEX_KEY_LENGTH_1K  =  255
MAX_INDEX_KEY_LENGTH_2K  =  540
MAX_INDEX_KEY_LENGTH_4K  = 1100
MAX_INDEX_KEY_LENGTH_8K  = 2200
MAX_INDEX_KEY_LENGTH_16K = 4500
MAX_INDEX_KEY_LENGTH_32K = 9000
[30 Nov 2007 20:43] Bugs System
Pushed into 6.0.4-alpha
[3 Dec 2007 14:13] MC Brown
A note has been added to the 6.0.4 changelog: 

Falcon used a fixed index key size which would be too small to cope with some Falcon page sizes, leading to a crash. Falcon now supports variable length index keys according to the supported page sizes. See falcon_page_size.