Cleanup Policies, Retention, Component Age, Last-Downloaded Rules, Preview, and Storage Reclamation: Diagnostics, Failure Modes, Security, and Performance
Diagnose cleanup incidents with evidence: determine whether the problem is candidate selection, repository scope, timestamp interpretation, task execution, soft deletion, physical reclamation, client cache, or an unsupported manual intervention.
Learning objectives
- Use a repeatable diagnostic sequence before making any destructive correction.
- Distinguish wrong candidate selection from delayed physical reclamation.
- Diagnose broad regex, usage-timestamp, schedule, and task-overlap failures.
- Explain why direct blob/database deletion creates consistency failures.
- Build a post-incident evidence packet that supports safe recovery and future policy changes.
1. Preserve evidence before “fixing” cleanup
Retention failures are unusually easy to make worse because the
intuitive response to storage pressure is more deletion. If a
release vanished, the first response should not be compaction. If
disk space did not fall, the first response should not be
rm. Preserve the policy definition, repository scope,
preview output, task history, version/edition/database/blob-store
information, logs, and client request evidence before changing
anything.
Version baseline (26 August 2026). Sonatype's current 3.95.x release notes list Nexus Repository 3.95.2 (released 21 August 2026) as the newest patch in that line. The 3.95 release expanded cleanup-policy administration and retain-last-N coverage. Current Nexus Repository 3.95.x system requirements use Java 21; official bundles include the recommended runtime. Record the exact version, edition, database, and blob-store type of your lab before applying any cleanup rule because cleanup behavior and available criteria are version- and format-sensitive.
2. Diagnostic sequence
flowchart TB E[Preserve policy + preview + task evidence] --> V[Confirm Nexus version / edition / DB / blob store] V --> R[Confirm repository format / type / policy attachment] R --> C[Re-evaluate criteria and candidate semantics] C --> U[Inspect download / age evidence and known issues] U --> T[Inspect cleanup and unused-blob task status] T --> S[Inspect repository visibility / search / client result] S --> B[Inspect blob capacity and compaction status] B --> L[Inspect logs / task logs / IO metrics] L --> X[Apply smallest supported correction] X --> Q[Verify with controlled requests]
The sequence intentionally defers mutation. The goal is to locate the layer that disagrees with expectation. A 404 after cleanup, a successful build from a client cache, and unchanged filesystem free space can all be simultaneously correct.
3. Symptom-to-layer matrix
| Symptom | Likely layer | Evidence | Do not do |
|---|---|---|---|
| Needed release selected in preview | Criteria/scope | Policy definition, format semantics, repository association | Run cleanup “to confirm” |
| Preview safe, later run deletes more | Time/concurrency or changed policy/repo | timestamps, downloads, publish events, change history | Assume preview is a lock |
| Deleted artifact still builds locally | Client cache | fresh isolated client/cache and HTTP request | Conclude Nexus retained it |
| Artifact absent, disk unchanged | Soft delete / compaction | task history, blob-store capacity, compact task | Delete blob files manually |
| Cleanup task runs very long | DB/IO/task load | task log, DB latency, blob IO, concurrent jobs | Blindly raise heap |
| Active Docker image appears idle | Known version issue | 3.94.0–3.95.2 release notes, request method evidence | Keep Last Downloaded policy enabled |
4. Broken example: an asset matcher escaped its intended subtree
An operator intended to match
learner-example/ci-expire/ but configured:
learner-example/.*expire.*
This can match paths whose names contain “expire” outside the intended directory. The safer H2/PostgreSQL rule includes the leading asset-path slash and anchors the path boundary:
^/learner-example/ci-expire/.*$
Do not repair this by deleting the policy after execution and hoping the content returns. If preview already shows unexpected candidates, stop before cleanup. If cleanup already happened, disable further cleanup/compaction, preserve the task evidence, identify exactly what disappeared, and move into a supported recovery path using soft-delete capability or validated backups as appropriate.
5. Failure mode: a needed release was deleted
Possible causes include a policy attached to the wrong repository, missing release-type protection, an over-broad asset matcher, a short age window, or a false assumption that “last downloaded” reflected business criticality. The recovery priority is to prevent hard deletion from reducing options.
- Disable or detach the offending cleanup policy from the affected disposable/production repository according to change control.
- Do not run compact-blob-store on the affected store.
- Preserve task logs, policy config, preview evidence, and component coordinates/paths.
- Determine whether the blob remains soft-deleted and whether a supported repair/recovery procedure applies to the exact version.
- If recovery requires backup, use a validated restore procedure rather than copying random blob/database files.
- After recovery, rebuild the policy from lifecycle intent and preview again.
Chapter 25 will cover full backup/restore. This lesson's responsibility is to keep the incident recoverable and avoid destructive improvisation.
6. Failure mode: download timestamps are not what the operator assumed
A component can look inactive because consumers use a local cache, because requests hit a different repository endpoint, because a group/proxy path changes which member serves the content, or because the format/version does not update the timestamp for the request method you expected. Diagnose from controlled client requests against a fresh cache and from version-specific documentation.
Docker 3.94.0–3.95.2. Current Sonatype release
notes explicitly state that Docker manifest
HEAD requests fail to update
lastDownloaded. An actively checked image may
therefore satisfy an inactivity rule incorrectly. The published
workaround is to disable affected Last Downloaded cleanup policies
until a fix exists.
7. Failure mode: preview and execution disagree
Preview is a point-in-time evaluation. Between preview and task execution, a component can be downloaded, a new version can be uploaded, a policy can be edited, or repository scope can change. Large-repository previews can also have performance limits. A safe change process records a short preview-to-execution window, freezes policy changes during the change, and re-previews when the candidate set is safety-critical.
If the actual deletion count differs slightly from preview, do not immediately label it corruption. Compare timestamps and repository events. If the difference includes protected releases or a large unexplained expansion, halt compaction and investigate.
8. Failure mode: “cleanup worked, but disk is still full”
This is often a state-model error. Cleanup policies soft delete
content. Unused-asset cleanup handles orphaned assets.
Admin - Compact blob store performs physical deletion
of eligible soft-deleted blobs. Object-storage backends can also
have provider-specific lifecycle behavior. Therefore logical content
disappearance and storage reclamation occur at different times.
Check free-space trend, blob-store status, compact-task configuration, Blobs Older Than grace period, last task execution, and task result. If the grace period is seven days, immediate reclamation is not expected. If compaction is failing, inspect its task log and storage backend health rather than bypassing Nexus.
9. Failure mode: compaction ran at the wrong time
Compaction can create IO load and permanently reduce recovery options. Running it during peak publishing, backup, migration, repository move, or other heavy maintenance can increase contention. Some Nexus tasks explicitly conflict with blob-store operations. A production runbook should list incompatible/high-cost jobs and an approved maintenance window.
Measure before tuning: task duration, blob-store latency, database latency, request error rate, CPU, heap/direct memory, and concurrent task activity. A slow compact task is not evidence that the JVM needs more heap.
10. Catastrophic shortcut: direct filesystem or database deletion
Deleting blob files with shell commands or deleting database rows with SQL destroys the invariant that Nexus maintains between component metadata, asset metadata, blob references, and binary content. The immediate symptom may be missing downloads, 500 errors, reconciliation reports, or search inconsistencies; the long-term symptom can appear during backup, migration, or recovery.
# DO NOT RUN — examples of unsupported cleanup shortcuts
# rm -rf "$NEXUS_DATA/blobs/default/content/vol-*"
# find "$NEXUS_DATA/blobs" -type f -mtime +90 -delete
# psql ... -c 'DELETE FROM asset WHERE ...'
The correct response to storage pressure is supported cleanup/compaction, additional capacity, or a documented migration/storage operation—not deleting internals behind Nexus's back.
11. Security: separate who defines policy, who attaches it, and who runs tasks
Current Sonatype cleanup documentation distinguishes administrative privilege to create policies, repository-admin edit privilege to attach them, and task-update/task-all privilege to modify tasks. That separation is useful: a repository owner may be allowed to apply an approved policy without being able to create arbitrary global cleanup logic or run unrelated administrative tasks.
Audit sensitive changes. Never put administrator passwords in cleanup scripts. The cleanup-policy REST management API is currently Pro-only, so Community automation should not depend on undocumented endpoints or browser automation.
12. Performance diagnosis: identify the bottleneck
| Resource | Evidence | Possible impact |
|---|---|---|
| Database | query latency/connection metrics, task duration | candidate selection and metadata mutation slow |
| Blob IO | storage latency/throughput | compaction and orphan cleanup slow |
| CPU/heap/direct memory | JVM metrics and GC, not guesses | general application pressure |
| Concurrent tasks | task history/schedule | maintenance contention |
| Client traffic | request rate/latency | user-visible slowdown during maintenance |
| Object store | provider latency/lifecycle status | delayed physical deletion |
13. Incident drill
A policy named cleanup-all-old is attached to
maven-releases and maven-snapshots. At
02:00 the cleanup service completes. At 02:10 a rollback deployment
fails because com.example:orders:4.8.2 is missing. The
compact task is scheduled for 03:00.
Your first actions are: stop/detach the policy, disable the pending compaction task for the affected blob store, preserve task and policy evidence, verify the missing coordinate from a fresh client, identify whether the blob is still soft-deleted, and invoke the supported recovery path. You do not republish a newly rebuilt 4.8.2 under the same release identity because that would destroy artifact identity evidence.
14. Verification checklist after correction
- Exact protected coordinate/path is available again or formally declared unrecoverable with evidence.
- Cleanup policy scope and criteria match the documented retention SLA.
- Preview contains only intended candidates.
- Compaction is disabled until recovery/change acceptance is complete.
- Representative clients use a fresh cache and controlled Nexus endpoint.
- No direct DB/blob edits were performed.
- Task schedules avoid known high-contention windows.
- Current release notes were checked for format-specific cleanup issues.
15. Knowledge check
A component is gone from Browse but the blob volume is unchanged. What layer do you inspect next?
Inspect soft-deletion/unused-asset cleanup and the compact-blob-store task. Do not delete files manually.
Why disable compaction after an accidental cleanup?
Compaction permanently removes eligible soft-deleted blobs and can eliminate recovery options that still exist before hard deletion.
What should you use to verify a “deleted artifact still builds” report?
A fresh isolated client/cache plus direct controlled requests to the intended Nexus repository, because an existing local cache may mask repository deletion.
Why is rebuilding and republishing a missing immutable release under the same version dangerous?
The bytes may differ from the originally released artifact, destroying immutable identity and provenance evidence.
What does a broad cleanup regex failure teach?
Candidate selection must be previewed against exact paths, regex boundaries must be explicit, and scope should be as small as practical.
16. Summary and next step
Cleanup diagnosis is a state-localization exercise: criteria, scope, timestamps, task execution, soft deletion, blob reclamation, client cache, and recovery each have different evidence. Lesson 5 combines the chapter into a checkpoint: design a synthetic retention SLA, predict candidates, execute safe cleanup, prove logical versus physical state, and hand off a runbook to Chapter 19's broader scheduled-task operations.
Official references and version notes
- Sonatype: Cleanup Policies — current criteria, preview, system cleanup tasks, soft deletion, compact-blob-store reclamation, and format matrix.
- Sonatype: Nexus Repository 3.95.x Release Notes — 3.95 cleanup enhancements and current known issues.
-
Sonatype: Tasks
— current task types including
Admin - Compact blob store. - Sonatype: Keeping Disk Usage Low — supported cleanup/reclamation guidance and the separation between deletion and freed disk space.
- Sonatype: Data Repair Tasks — current supported consistency/recovery concepts; use only with exact-version procedure and evidence.
Keep the academy open
Support free, practical DevOps education.
Every lesson is designed to remain readable in a browser, downloadable from GitHub, and usable without a paid learning platform. Contributions help expand and maintain the curriculum.
0x716c4Ab160C4B66F31a28AE2448BfF68fc3a2ef0
Send only Ethereum/ERC-20 compatible assets to this
address.