diff options
author | Varun Gupta <varun.gupta@mariadb.com> | 2020-05-15 02:37:16 +0530 |
---|---|---|
committer | Varun Gupta <varun.gupta@mariadb.com> | 2020-05-17 15:26:18 +0530 |
commit | 0a5668f5128c731a346abf41afdc6fed33164ffc (patch) | |
tree | 061cba1950e7b41397f42590f89d0a220ddafc3e /mysys | |
parent | 66f1e288a12c96b1306e204cca37ffee09e97a64 (diff) | |
download | mariadb-git-0a5668f5128c731a346abf41afdc6fed33164ffc.tar.gz |
MDEV-22556: Incorrect result for window function when using encrypt-tmp-files=ON
The issue here is that end_of_file for encrypted temporary IO_CACHE (used by filesort) is updated
using lseek.
Encryption adds storage overhead and hides it from the caller by recalculating offsets and lengths.
Two different IO_CACHE cannot possibly modify the same file
because the encryption key is randomly generated and stored in the IO_CACHE.
So when the tempfiles are encrypted DO NOT use lseek to change end_of_file.
Further observations about updating end_of_file using lseek
1) The end_of_file update is only used for binlog index files
2) The whole point is to update file length when the file was modified via a different file descriptor.
3) The temporary IO_CACHE files can never be modified via a different file descriptor.
4) For encrypted temporary IO_CACHE, end_of_file should not be updated with lseek
Diffstat (limited to 'mysys')
-rw-r--r-- | mysys/mf_iocache.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/mysys/mf_iocache.c b/mysys/mf_iocache.c index 54b89007b4c..51e8fe1a02f 100644 --- a/mysys/mf_iocache.c +++ b/mysys/mf_iocache.c @@ -504,8 +504,11 @@ my_bool reinit_io_cache(IO_CACHE *info, enum cache_type type, if (info->type == WRITE_CACHE) info->end_of_file= my_b_tell(info); else - info->end_of_file= mysql_file_seek(info->file, 0L, MY_SEEK_END, - MYF(0)); + { + if (!(info->myflags & MY_ENCRYPT)) + info->end_of_file= mysql_file_seek(info->file, 0L, + MY_SEEK_END, MYF(0)); + } } /* flush cache if we want to reuse it */ if (!clear_cache && my_b_flush_io_cache(info,1)) |