<!-- llms-explorer concept facts · https://llms-explorer.com/tree/time-series-compact-and-disk-space-reclaim/ · pack 2026-10-31 · ~1774 tokens -->

# Time series compact and disk space reclaim

> Source-anchored research for Time series compact and disk space reclaim. Run status: COMPLETED.

Parent: [Bucket fragmentation remediation (re-insert/merge)](https://llms-explorer.com/tree/bucket-fragmentation-remediation-re-insert-merge/) · 6 facets · 17 facts · page: https://llms-explorer.com/tree/time-series-compact-and-disk-space-reclaim/

## Structure and components

- Inference from the documented storage layers: compact addresses physical file-block fragmentation, not logical consolidation of measurements from separate time-series bucket documents. Time-series buckets group measurements in documents, whereas WiredTiger compaction relocates pages and blocks. Do not promise fewer bucket documents or denser measurement packing from compact alone. (medium confidence) — [source](https://github.com/mongodb/mongo/blob/master/src/mongo/db/timeseries/README.md)

## How it works

- compact may need additional disk space, so do not assume it can safely finish on an already full volume. Its checkpoint activity and storage work can also disrupt performance even when CRUD is permitted; assess available capacity and workload impact before running it. (high confidence) — [source](https://www.mongodb.com/docs/manual/reference/command/compact/)

## Measurements and reference values

- A May 2023 operator on MongoDB 4.4.5 reported compact returning bytesFreed:0 despite roughly 30 GB freeStorageSize, while resync reclaimed space. The thread does not establish a general root cause or guarantee that repeatedly rerunning compact will help. (low confidence) — [source](https://www.mongodb.com/community/forums/t/compact-doesnt-free-space/224858)

## Problems, failure modes and limitations

- The October 2022 time-series failure produced 'can't compact a view'; SERVER-70679 additionally reproduced 'can't compact a system namespace' for system.buckets.ts. The issue lists affected version 6.0.2 and fix version 6.3.0-rc0, so the forum's workaround advice is historical. (high confidence) — [source](https://jira.mongodb.org/browse/SERVER-70679)
- A December 2024 MongoDB 6.0.19 operator reported repeated EBUSY compaction retries, zero rewritten pages in sampled logs, and little reclamation after 24 hours. This is an observed failure mode, not a proven diagnosis or a time-series-specific incident. (low confidence) — [source](https://www.mongodb.com/community/forums/t/compacting-a-topic-repeated-log-lines-with-compaction-failed-with-ebusy/306468)
- MongoDB added compact support for time-series collections in 6.3. SERVER-70679 records the original failure on 6.0.2 and lists 6.3.0-rc0 as its fix version. Treat advice that time-series collections cannot be compacted as version-specific historical guidance. (high confidence) — [source](https://www.mongodb.com/docs/v7.0/release-notes/7.0/)
- Inference for maintenance planning: nonblocking CRUD does not mean zero operational impact. MongoDB warns that compaction can slow checkpoints, increase transaction commit time, and cause read latency or replication lag; Alibaba recommends off-peak execution, whereas Percona's older PSMDB 6.0 walkthrough says compaction can be planned at any time. (high confidence) — [source](https://www.mongodb.com/docs/manual/reference/command/compact/)

## Comparisons and alternatives

- Deleting documents or expiring them through TTL can leave allocated space available for subsequent writes rather than returning it to the operating system. Compact is useful when the collection will not reuse that space. (high confidence) — [source](https://www.alibabacloud.com/help/en/mongodb/use-cases/defragment-a-disk-to-improve-disk-usage)
- Compact is best effort: reusable-space totals do not guarantee equivalent filesystem reclamation because free blocks' locations matter. Verify before/after storage statistics and filesystem usage instead of treating command success as proof of reclaimed bytes. (high confidence) — [source](https://www.mongodb.com/docs/manual/reference/command/compact/)
- SERVER-81041 records a later time-series compact locking bug: compact locked the view namespace instead of system.buckets. The issue lists fix versions 7.0.3 and 7.2.0-rc0, and affected versions 7.0.1, 7.1.0-rc2 and 7.2.0-rc0. (low confidence) (verified as of 2026-09-21) — [source](https://jira.mongodb.org/browse/SERVER-81041)
- compact is local maintenance: the primary does not replicate the command to secondaries. Run it separately on the intended replica-set members, preferably secondaries, and on shard mongod nodes rather than mongos. Verify each member independently. (high confidence) — [source](https://www.mongodb.com/docs/manual/reference/command/compact/)
- Compaction can consume additional disk space and system resources. Reserve headroom and schedule around workload impact; Alibaba recommends off-peak operation, rather than assuming an operation that permits CRUD has no operational cost. (high confidence) — [source](https://www.mongodb.com/docs/manual/reference/command/compact/)
- A no-effect compact result can reflect file layout or reclamation thresholds rather than command failure. WiredTiger documents eligibility checks and repeated internal passes, while MongoDB states that effectiveness depends on available blocks and their positions. Repeating the command is not a guarantee that all free storage will become operating-system free space. (high confidence) — [source](https://source.wiredtiger.com/develop/arch-compact.html)

## Facts and statements

- MongoDB 8.0 introduced compact dryRun to estimate reclaimable bytes without compacting. Alibaba's reclamation procedure also recommends this estimate before execution; it is an estimate of reclamation, not a promise that maintenance will free that amount. (medium confidence) (verified as of 2026-08-06) — [source](https://www.mongodb.com/docs/manual/reference/command/compact/)
- compact attempts to return unused collection and index disk space to the operating system. WiredTiger describes this as best effort: it moves blocks from the file tail into reusable space nearer the beginning so the tail can be truncated; successful completion does not guarantee file shrinkage. (high confidence) — [source](https://www.mongodb.com/docs/manual/reference/command/compact/)
- Measure storage on the same node before and after compaction. MongoDB recommends collection statistics including freeStorageSize for reusable allocation; Percona also checks WiredTiger file bytes available for reuse and operating-system disk usage. These reuse metrics are not a guarantee that all reported bytes can be returned to the operating system. (high confidence) — [source](https://www.mongodb.com/docs/manual/reference/command/compact/)
- MongoDB documents dryRun as introduced in 8.0: it returns estimatedBytesFreed without performing compaction. Use it to estimate reclaimable bytes on a supporting server; the documentation does not define that result as peak temporary disk-space demand. (low confidence) — [source](https://www.mongodb.com/docs/manual/reference/command/compact/)
