[MDEV-26192] Sparse files are being created on thinly provisioned storage Created: 2021-07-20  Updated: 2021-07-21  Resolved: 2021-07-21

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - InnoDB
Affects Version/s: 10.6.3
Fix Version/s: 10.6.4

Type: Bug Priority: Major
Reporter: Marko Mäkelä Assignee: Marko Mäkelä
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-26029 Sparse files are inefficient on thinl... Closed

 Description   

I just noticed that extending page_compressed tables will still create sparse files. The following patch could almost fix it. In the middle hunk for fil_ibd_create(), we have a chicken-and-egg problem that needs to be addressed:

diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc
index c841eb79497..e8d36f24228 100644
--- a/storage/innobase/fil/fil0fil.cc
+++ b/storage/innobase/fil/fil0fil.cc
@@ -577,7 +577,7 @@ fil_space_extend_must_retry(
 		os_offset_t(FIL_IBD_FILE_INITIAL_SIZE << srv_page_size_shift));
 
 	*success = os_file_set_size(node->name, node->handle, new_size,
-				    space->is_compressed());
+				    node->punch_hole == 1);
 
 	os_has_said_disk_full = *success;
 	if (*success) {
@@ -2034,7 +2034,9 @@ fil_ibd_create(
 
 	if (!os_file_set_size(
 		path, file,
-		os_offset_t(size) << srv_page_size_shift, is_compressed)) {
+		os_offset_t(size) << srv_page_size_shift,
+		is_compressed /* FIXME: punch_hole==1 is set only after
+			      node->find_metadata() below */)) {
 		*err = DB_OUT_OF_FILE_SPACE;
 err_exit:
 		os_file_close(file);
diff --git a/storage/innobase/log/log0recv.cc b/storage/innobase/log/log0recv.cc
index 16250928845..0f016ba5f98 100644
--- a/storage/innobase/log/log0recv.cc
+++ b/storage/innobase/log/log0recv.cc
@@ -841,7 +841,7 @@ bool recv_sys_t::recover_deferred(recv_sys_t::map::iterator &p,
         goto fail;
       if (!os_file_set_size(node->name, node->handle,
                             size * fil_space_t::physical_size(flags),
-                            space->is_compressed()))
+                            node->punch_hole == 1))
       {
         space->release();
         goto fail;


Generated at Thu Feb 08 09:43:26 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.