mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-22 03:50:30 +00:00
fix(storage): reset reclaim state after any restore, re-check owners often, share release ticks
- A restore (admin panel or RESTORE_FROM_BACKUP) now leaves data/.trek-reclaim-reset before it swaps the database in. Boot reconcile resets the reclaim state when it finds the file, whatever install id the database names, and removes it afterwards; a successful reopen removes it too. A restart after a failed reopen, or a boot restore of this installation's own backup, no longer keeps the old switch, marks and confirmations. The id mismatch reset stays. - The release job skips a tick (install_mismatch) while the database names another installation or a reset is still pending. - An allowed owner verdict is cached for 15 minutes, a refusal for 26 hours. The local driver reads a list prefix as a folder, so the category root is still listed whole, at most once per category per window. - Each tick reads every allowed category's due rows separately, an equal share of the 200 each, so a category whose deletes keep failing cannot starve the others. - Rows dropped after 30 days overdue and releases refused by a full queue are logged at warn with their counts.
This commit is contained in:
@@ -14,9 +14,9 @@ export interface ReleaseQueueRow {
|
||||
/**
|
||||
* `storage_release_queue`: the objects a delete or a replace left unnamed,
|
||||
* keyed by category and category-relative key, each with the time it may go.
|
||||
* Owners only add rows; the release job reads the due ones of the categories
|
||||
* it may judge, asks every reference source again and drops each row once it
|
||||
* has decided, deleted or not. A key queued again waits from the later time.
|
||||
* Owners only add rows; the release job reads the due ones of each category
|
||||
* it may judge (a share of its tick each), asks every reference source again
|
||||
* and drops each row once it has decided, deleted or not. A key queued again waits from the later time.
|
||||
*/
|
||||
export class StorageReleaseQueueRepository extends TrekRepository<StorageReleaseQueue> {
|
||||
private db() {
|
||||
@@ -49,15 +49,16 @@ export class StorageReleaseQueueRepository extends TrekRepository<StorageRelease
|
||||
return rows.map((row) => row.category);
|
||||
}
|
||||
|
||||
/** The rows of these categories due at `now`, the longest waiting first, at most `limit`. */
|
||||
async dueIn(categories: string[], now: string, limit: number): Promise<ReleaseQueueRow[]> {
|
||||
if (categories.length === 0 || limit <= 0) return [];
|
||||
/** The rows of one category due at `now`, the longest waiting first, at most `limit`. */
|
||||
async dueIn(category: string, now: string, limit: number): Promise<ReleaseQueueRow[]> {
|
||||
if (limit <= 0) return [];
|
||||
return await this.db()
|
||||
.selectFrom('storage_release_queue')
|
||||
.select(['category', 'key', 'due_at'])
|
||||
.where('category', 'in', categories)
|
||||
.where('category', '=', category)
|
||||
.where('due_at', '<=', now)
|
||||
.orderBy('due_at')
|
||||
.orderBy('key')
|
||||
.limit(limit)
|
||||
.execute();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user