mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-03 20:22:46 +01:00
9c798e5cca
Summary: Fixes T9494. This: - Removes all the random GC.x.y.z config. - Puts it all in one place that's locked and which you use `bin/garbage set-policy ...` to adjust. - Makes every TTL-based GC configurable. - Simplifies the code in the actual GCs. Test Plan: - Ran `bin/garbage collect` to collect some garbage, until it stopped collecting. - Ran `bin/garbage set-policy ...` to shorten policy. Saw change in web UI. Ran `bin/garbage collect` again and saw it collect more garbage. - Set policy to indefinite and saw it not collect garabge. - Set policy to default and saw it reflected in web UI / `collect`. - Ran `bin/phd debug trigger` and saw all GCs fire with reasonable looking queries. - Read new docs. {F857928} Reviewers: chad Reviewed By: chad Maniphest Tasks: T9494 Differential Revision: https://secure.phabricator.com/D14219
29 lines
636 B
PHP
29 lines
636 B
PHP
<?php
|
|
|
|
final class DrydockLogGarbageCollector
|
|
extends PhabricatorGarbageCollector {
|
|
|
|
const COLLECTORCONST = 'drydock.logs';
|
|
|
|
public function getCollectorName() {
|
|
return pht('Drydock Logs');
|
|
}
|
|
|
|
public function getDefaultRetentionPolicy() {
|
|
return phutil_units('30 days in seconds');
|
|
}
|
|
|
|
protected function collectGarbage() {
|
|
$log_table = new DrydockLog();
|
|
$conn_w = $log_table->establishConnection('w');
|
|
|
|
queryfx(
|
|
$conn_w,
|
|
'DELETE FROM %T WHERE epoch <= %d LIMIT 100',
|
|
$log_table->getTableName(),
|
|
$this->getGarbageEpoch());
|
|
|
|
return ($conn_w->getAffectedRows() == 100);
|
|
}
|
|
|
|
}
|