mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
refactor: remove the logs database plumbing
#13630 emptied the logs collection set but kept the database and the `getLogsDB` plumbing around it. Nothing in this repo reads that database: `Deletes` takes `callable $getLogsDB` and never dereferences it, and the collection set it was created from is empty. Remove the resource from all four containers (request, worker message, CLI and the shared `resources.php`), `Factory::logs()`, the `logs` pool and `_APP_CONNECTIONS_DB_LOGS`, the empty collection set, and the boot-time `createDatabase()` call in `http.php`. The logs set was also merged into the collection lookup in `Queries\Base`; dropping the key there too. Boot no longer pings and creates a second database before the platform one. `_APP_CONNECTIONS_DB_LOGS` was never in `.env`, `docker-compose.yml` or `app/config/variables.php`, so self-hosted installs left it unset and the pool fell back to the main `_APP_DB_HOST`. What they are left with is an empty `logsV1__metadata` table in the `appwrite` schema, which nothing reads; no migration is warranted for it.
This commit is contained in:
1 parent
3958968f2b
commit
a77d9da6db
11 files changed
+1
-137
No files matched your search
-36
@@ -21,7 +21,6 @@ use Utopia\Database\Database;
|
||||
use Utopia\Database\Document;
|
||||
use Utopia\Database\Validator\Authorization;
|
||||
use Utopia\Platform\Service;
|
||||
use Utopia\Pools\Group;
|
||||
use Utopia\Registry\Registry;
|
||||
use Utopia\Span\Span;
|
||||
|
||||
@@ -139,41 +138,6 @@ $container->set('getProjectDB', function (DatabaseFactory $databaseFactory, Data
|
||||
};
|
||||
}, ['databaseFactory', 'dbForPlatform']);
|
||||
|
||||
$container->set('getLogsDB', function (Group $pools, Cache $cache, Authorization $authorization) {
|
||||
$database = null;
|
||||
|
||||
return function (?Document $project = null) use ($pools, $cache, &$database, $authorization) {
|
||||
if ($database !== null && $project !== null && !$project->isEmpty() && $project->getId() !== 'console') {
|
||||
$database->setTenant($project->getSequence());
|
||||
return $database;
|
||||
}
|
||||
|
||||
/** @var array $collections */
|
||||
$collections = Config::getParam('collections', []);
|
||||
$logsCollections = $collections['logs'] ?? [];
|
||||
$logsCollections = array_keys($logsCollections);
|
||||
|
||||
$adapter = new DatabasePool($pools->get('logs'));
|
||||
$database = new Database($adapter, $cache);
|
||||
|
||||
$database
|
||||
->setDatabase(APP_DATABASE)
|
||||
->setAuthorization($authorization)
|
||||
->setSharedTables(true)
|
||||
->setNamespace('logsV1')
|
||||
->setGlobalCollections($logsCollections)
|
||||
->setTimeout(APP_DATABASE_TIMEOUT_MILLISECONDS_TASK)
|
||||
->setMaxQueryValues(APP_DATABASE_QUERY_MAX_VALUES);
|
||||
|
||||
// set tenant
|
||||
if ($project !== null && !$project->isEmpty() && $project->getId() !== 'console') {
|
||||
$database->setTenant($project->getSequence());
|
||||
}
|
||||
|
||||
return $database;
|
||||
};
|
||||
}, ['pools', 'cache', 'authorization']);
|
||||
|
||||
$container->set('usage', function () {
|
||||
return new UsageContext();
|
||||
}, []);
|
||||
|
||||
@@ -6,7 +6,6 @@ $projects = include __DIR__ . '/collections/projects.php';
|
||||
$databases = include __DIR__ . '/collections/databases.php';
|
||||
$vectorsdb = include __DIR__ . '/collections/vectorsdb.php';
|
||||
$platform = include __DIR__ . '/collections/platform.php';
|
||||
$logs = include __DIR__ . '/collections/logs.php';
|
||||
|
||||
// see - http.php#245
|
||||
// $collections['buckets']['files'];
|
||||
@@ -30,7 +29,6 @@ $collections = [
|
||||
'vectorsdb' => $vectorsdb,
|
||||
'projects' => array_merge_recursive($projects, $common),
|
||||
'console' => array_merge_recursive($platform, $common),
|
||||
'logs' => $logs,
|
||||
];
|
||||
|
||||
return $collections;
|
||||
@@ -1,5 +0,0 @@
|
||||
<?php
|
||||
|
||||
// Empty by design: the logs database is still created, and other editions merge
|
||||
// their own collections into this set.
|
||||
return [];
|
||||
@@ -194,9 +194,6 @@ $http->on(Constant::EVENT_START, function ($http) use ($payloadSize, $totalWorke
|
||||
/** @var array $collections */
|
||||
$collections = Config::getParam('collections', []);
|
||||
|
||||
// create logs database first, `getLogsDB` is a callable.
|
||||
createDatabase($container, 'getLogsDB', 'logs', $collections['logs'], $pools);
|
||||
|
||||
// create appwrite database, `dbForPlatform` is a direct access call.
|
||||
createDatabase($container, 'dbForPlatform', 'appwrite', $collections['console'], $pools, function (Database $dbForPlatform) use ($collections, $container) {
|
||||
$authorization = $container->get('authorization');
|
||||
|
||||
@@ -98,12 +98,6 @@ $register->set('pools', function () {
|
||||
'multiple' => true,
|
||||
'schemes' => ['postgresql'],
|
||||
],
|
||||
'logs' => [
|
||||
'type' => 'database',
|
||||
'dsns' => System::getEnv('_APP_CONNECTIONS_DB_LOGS', $fallbackForDB),
|
||||
'multiple' => false,
|
||||
'schemes' => ['mongodb','mariadb', 'mysql','postgresql'],
|
||||
],
|
||||
'publisher' => [
|
||||
'type' => 'publisher',
|
||||
'dsns' => $fallbackForRedis,
|
||||
|
||||
@@ -268,25 +268,6 @@ $container->set('dbForPlatform', fn (DatabaseFactory $databaseFactory) => $datab
|
||||
['host' => \gethostname(), 'project' => 'console']
|
||||
), ['databaseFactory']);
|
||||
|
||||
$container->set('getLogsDB', function (DatabaseFactory $databaseFactory) {
|
||||
$database = null;
|
||||
|
||||
return function (?Document $project = null) use ($databaseFactory, &$database) {
|
||||
if ($database !== null && $project !== null && !$project->isEmpty() && $project->getId() !== 'console') {
|
||||
$database->setTenant($project->getSequence());
|
||||
return $database;
|
||||
}
|
||||
|
||||
$database = $databaseFactory->logs(
|
||||
$project,
|
||||
APP_DATABASE_TIMEOUT_MILLISECONDS_API,
|
||||
APP_DATABASE_QUERY_MAX_VALUES
|
||||
);
|
||||
|
||||
return $database;
|
||||
};
|
||||
}, ['databaseFactory']);
|
||||
|
||||
$container->set('cache', function (Group $pools, Telemetry $telemetry) {
|
||||
$list = Config::getParam('pools-cache', []);
|
||||
$adapters = [];
|
||||
|
||||
@@ -244,17 +244,6 @@ return function (Container $context): void {
|
||||
};
|
||||
}, ['databaseFactory', 'dbForPlatform']);
|
||||
|
||||
$context->set('getLogsDB', function (DatabaseFactory $databaseFactory) {
|
||||
|
||||
return function (?Document $project = null) use ($databaseFactory) {
|
||||
return $databaseFactory->logs(
|
||||
$project,
|
||||
APP_DATABASE_TIMEOUT_MILLISECONDS_API,
|
||||
APP_DATABASE_QUERY_MAX_VALUES
|
||||
);
|
||||
};
|
||||
}, ['databaseFactory']);
|
||||
|
||||
/**
|
||||
* List of allowed request hostnames for the request.
|
||||
*/
|
||||
|
||||
@@ -109,26 +109,6 @@ return function (Container $container): void {
|
||||
};
|
||||
}, ['databaseFactory', 'project']);
|
||||
|
||||
$container->set('getLogsDB', function (DatabaseFactory $databaseFactory) {
|
||||
$database = null;
|
||||
|
||||
return function (?Document $project = null) use ($databaseFactory, &$database) {
|
||||
if ($database !== null && $project !== null && !$project->isEmpty() && $project->getId() !== 'console') {
|
||||
$database->setTenant($project->getSequence());
|
||||
|
||||
return $database;
|
||||
}
|
||||
|
||||
$database = $databaseFactory->logs(
|
||||
$project,
|
||||
APP_DATABASE_TIMEOUT_MILLISECONDS_WORKER,
|
||||
APP_DATABASE_QUERY_MAX_VALUES_WORKER
|
||||
);
|
||||
|
||||
return $database;
|
||||
};
|
||||
}, ['databaseFactory']);
|
||||
|
||||
$container->set('abuseRetention', function () {
|
||||
return \time() - (int) System::getEnv('_APP_MAINTENANCE_RETENTION_ABUSE', 86400); // 1 day
|
||||
}, []);
|
||||
|
||||
@@ -67,35 +67,6 @@ class Factory
|
||||
return $this->configureProject($database, $project, $dsn);
|
||||
}
|
||||
|
||||
public function logs(
|
||||
?Document $project = null,
|
||||
int $timeout = 0,
|
||||
int $maxQueryValues = 0,
|
||||
array $metadata = [],
|
||||
): Database {
|
||||
/** @var array $collections */
|
||||
$collections = Config::getParam('collections', []);
|
||||
$logsCollections = \array_keys($collections['logs'] ?? []);
|
||||
|
||||
$database = $this->newDatabase($this->adapter('logs'));
|
||||
|
||||
$database
|
||||
->setDatabase($this->database)
|
||||
->setAuthorization($this->authorization)
|
||||
->setDropUnknownAttributes(true)
|
||||
->setSharedTables(true)
|
||||
->setGlobalCollections($logsCollections)
|
||||
->setNamespace('logsV1');
|
||||
|
||||
if ($project !== null && !$project->isEmpty() && $project->getId() !== 'console') {
|
||||
$database->setTenant($project->getSequence());
|
||||
}
|
||||
|
||||
$this->configureOptions($database, $timeout, $maxQueryValues, $metadata);
|
||||
|
||||
return $database;
|
||||
}
|
||||
|
||||
/**
|
||||
* Databases and tables the caller owns. Unknown attributes stay a rejected write here:
|
||||
* the schema is theirs, so dropping one would silently discard data they sent.
|
||||
|
||||
@@ -63,7 +63,6 @@ class Deletes extends Action
|
||||
->inject('dbForPlatform')
|
||||
->inject('getProjectDB')
|
||||
->inject('getDatabasesDB')
|
||||
->inject('getLogsDB')
|
||||
->inject('deviceForFiles')
|
||||
->inject('deviceForFunctions')
|
||||
->inject('deviceForSites')
|
||||
@@ -94,7 +93,6 @@ class Deletes extends Action
|
||||
Database $dbForPlatform,
|
||||
callable $getProjectDB,
|
||||
callable $getDatabasesDB,
|
||||
callable $getLogsDB,
|
||||
Device $deviceForFiles,
|
||||
Device $deviceForFunctions,
|
||||
Device $deviceForSites,
|
||||
@@ -128,7 +126,6 @@ class Deletes extends Action
|
||||
$dbForPlatform,
|
||||
$getProjectDB,
|
||||
$getDatabasesDB,
|
||||
$getLogsDB,
|
||||
$deviceForFiles,
|
||||
$deviceForFunctions,
|
||||
$deviceForSites,
|
||||
@@ -222,7 +219,6 @@ class Deletes extends Action
|
||||
Database $dbForPlatform,
|
||||
callable $getProjectDB,
|
||||
callable $getDatabasesDB,
|
||||
callable $getLogsDB,
|
||||
Device $deviceForFiles,
|
||||
Device $deviceForFunctions,
|
||||
Device $deviceForSites,
|
||||
|
||||
@@ -30,8 +30,7 @@ class Base extends Queries
|
||||
$config['projects'],
|
||||
$config['buckets'],
|
||||
$config['databases'],
|
||||
$config['console'],
|
||||
$config['logs']
|
||||
$config['console']
|
||||
);
|
||||
|
||||
$collection = $collections[$collection];
|
||||
|
||||
Reference in new issue
Block a user