MariaDB / mariadb-docker

Docker Official Image packaging for MariaDB
https://mariadb.org
GNU General Public License v2.0
759 stars 438 forks source link

Could not set the file size of './ibtmp1' #483

Closed Neamar closed 1 year ago

Neamar commented 1 year ago

At some point, I ran out of disk space, which led to a MariaDB 10.5 crash. I cleaned up some files, and tried restarting the container. I got the following error messages:

[Note] InnoDB: Starting a batch to recover 28234 pages from redo log.
[Note] InnoDB: Starting final batch to recover 26336 pages from redo log.
[Note] InnoDB: 128 rollback segments are active.
[Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
[Note] InnoDB: Creating shared tablespace for temporary tables
[Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
[ERROR] InnoDB: preallocating 12582912 bytes for file ./ibtmp1 failed with error 28
[ERROR] InnoDB: Could not set the file size of './ibtmp1'. Probably out of disk space
[ERROR] InnoDB: Unable to create the shared innodb_temporary
[ERROR] InnoDB: Plugin initialization aborted with error Generic error

The error message does say "Probably out of disk space". So I tried to docker exec -it container bash, and from /var/lib/mysql I ran fallocate -l 12M ibtmp1. This worked fine, since I do have disk space.

However, if I do su mysql and then fallocate -l 12M ibtmp1:

root@63716ef698f6:/var/lib/mysql# su mysql
$ fallocate -l 12M test
fallocate: fallocate failed: No space left on device

So... it seems the mysql user is out of space, but not root. Am I missing something? Is there some kind of permission that would prevent mysql from actually writing to this file?

(/var/lib/mysql is mounted as a volume, but I don't know if that's relevant)

tl;dr:

Full logs:

2022-12-30 16:13:34+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.5.9+maria~focal started.
2022-12-30 16:13:34+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2022-12-30 16:13:35+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.5.9+maria~focal started.
2022-12-30 16:13:35 0 [Note] mysqld (mysqld 10.5.9-MariaDB-1:10.5.9+maria~focal) starting as process 1 ...
2022-12-30 16:13:35 0 [Note] InnoDB: Uses event mutexes
2022-12-30 16:13:35 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2022-12-30 16:13:35 0 [Note] InnoDB: Number of pools: 1
2022-12-30 16:13:35 0 [Note] InnoDB: Using generic crc32 instructions
2022-12-30 16:13:35 0 [Note] mysqld: O_TMPFILE is not supported on /tmp (disabling future attempts)
2022-12-30 16:13:35 0 [Note] InnoDB: Using Linux native AIO
2022-12-30 16:13:35 0 [Note] InnoDB: Initializing buffer pool, total size = 134217728, chunk size = 134217728
2022-12-30 16:13:35 0 [Note] InnoDB: Completed initialization of buffer pool
2022-12-30 16:13:35 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2022-12-30 16:13:35 0 [Note] InnoDB: Starting crash recovery from checkpoint LSN=1397891428,1397891428
2022-12-30 16:13:39 0 [Note] InnoDB: Starting a batch to recover 28234 pages from redo log.
2022-12-30 16:13:42 0 [Note] InnoDB: Starting final batch to recover 26336 pages from redo log.
2022-12-30 16:13:45 0 [Note] InnoDB: 128 rollback segments are active.
2022-12-30 16:13:45 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
2022-12-30 16:13:45 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2022-12-30 16:13:45 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2022-12-30 16:13:45 0 [ERROR] InnoDB: preallocating 12582912 bytes for file ./ibtmp1 failed with error 28
2022-12-30 16:13:45 0 [ERROR] InnoDB: Could not set the file size of './ibtmp1'. Probably out of disk space
2022-12-30 16:13:45 0 [ERROR] InnoDB: Unable to create the shared innodb_temporary
2022-12-30 16:13:45 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
221230 16:13:45 [ERROR] mysqld got signal 11 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.

To report this bug, see https://mariadb.com/kb/en/reporting-bugs

We will try our best to scrape up some info that will hopefully help
diagnose the problem, but since we have already crashed, 
something is definitely wrong and this may fail.

Server version: 10.5.9-MariaDB-1:10.5.9+maria~focal
key_buffer_size=134217728
read_buffer_size=131072
max_used_connections=0
max_threads=153
thread_count=0
It is possible that mysqld could use up to 
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 467864 K  bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

Thread pointer: 0x0
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = 0x0 thread_stack 0x49000
mysqld(my_print_stacktrace+0x32)[0x55a25fa03af2]
mysqld(handle_fatal_signal+0x485)[0x55a25f4596f5]
grooverdan commented 1 year ago

Are you using a named volume or a path passed in as a volume?

Even ordinary filesystems have a reserved space which only root can write to. E.g:

$ sudo dumpe2fs  -h /dev/mapper/fedora_localhost--live-home 
dumpe2fs 1.46.5 (30-Dec-2021)
Filesystem volume name:   <none>
Last mounted on:          /home
Filesystem UUID:          a1c0426a-64a8-4252-801b-be0e904e1cdd
Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)
Filesystem features:      has_journal ext_attr resize_inode dir_index filetype needs_recovery extent 64bit flex_bg sparse_super large_file huge_file dir_nlink extra_isize metadata_csum
Filesystem flags:         signed_directory_hash 
Default mount options:    user_xattr acl
Filesystem state:         clean
Errors behavior:          Continue
Filesystem OS type:       Linux
Inode count:              26058752
Block count:              104230912
Reserved block count:     5211545
...

Here the reserved blockcount

Is this the case for the filesystem that gets passed into the container? Is it out of its non-reserved space?

Good news is you can change this reserved space with filesystem tools (tune2fs -r for extX, but others have their own too), especially if its a volume root doesn't write too.

$ sudo tune2fs -r 0 /dev/mapper/fedora_localhost--live-home 
tune2fs 1.46.5 (30-Dec-2021)
Setting reserved blocks count to 0

So there is nothing explicit in the container that controls space. There may be contains from the container runtime.

And from you logs here we'll need to fix the SEGV that occurs when this condition occurs. We should clean-up cleaner than this.

Neamar commented 1 year ago

You're correct, this did fix my issue. I wasn't aware of this mechanism, thanks for the help!

Since you mentioned you want to do some cleanup, I'm not closing -- feel free to close if you'd rather track that somewhere else, but from my point of view this is all sorted out, thanks!

grooverdan commented 1 year ago

Releasing reserved space has saved me so many times in DBA work to just get to a clean state before migrating or getting a bit more uptime. Glad to share that.

I tried to reproduce something on generating this error in a crash recovery and was unable to do so on the latest 10.5. So closing.