Database cleanup¶
Data will accumulate over time in the database if client USSs do not remove their expired entities, and this can lead to lower performance due to quantity of stale entities. For this reason, InterUSS recommends periodically cleaning up no-longer-relevant entities if USS clients do not always clean up after themselves.
This page describes how to clean up expired entities from the DSS datastore using the db-manager evict command.
Overview¶
The evict subcommand of db-manager is a CLI tool that lists and deletes expired entities in the DSS store. The following entity types are supported:
- SCD operational intents
- SCD subscriptions
- RID identification service areas (ISAs)
- RID subscriptions
By default, the tool only lists expired entities. Deletion is opt-in via the --delete flag.
Warning
Using this tool incorrectly may result in loss of data. Before deleting anything:
- Always review and validate the list of entities identified as expired (run the tool without
--deletefirst). - Ensure a backup of the data is available.
- Double-check the TTL values passed to
--rid_ttland--scd_ttl.
Expiration of entities is preferably determined through their end times. In the unusual event that an end time is not available, the last update time is used instead.
Why and when to run the cleanup¶
Expired entities (operational intents past their end time, stale subscriptions, ISAs whose lifetime has elapsed) can accumulate over time in the datastore if not cleaned up by clients. While the DSS keeps functioning correctly with some stale rows present, excessive accumulation can impact:
- Storage growth: unbounded storage usage in data stores (e.g., CockroachDB / YugabyteDB).
- Query performance: indexes get larger, range scans on
operational_intents/subscriptions/identification_service_areasdegrade.
There is no single correct interval or TTL. Reasonable values depend on context and must be defined per DSS pool, taking into account: traffic volume and entity churn, regulatory or contractual data-retention requirements applicable to your jurisdiction, the storage capacity of the datastore cluster, and how long clients may legitimately need to query historical entities.
The defaults shipped with the deployment tooling (30m TTL on RID running every 30 min, 2688h ≈ 56-day TTL on SCD running nightly when enabled) are starting points, not recommendations. Validate production values against the criteria above.
Performance impact¶
All expired entities are identified and removed within a single transaction. When the system is under heavy load, lock contention with concurrent transactions may cause the cleanup to fail. There is no risk of data inconsistency in this case - the cleanup may simply be retried.
To mitigate this:
- Run the cleanup during low-intensity periods (e.g. at night).
- Clean up iteratively, starting with a lower TTL and progressively increasing it. If this becomes a recurring issue, batching removals could be considered as a future improvement.
Changes in locality¶
There may be cases where a DSS instance changes its locality. This commonly occurs if locality wasn't previously required, though routine updates can also trigger a change.
In such cases, ensure that a cleanup is performed on the older locality (if it was not set before, set an empty one), especially since the automatically deployed cron job (see below) will automatically follow the locality settings of the main service.
Usage¶
Extracted from db-manager evict --help:
Notes:
- By default, expired entities are only listed -
--deleteis required to actually remove them. --rid_ttland--scd_ttlaccept durations formatted as Gotime.Durationstrings, e.g.24h.- The datastore connection flags match those of the
core-servicecommand.
Regular cleanup¶
Beyond running db-manager evict manually, the DSS deployment tooling can schedule the cleanup as a recurring Kubernetes CronJob. Three deployment paths expose the same set of evict knobs, but will always run with the --delete flag set.
Shared default: RID cleanup is enabled by default (*/30 * * * *, ttl = 30m); SCD cleanup is disabled by default (suggested schedule 0 2 * * *, ttl = 2688h - i.e. 2 x 56 days).
The current defaults are structured this way because each DSS instance is intended to manage the cleanup of its own RID objects (with deletion restricted to entities created by that specific instance, based on locality). Conversely, SCD cleanup is a global operation; therefore, DSS operators should coordinate to avoid redundant tasks, or potentially designate a single USS to handle the cleanup process.
Helm¶
The dss chart includes a dss-evict CronJob (see deploy/services/helm-charts/dss/templates/dss-evict.yaml), configured under dss.conf.evict in values.yaml:
Tanka¶
Configure it under the evict key of your environment metadata:
Terraform¶
When deploying via terrafrom modules, the parameters are configurable with module variables:
| Terraform variable | Default |
|---|---|
evict_enable_scd_cron |
false |
evict_scd_schedule |
"0 2 * * *" |
evict_scd_ttl |
"2688h" |
evict_scd_operational_intents |
true |
evict_scd_subscriptions |
true |
evict_enable_rid_cron |
true |
evict_rid_schedule |
"*/30 * * * *" |
evict_rid_ttl |
"30m" |
evict_rid_isas |
true |
evict_rid_subscriptions |
true |
Examples¶
The examples below assume a DSS running locally via the run_locally.sh script.