nextcloud-server/lib/private/DB
Louis Chemineau f9a4e80a72 fix: Initialize lastConnectionCheck after first connection
We are checking whether the DB connection is alive once every 30 seconds. But when we are lacking the last check time, we are skipping the check and reconnect logic. This is causing the reconnect logic to never fire in those cases.

It seems to me that "those cases", are actually always the case, as upon initialization, we are not using the proper connection name to store the time.

In the `connect()` logic, when `$this->_conn` is null, `$this->getConnectionName()` is returning `replica`, so `$this->lastConnectionCheck` will be equal to `['replica' => time()];`

60711ea4cf/lib/private/DB/Connection.php (L215-L221)

60711ea4cf/lib/private/DB/Connection.php (L891-L893)

2b6d7bf65f/doctrine/dbal/src/Connections/PrimaryReadReplicaConnection.php (L136-L139)

Then, if the connection name ends up as being 'primary', the reconnect logic is skipped:

60711ea4cf/lib/private/DB/Connection.php (L874-L880)

Follow-up of https://github.com/nextcloud/server/pull/41819

Signed-off-by: Louis Chemineau <louis@chmn.me>
2025-02-25 11:08:43 +07:00
..
Exceptions
QueryBuilder fix: Remove bogus code from query builder and fix parameter name 2024-04-30 10:47:46 +07:00
Adapter.php fix: Apply new coding standard to all files 2024-04-04 11:45:22 +07:00
AdapterMySQL.php
AdapterOCI8.php
AdapterPgSql.php
AdapterSqlite.php fix: Apply new coding standard to all files 2024-04-04 11:45:22 +07:00
BacktraceDebugStack.php
Connection.php fix: Initialize lastConnectionCheck after first connection 2025-02-25 11:08:43 +07:00
ConnectionAdapter.php feat: add additional logging for database errors 2024-07-25 14:47:27 +07:00
ConnectionFactory.php fix(ConvertType): Read dbtype in createConnectionParams and remove safeguard 2025-01-30 12:21:30 +07:00
DbDataCollector.php fix: Apply new coding standard to all files 2024-04-04 11:45:22 +07:00
MigrationException.php
MigrationService.php fix(migration): Make compatible with PHP 8.0 2024-12-05 12:08:16 +07:00
Migrator.php fix: Run migration sql as statement so that the primary db node is used 2024-09-09 09:39:01 +07:00
MigratorExecuteSqlEvent.php
MissingColumnInformation.php
MissingIndexInformation.php
MissingPrimaryKeyInformation.php
MySqlTools.php
OCSqlitePlatform.php
ObjectParameter.php
OracleConnection.php
OracleMigrator.php
PgSqlTools.php
PreparedStatement.php
ResultAdapter.php
SQLiteMigrator.php
SQLiteSessionInit.php
SchemaWrapper.php
SetTransactionIsolationLevel.php