Research: how pkg5 models publication transactions, the trans/ directory and catalog updates after publish #32
Labels
No labels
Compat/Breaking
Crazy Idea
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority/Critical
Priority/High
Priority/Low
Priority/Medium
Reviewed/Confirmed
Reviewed/Duplicate
Reviewed/Invalid
Reviewed/Won't Fix
Status/Abandoned
Status/Blocked
Status/Need More Info
needs-info
needs-triage
ready-for-agent
ready-for-human
wayfinder:grilling
wayfinder:map
wayfinder:prototype
wayfinder:research
wayfinder:task
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Blocks
Reference
OpenIndiana/ips#32
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Part of #24
Question
Summarise, from
doc/pkg5_docs/(guide-publication-protocol.rst,guide-repository-format.rst,catalog-v1.txt,dev-guide/) and the pkg5 sources in the workspace (repos/OpenIndiana/pkg5undersrc/modules/server/transaction.py,src/modules/server/repository.py), how pkg5 handles: transaction lifecycle and on-disk state undertrans/, multi-package publication (doespkgsend publishbatch?), whatclosedoes to the catalog (incremental update log vs rebuild), refresh-index behaviour, and how crashes mid-transaction are recovered. Note which of these behaviours legacy clients observe via the depot API and which are internal.Capture the findings as
docs/research/pkg5-publication-model.mdand link it from this ticket. This feeds the publish transaction model decision.Links
Resolution
pkg5 models publication as one transaction per package version:
openbinds an FMRI, createstrans/<unix-open-time>_<urlquoted fmri>/with a one-linemanifest;addappends action lines and stages gzipped payloads undertrans/<id>/<hash>(only for content not already infile/);closerenames manifest topkg/, renames payloads intofile/, then (unlessX-IPkg-Add-To-Catalog: 0) callsadd_packagewhich rewrites the catalog once under thetmp/lockfile lock and finally rmtree's the dir;abandonis just rmtree. The documented SUBMITTED/INCOMPLETE states were never implemented. Transactions are not journalled or scanned: a crashed one lingers forever intrans/(invisible tostatus/0, nopkgrepocleanup) but can be lazilyreopened by id even after a depot restart. Close is not two-phase: manifest moves before payloads and before the catalog write, so crashes can leave uncatalogued or file-less packages (repair =refresh-packages/rebuild/pkgrepo fix).Catalog: each close does
Catalog.add_packagewith a single op-time, setscatalog.attrs.last-modified, appends to an hourlyupdate.<YYYYMMDDTHH>Z.Clog, and saves via copy-to-tmp + rename swap (leavesold.catalogon crash; never prunes logs).pkgsend publish= one transaction per invocation; batching is only--no-catalog+ oneadmin/0?cmd=refresh-packages(incremental__rebuild, which does emit update logs);rebuilddestroys the catalog, changescreated, and forces every client to a full refetch. Indexing is never on the publish path (refresh-indexis an async background task whose failures are invisible).Legacy pkg(1) only sees the retrieval side:
catalog/1/<file>semantics (createdstable, monotoniclast-modified, per-partlast-modified+signature-sha-1, hourly update-log names listed inattrs.updates, op-time filtering, Last-Modified/If-Modified-Since, Cache-Control) plus manifest/file/publisher/p5i/search/status. Everything else (trans layout, open/add/close/append/abandon, manifest/1 & file/1 POST, X-IPkg-* headers, admin/0, index/0, background queue, lock/tmp files) is internal and free to redesign.Implications for pkg6depotd: preserve the catalog/1 contract exactly; make multi-package transactions native (one op-time, one update-log append, one atomic catalog commit); persist transaction state explicitly with listing/TTL/status exposure; make close validate-then-move (payloads before manifest, idempotent commit marker); keep renames same-filesystem, catalog writes serialised, indexing async but with reported failures. Note "no pkgsend compat" also drops legacy
pkgrecvpush and remotepkgrepo rebuild/refresh; pulling from pkg6depotd is unaffected.Full findings: docs/research/pkg5-publication-model.md on branch
research/pkg5-publication-model(research branch, not merged; cherry-pick the file when the decision it feeds is recorded).