buf_zip_decompress(). This will prevent btr_cur_search_to_nth_level()
from accessing a half-decompressed leaf page. Internal B-tree nodes
(non-leaf pages) in B-tree searches are only protected by the tree
latch (index->lock) and by buffer-fixing.
buf_pool->page_hash and buf_pool->LRU before releasing buf_pool->mutex.
buf_page_init_for_read(), buf_page_create(): Allocate the compressed
page after the block has been added to the buffer pool. Document the
reason for this.
buf_page_init(): Declare block->frame valid only in the system tablespace.
trx_sysf_create(): Declare the rest of the page valid, although it is
uninitialized.
buf_buddy_relocate(): Document that src may have been split and some of
it may be in buf_pool->zip_free[j] for some j<i, thus mach_read_from_4()
may be reading from free memory. Check buffer pages only for addressability,
not for being completely initialized. Ensure that block descriptors are
completely initialized.
buf_buddy_remove_from_free(): Check prev->state and next->state in
UNIV_DEBUG && UNIV_DEBUG_VALGRIND builds.
buf_buddy_free_low(): Flag the entire block valid prior to invoking
buf_buddy_remove_from_free() in order to avoid a Valgrind warning about
the debug assertion on bpage->state. Remove the Valgrind check for
buddy being completely allocated. If it has been split to smaller blocks,
some of those blocks may be free.
UNIV_MEM_FREE(): Declare a memory area free.
UNIV_MEM_ALLOC(): Declare a memory area allocated (but uninitialized).
UNIV_MEM_DESC(): Associate a memory area with a control block.
UNIV_MEM_UNDESC(): Unassociate a control block.
trx_sys_create_doublewrite_buf(): Clear the buffer with memset().
buf_page_init(): Add a bogus UNIV_MEM_VALID(block->frame) to silence
valid warnings about InnoDB data pages containing uninitialized data.
buf_LRU_get_free_only(): Add UNIV_MEM_ALLOC(block->frame).
buf_LRU_get_free_block(): Add UNIV_MEM_DESC(block->page.zip.data, block).
buf_LRU_free_block(): Add UNIV_MEM_DESC(b->zip.data, b) when allocating
a compressed-only control block for a compressed page.
buf_LRU_block_free_non_file_page(): Replace UNIV_MEM_INVALID() with
UNIV_MEM_FREE().
buf_LRU_block_remove_hashed_page(): Add UNIV_MEM_UNDESC(bpage) when
deallocating a compressed-only control block. Add
UNIV_MEM_INVALID(block->frame). (The frame should be flagged free
by buf_LRU_block_free_non_file_page() moments later.)
buf0buddy.c: Disable some extra checks in Valgrind-instrumented builds.
Add UNIV_MEM_VALID(), UNIV_MEM_INVALID(), UNIV_MEM_FREE(), UNIV_MEM_ALLOC()
as necessary.
buf_buddy_block_free(), buf_buddy_free_low(): Flag the freed bytes
uninitialized.
buf_page_init_for_read(), buf_buddy_relocate(): Do not refer to bpage
after invoking buf_relocate().
buf_buddy_relocate(): Flag src uninitialized.
during the buf_zip_decompress() call. Otherwise, the block may end
up being freed by another thread. This bug was caught by the
page_zip_validate() check in buf_LRU_block_remove_hashed_page().
buf_page_init_for_read(): Protect the buf_zip_decompress() call with
an X-lock on the block.
page_zip_validate(): Move the page_is_comp() assertion after the
page header comparison.
compressed-only page, restart the scan of the LRU list, because
prev_bpage may have been relocated.
buf_LRU_block_remove_hashed_page(): Note that other compressed pages
or compressed-only blocks may be relocated when freeing a compressed
page or a compressed-only block descriptor.
dirty uncompressed blocks. Move the page_zip_validate() call to
a more appropriate place, buf_LRU_block_remove_hashed_page().
buf_LRU_block_remove_hashed_page(): Allow bpage->oldest_modification != 0
for uncompressed pages if there is a compressed page that will be preserved.
Release the mutexes before calling buf_print() and buf_LRU_print().
page_zip_validate(): Remove the assertion containing the
buf_frame_get_page_zip() call. We might already be holding buf_pool->mutex.
the buffer pool.
buf_LRU_free_block(): When preserving the compressed page, compute the
checksum. Also assert page_zip_validate().
buf_zip_decompress(): Add parameter "check" for enabling checksum tests.
Before decompressing a compressed-only page from the buffer pool, verify
the compressed page checksum.
buf_page_get_gen(): Note that buf_read_page() may uncompress
a compressed-only page.
buf_page_create(): Test buf_page_in_file() instead of BUF_BLOCK_FILE_PAGE.
and add compressed-only pages to buf_pool->page_hash.
BUF_POOL_ZIP_FOLD(), BUF_POOL_ZIP_FOLD_PTR(), BUF_POOL_ZIP_FOLD_BPAGE():
Macros for computing buf_pool->zip_hash fold values. Make use of these
in buf0buddy.c.
buf0buddy.c: Replace some ptr == ut_align_down(ptr, ...) in assertions with
!ut_align_offset(ptr, ...).
to BUF_BLOCK_ZIP_DIRTY (discarding the uncompressed page corresponding
to a modified compressed page that has not been flushed to disk).
buf_page_can_relocate(): New function, modelled after
buf_flush_ready_for_replace().
buf_LRU_free_block(): Allow the transition to BUF_BLOCK_ZIP_DIRTY.
buf_flush_insert_into_flush_list(): Make the prototype public.
buf_buddy_relocate(): Remove an unnecessary switch statement.
Use buf_page_can_relocate() instead of buf_flush_ready_for_replace().
buf_page_peek(): Made UNIV_INLINE.
Document UNIV_ZIP_DEBUG.
Improve diagnostics.
buf_buddy_relocate(): Do not assume all small blocks to contain only one
buf_page_t object. Require an exact size match, as in the case of
compressed pages.
buf_relocate(): Relocate buf_pool->LRU_old if needed.
Validate the LRU list in debug builds.
buf_LRU_block_remove_hashed_page(): Do not overwrite FIL_PAGE_OFFSET
or FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID. The memory will be invalidated
in debug builds of buf_buddy_free().
buf0buddy.c: Add assertions for not holding buf_pool->zip_mutex.
The calling thread should not be holding any block->mutex, but it might
be too time-consuming to assert against that, even #ifdef UNIV_SYNC_DEBUG.
There is something wrong with the management of compressed-only blocks
(BUF_BLOCK_ZIP_PAGE). To disable the creation of such blocks, set zip=TRUE
in buf_LRU_block_remove_hashed_page().
buf_LRU_block_remove_hashed_page(): Release buf_pool->zip_mutex when
freeing a compressed-only page and its control block, with buf_buddy_free().
Adapt callers.
buf_LRU_block_free_hashed_page(): Change the parameter type from buf_page_t*
to buf_block_t*.
buf_LRU_free_block(): Move below the definition of buf_LRU_add_block_low().
Allocate block descriptor for compressed-only blocks.
buf_LRU_block_free_non_file_page(): Replace ut_free() with buf_buddy_free().
buf_zip_decompress(): New function, split from buf_page_io_complete().
buf_page_init_for_read(): Do not allocate the compressed page until it is
really needed, to avoid the overhead of the buddy allocator. Decompress
compressed-only blocks that are needed again.
buf_page_create(): Do not allocate the compressed page until it is
really needed, to avoid the overhead of the buddy allocator.
buf_validate(): Replace some equality tests on the lengths of the LRU
list and the flush lists with greater-or-equal tests, since the counted
numbers do not include control blocks for compressed-only pages.
buf_buddy_get(): New function in buf0buddy.c, to replace the macro
in buf0buddy.h.
buf_buddy_get_offset(): Remove.
buf_buddy_get_slot(): Remove the prototype from buf0buddy.h. This function
is for internal use in buf0buddy.ic.
buf_page_get_gen(): Cache the result of fil_space_get_zip_size().
trx_commit_off_kernel(): Eliminate the flag must_flush_log. Initialize lsn = 0
to signify must_flush_log == FALSE.
log_flush_margin(): Eliminate the flag do_flush. Initialize lsn = 0
to signify do_flush == FALSE.
buf_buddy_block_free(): Remove the block from buf_pool->zip_hash.
buf_buddy_alloc_clean(): Test for buf_page_in_file() before
invoking buf_LRU_free_block(). The LRU list also contains "half-freed"
blocks (state == BUF_BLOCK_REMOVE_HASH).
twice the maximum block size of the buddy system.
buf_page_t: Note that state may change from BUF_BLOCK_READY_FOR_USE
to BUF_BLOCK_MEMORY without buf_page_get_mutex() protection
[only buf_pool->mutex].
buf_buddy_get_slot(): Extend the output to BUF_BUDDY_SIZES.
buf_buddy_alloc(), buf_buddy_free(): Allow sizes up to UNIV_PAGE_SIZE.
buf_buddy_alloc_low(), buf_buddy_free_low(), buf_buddy_alloc_clean():
Allow i==BUF_BUDDY_SIZES.
buf_buddy_free(), buf_buddy_free_low(): Document that the data must
not be pointed to by the buffer pool. Add ut_ad(!buf_pool_contains_zip())
assertions to catch pointers to freed blocks.
Validate the zip_free[] lists #ifdef UNIV_DEBUG.
buf_buddy_relocate(): Ensure that the size of the compressed page
matches. The buddy block can be split, and the control block can be
pointing to a smaller compressed page than the one whose relocation
is being attempted.
buf_buddy_alloc_zip() [UNIV_DEBUG]: Byte-fill the allocated blocks with ~i.
buf_buddy_block_free() [UNIV_DEBUG]: Clear the frame before releasing it
to the buffer pool.
buf_buddy_alloc_from() [UNIV_DEBUG]: Byte-fill the free blocks with j.
buf_buddy_relocate(): Allow the buf_page_hash_get() lookup to fail,
and note the reason.
buf_buddy_free_low(): Correctly compute the address of the combined free block.
buf_page_struct: Clarify the mutex protection rules. Note that
the pointer zip.data is also protected by buf_pool->mutex.
buf_buddy_alloc_zip(): Calculate the address with char* aritmetics.
buf_buddy_alloc_clean(): Acquire a mutex on the block before
calling buf_LRU_free_block().
buf_buddy_relocate(): Remove the bogus assertion about src and dst
being buddies of each other. Use mach_read_from_4() instead of
page_get_space_id() and page_get_page_no() to avoid page alignment
assertions.
buf_buddy_free_low(): Replace bogus assertions.
buf_LRU_block_remove_hashed_page(): Return the new state of the block.
Only call buf_LRU_block_free_hashed_page()
if buf_LRU_block_remove_hashed_page() did not return BUF_BLOCK_ZIP_FREE,
that is, the control block was not freed.
buf_LRU_insert_zip_clean(): New function, for inserting a compressed-only
block into buf_pool->zip_clean in the LRU order.
buf_LRU_block_remove_hashed_page(), buf_LRU_free_block():
Add the flag "zip" for controlling if the compressed page of an uncompressed
page should be removed. For now, assume zip==TRUE.
buf_LRU_get_free_block(): Replace the test for UT_LIST_GET_LEN(buf_pool->free)
with a test for the return value of buf_LRU_get_free_only(). Do not
free zip.data, as it must already have been freed.
buf_flush_insert_into_flush_list(), buf_flush_insert_sorted_into_flush_list():
Remove compressed-only blocks from the buf_pool->zip_clean list.
buf_flush_remove(): Restore compressed-only blocks to
the buf_pool->zip_clean list.
buf_page_init_for_read(): Uncompress compressed-only blocks when possible.
Currently, there cannot be any compressed-only blocks in the buffer pool;
they would be inserted by buf_LRU_free_block(bpage, zip=FALSE).
buf_flush_remove(): New function, for removing a block from the flush list.
Sliced from buf_flush_write_complete().
buf_page_set_state(): Allow transitions between BUF_BLOCK_ZIP_PAGE
and BUF_BLOCK_ZIP_DIRTY.
buf_LRU_get_free_block(): Document that the block is in the state
BUF_BLOCK_READY_FOR_USE.
buf_block_alloc(): Change the state of the block to BUF_BLOCK_MEMORY
and document it.
Replace those invocations of buf_block_alloc() with
buf_LRU_get_free_block() where the allocated block is used for buffer
pool input and output. However, temporary copies of B-tree pages
during reorganization are not used for file I/O, and such blocks are
still allocated with buf_block_alloc().