This page covers Canton-side pruning for participant nodes and automatic pruning configuration. For Super Validator pruning of the sequencer and CometBFT layers, see SV Pruning.Documentation Index
Fetch the complete documentation index at: https://docs.canton.network/llms.txt
Use this file to discover all available pages before exploring further.
Participant node pruning
Pruning helps bound the size of the database storage. Participant Node pruning refers to the selective removal of archived contracts and old transactions. Select one of two options, choosing between ease-of-use and control:- Automatic pruning instructs the Participant Node to perform pruning according to a regular schedule and retention period.
- Manual pruning provides explicit control over the ledger offset to prune up to. In addition, manual pruning allows integration of pruning with operational procedures such as database backups and defragmentation.
Enable automatic pruning
Enable automatic pruning by specifying a pruning schedule consisting of the following:- A cron expression that designates regular pruning begin times.
- A maximum duration specifying pruning end times relative to the begin times of the cron expression.
- A retention period to specify how far to prune relative to the current time.
- An optional indication of whether to prune internal stores only, or by default, to prune Ledger API visible archived contracts and updates as well.
Perform manual pruning
Manually pruning Participant Nodes allows composing pruning with database maintenance operations, but requires identifying an explicit ledger offset up to which the ledger should be pruned.-
Identify the numeric ledger offset up to which to prune the ledger by specifying the time up to which to prune:
The
find_safe_offsetmethod returnsNoneif no offset corresponds to the specified time. -
Invoke manual pruning on the Participant Node.
In almost all cases, choose the comprehensive
prunemethod that frees up the most storage, but also reduces the portion of the ledger visible via the Ledger API.In some cases, you might elect to use theprune_internallymethod in addition to theprunemethod. Typically, you invoke theprune_internallymethod after theprunemethod and with a larger offset. For example, this way you can retain three months of the Ledger API history, but prune the internal stores up to one month.On Participant Nodes that are configured for high availability and share a common database, the pruning methods have to be invoked on the active Participant Node replica.
prune and prune_internally methods might appear to be hanging unless the ledger offset is iteratively increased in sufficiently small increments for piecemeal pruning via multiple methods calls. In addition, these manual methods have no built-in mechanism to resume on another node after a high-availability failover.
Defragment the database
Defragment the database after pruning. Pruning deletes data from the database, freeing up space, but it does not resize tables. Refer to the PostgreSQL documentation onVACUUM and VACUUM FULL for more information on how to optimally reclaim the space freed up by pruning.
Monitor pruning progress
Monitor the pruning state to determine that the pruning schedule allows pruning to keep up with ledger growth, and that automatic pruning is not stuck for one of the reasons described below as pruning limitations. Monitor thedaml_pruning_max_event_age metric describing the age of the “oldest, un-pruned” event (in hours). The max-event-age metrics should not exceed the value of the pruning schedule retention plus the length of the interval. For example, if your schedule specifies a retention of 30 days and a cron that calls for weekly pruning, max-event-age must remain below 37 days. If for any node the max-event-age metric exceeds this upper limit, consider allocating more time for pruning by reducing the interval between pruning windows, or by increasing the maximum duration pruning schedule setting.
Automatic pruning reference
The following functions are available to set, modify, and read the pruning schedule:\*), as illustrated in the preceding examples. If the hour field is fixed, the fields for the minute and the second must be fixed too.
Schedule format
Cron expressions are formatted as seven whitespace-separated fields:| Field | Type and valid values* |
|---|---|
| seconds | number from 0 to 59 |
| minutes | number from 0 to 59 |
| hours | number from 0 to 23 |
| day of the month | number from 1 to 31 |
| month | number from 0 to 11 (0 = January) or the first three letters of the month name (JAN, FEB, MAR, etc) |
| day of the week | number from 1 to 7 (1 = Sunday) or the first three letters of the day name (SUN, MON, TUE, etc) |
| year (optional) | number from 1900 to 2099 |
Advanced schedule formatting
- You can construct lists and ranges of values. For example, the day of the week could be a range like
MON-FRIto refer to the days Monday through Friday, orTUE,FRIto refer to Tuesday and Friday exclusively. Or you could use a mix of both, for example,MON,WED-FRI, meaning “Monday, and also Wednesday through Friday.” - Use the asterisk (
*) as a wildcard that means “all possible values.” - Use the question mark (
?) as a wildcard that means “any value” in the day-of-the-month and day-of-the-week fields. For example, to specify “every Monday at noon,” use the?character to indicate that any day of the month is valid:0 0 12 ? * MON - To apply increments to numeric values, use the slash character (
/). For example, a value of1/2in the hours field means “every two hours starting from 1 AM” (1 AM, 3 AM, 5 AM, etc).
0 30 * * * *Every hour at half past0 5/15 12,18-20 * * *Every fifteen minutes, starting from five past, at noon and from 6 to 8 PM0 5/15 12,18-20 ? * MON,THUSame as above, but only on Mondays and Thursdays0 0 22 1 * ?Every first day of the month at 10 PM