Skip to content

[stable29] fix(Database): Use real idle-timer to prevent lastInsertId being reset on MariaDB/MySQL - #62709

Open
backportbot[bot] wants to merge 1 commit into
stable29from
backport/62697/stable29
Open

[stable29] fix(Database): Use real idle-timer to prevent lastInsertId being reset on MariaDB/MySQL#62709
backportbot[bot] wants to merge 1 commit into
stable29from
backport/62697/stable29

Conversation

@backportbot

@backportbot backportbot Bot commented Jul 30, 2026

Copy link
Copy Markdown

Backport of #62697

Warning, This backport's changes differ from the original and might be incomplete ⚠️

Todo

  • Review and resolve any conflicts
  • Review and verify the backported changes
  • Amend HEAD commit to remove the line stating to skip CI

Learn more about backports at https://docs.nextcloud.com/server/stable/go.php?to=developer-backports.

@backportbot backportbot Bot added bug 3. to review Waiting for reviews tests Related to tests CI feature: database Database related DB AI assisted labels Jul 30, 2026
@DerDreschner
DerDreschner force-pushed the backport/62697/stable29 branch from 116c49e to 4178e56 Compare August 9, 2026 21:51
@DerDreschner
DerDreschner marked this pull request as ready for review August 9, 2026 21:52
Comment thread lib/private/DB/Connection.php Fixed
…set on MariaDB/MySQL

The previous implementation of the idle timer runs on a strict 30 second interval and sends a dummy `SELECT` statement to keep the connection open.

This generates issues with the `lastInsertId` on long-running tasks (like our CI pipeline), as the MariaDB documentation clearly states:

> If the last query wasn't an INSERT or UPDATE statement or if the modified table does not have a column with the AUTO_INCREMENT attribute and LAST_INSERT_ID was not used, this function will return zero.

Source: https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_insert_id

To mitigate that, this commit now uses a real idle-timer per connection instead.

Assisted-by: ClaudeCode:claude-fable-5
Signed-off-by: David Dreschner <david.dreschner@nextcloud.com>
@DerDreschner
DerDreschner force-pushed the backport/62697/stable29 branch from 4178e56 to c47a6e1 Compare August 9, 2026 22:04
$this->tablePrefix = $params['tablePrefix'];
// the DBAL 3.8 params are a sealed array shape that predates this key, so it is
// reached through isset() like the ones above instead of a null coalesce
if (isset($params['activity_notifier']) && $params['activity_notifier'] instanceof ConnectionActivityNotifier) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews AI assisted bug CI feature: database Database related DB tests Related to tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants