A site archived on the farm outside the console is never purged, and one archived twice can be purged at once #246

Closed
opened 2026-10-22 06:46:29 +00:00 by cgalo5758 · 1 comment
Owner

What happens

The sync copies a farm-side status onto the site row (UpsertSiteFromFarm) without touching archived_at; only the console's own status write (SetSiteStatusByDomain) sets or clears it. The retention purge takes archived rows whose archived_at is set and older than 30 days. So a site archived on the farm outside the console keeps its content and its name forever, while the member's Archived section says archived sites are removed automatically after 30 days.

In reverse, a site archived in the console and restored on the farm keeps its first archived_at. If the farm archives it again later, the purge at the end of that same sync run can delete it permanently at once.

What should happen

Any write that moves a row into archived stamps archived_at, and any write that moves it out clears it, so the 30 days start when the console first sees the archive.

Where

internal/integrations/fedwiki/store/queries/sites.sql (UpsertSiteFromFarm, ListArchivedSitesArchivedBefore), internal/integrations/fedwiki/workflows/sync.go, internal/integrations/fedwiki/workflows/reconcile.go (PurgeExpiredArchivedActivity)

Steps

Enable the sync, archive a site through the farm manager API, wait one tick, and read the row's archived_at.

Why it matters

Members are told archived sites go after 30 days, and the reverse case erases a site with no window at all.

### What happens The sync copies a farm-side status onto the site row (`UpsertSiteFromFarm`) without touching `archived_at`; only the console's own status write (`SetSiteStatusByDomain`) sets or clears it. The retention purge takes archived rows whose `archived_at` is set and older than 30 days. So a site archived on the farm outside the console keeps its content and its name forever, while the member's Archived section says archived sites are removed automatically after 30 days. In reverse, a site archived in the console and restored on the farm keeps its first `archived_at`. If the farm archives it again later, the purge at the end of that same sync run can delete it permanently at once. ### What should happen Any write that moves a row into `archived` stamps `archived_at`, and any write that moves it out clears it, so the 30 days start when the console first sees the archive. ### Where `internal/integrations/fedwiki/store/queries/sites.sql` (`UpsertSiteFromFarm`, `ListArchivedSitesArchivedBefore`), `internal/integrations/fedwiki/workflows/sync.go`, `internal/integrations/fedwiki/workflows/reconcile.go` (`PurgeExpiredArchivedActivity`) ### Steps Enable the sync, archive a site through the farm manager API, wait one tick, and read the row's `archived_at`. ### Why it matters Members are told archived sites go after 30 days, and the reverse case erases a site with no window at all.
cgalo5758 added this to the Public launch milestone 2026-10-22 06:46:29 +00:00
cgalo5758 added the
kind
bug
area/fedwiki
labels 2026-10-22 06:46:29 +00:00
Author
Owner

Fixed in d87cb15a.

The database now sets archived_at itself. A trigger on fedwiki.sites runs on every insert and update: a site whose new status is not archived gets no archive time, a site that enters archived (or is inserted archived) gets the time of that write, and a site that stays archived keeps its time. A time the query supplies is ignored, so the sync, the console's own status writes and any writer added later all follow the same rule, and no query sets the column any more.

Both cases in this issue now behave as described under "What should happen":

  • A site archived on the farm gets its time when the sync first records it as archived, so the 30 days start then and the retention purge removes it after them.
  • A site restored on the farm loses its archive time when the sync records the restore; archived again, it starts a fresh 30 days.

What this does not cover: if the farm restores and re-archives a site between two sync runs, the console never sees the restore, so the site keeps its first archive time.

Existing rows are not rewritten by the migration; each is corrected on its next write, which with the sync enabled is the next sync run. A deployment that wants to check its archived sites should count them and fix any suspect time before upgrading; after the upgrade, a hand correction has to move the row out of archived and back in one transaction, since the trigger ignores a time written directly.

Fixed in d87cb15a. The database now sets `archived_at` itself. A trigger on `fedwiki.sites` runs on every insert and update: a site whose new status is not `archived` gets no archive time, a site that enters `archived` (or is inserted archived) gets the time of that write, and a site that stays archived keeps its time. A time the query supplies is ignored, so the sync, the console's own status writes and any writer added later all follow the same rule, and no query sets the column any more. Both cases in this issue now behave as described under "What should happen": - A site archived on the farm gets its time when the sync first records it as archived, so the 30 days start then and the retention purge removes it after them. - A site restored on the farm loses its archive time when the sync records the restore; archived again, it starts a fresh 30 days. What this does not cover: if the farm restores and re-archives a site between two sync runs, the console never sees the restore, so the site keeps its first archive time. Existing rows are not rewritten by the migration; each is corrected on its next write, which with the sync enabled is the next sync run. A deployment that wants to check its archived sites should count them and fix any suspect time before upgrading; after the upgrade, a hand correction has to move the row out of `archived` and back in one transaction, since the trigger ignores a time written directly.
Sign in to join this conversation.
No labels area/fedwiki
kind
bug
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: wiki-cafe/member-console#246