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 Migrate missing column database check to new API 2023-11-27 15:23:52 +07:00
MissingIndexInformation.php Migrate missing index database check to new API 2023-11-27 15:23:52 +07:00
MissingPrimaryKeyInformation.php Migrate missing primary key database check to new API 2023-11-27 15:23:52 +07:00
MySqlTools.php
OCSqlitePlatform.php
ObjectParameter.php
OracleConnection.php
OracleMigrator.php fix(oracle): Move away from internal and deprecated SchemaDiff API 2023-10-06 15:29:26 +07:00
PgSqlTools.php
PreparedStatement.php
ResultAdapter.php
SQLiteMigrator.php fix(sqlite): Remove some old SQLite cheats 2023-10-06 15:29:27 +07:00
SQLiteSessionInit.php
SchemaWrapper.php
SetTransactionIsolationLevel.php enh: Implement PrimaryReadReplicaConnection 2023-12-16 20:27:37 +07:00