[MDEV-31568] innodb protection against dual processes accessing data insufficient Created: 2023-06-28 Updated: 2023-07-21 Resolved: 2023-07-05 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Storage Engine - InnoDB |
| Affects Version/s: | 10.5.21, 10.6.14 |
| Fix Version/s: | 10.5.22, 10.6.15, 10.9.8, 10.10.6, 10.11.5, 11.0.3, 11.1.2, 11.2.1 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Daniel Black | Assignee: | Marko Mäkelä |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | not-10.4 | ||
| Issue Links: |
|
||||||||||||||||||||||||||||
| Description |
|
steps: 1. start
|
| Comments |
| Comment by Daniel Black [ 2023-07-05 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Its at this point that ibdata1 is opened without a lock allowing second instance to start:
Unsuccessful thought:
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2023-07-05 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
The problem is that after the initial unconditional advisory locking of the system tablespace in SysTablespace::open_file(), SysTablespace::open_or_create() would close the file(s) and therefore release the advisory lock(s). It needs to be redone later down the path when the system tablespace file(s) are being opened for good:
With this patch, it works for me. Tested as follows:
The attempt to start a second server will now properly fail:
On Linux, Error 11 is EAGAIN, or Resource temporarily unavailable. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Daniel Black [ 2023-07-05 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Tested some more as well. Looked at strace of shutdown paths to ensure both innodb and aria stop writing before the locked files are closed and that's true. Did some of the race conditions where process 1 gets the aria lock, process 2 gets the innodb lock, and both fail to start. But it occurs without corruption. |