Commit 9f42bb4
committed
[BUGFIX] Mitigate query buffer issue in
Using `pdo_mysql` driver with `MySQL` and `MariaDB` databases
requires that buffered result sets are fully read or explicitly
free'd. That means, that queries returning a result set needs
to consume the full result set by reading all rows and not only
one record and leaving the rest in the buffer.
TYPO3 mitigates this in several places for select queries by
explicitly enforcing `setMaxResults(1)` when reading only one
record and it could be a duplicates, which is not an ideal or
reading the full result set.
The DDL `OPTIMIZE TABLE` for `MariaDB` and `MySQL` databases
returns a result stating the outcome of the operation and is
a buffered query, which requires to use `executeQuery()` and
not `executeStatement()` on the connection and fully consume
the result when using `pdo_mysql`. However, the `mysqli`
driver is more forgiving here.
This change now uses `executeQuery()` in the scheduler task
`OptimizeDatabaseTableTask` to retrieve the result without
using it to ensure buffer is consumed and works with both
possible drivers for the aforementioned database vendors.
As a first guard, one functional test execution is changed
to use `pdo_mysql` and is scheduled to rework the matrix
in a dedicated change to cover differences with both drivers
for `MySQL` and `MariaDB`.
Can be verified executing the single test case, working with
`mysqli` and failing with `pdo_mysql` (without this change):
> Build/Scripts/runTests.sh -s functional -d mariadb -a mysqli -- \
--filter 'OptimizeDatabaseTableTaskTest'
> Build/Scripts/runTests.sh -s functional -d mariadb -a pdo_mysql -- \
--filter 'OptimizeDatabaseTableTaskTest'
> Build/Scripts/runTests.sh -s functional -d mysql -a mysqli -- \
--filter 'OptimizeDatabaseTableTaskTest'
> Build/Scripts/runTests.sh -s functional -d mysql -a pdo_mysql -- \
--filter 'OptimizeDatabaseTableTaskTest'
Added tests are executed against all databases albeit the task
silently does nothing for other database systems than `MariaDB`
or `MySQL` to ensure that the platform detection stays in place.
TYPO3 v12 used the `Connection::query()` method using
`executeQuery()` internally, which means that it has
been replaced with the wrong method while upgrading to
Doctrine DBAL 4 with #102875 in TYPO3 v13.
Resolves: #106563
Related: #102875
Releases: main, 13.4
Change-Id: Ie8cc10d917ea7695da826bb7f8ec5dfeba2c89bf
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/89082
Reviewed-by: Garvin Hicking <gh@faktor-e.de>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Garvin Hicking <gh@faktor-e.de>
Tested-by: Stefan Bürk <stefan@buerk.tech>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Benni Mack <benni@typo3.org>OptimizeDatabaseTableTask
1 parent 859c291 commit 9f42bb4
File tree
3 files changed
+63
-3
lines changed- Build/gitlab-ci/pre-merge
- typo3/sysext/scheduler
- Classes/Task
- Tests/Functional/Task
3 files changed
+63
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
Lines changed: 5 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
57 | 61 | | |
58 | 62 | | |
59 | 63 | | |
| |||
Lines changed: 56 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
0 commit comments