Repository navigation
Data Lifecycle
This page follows data from its creation to its removal, component by component. Every duration below is a default stated in a README or a script; set it where the README says it can be set. Where nothing is designed, the page says so.
| Stage | What happens | Source of the rule |
|---|---|---|
| Creation |
create_distributed_table splits a table into hash buckets (partitions named like <table>_b0001) and places them on shard groups. The table may hold rows. |
Sharding |
| Growth | New nodes join through add_node(); a rebalance moves buckets (one move at a time by default; strategies by bucket count or by disk size, weights per server, draining a server). A bucket can be split in 2, 4, 8 or 16 parts with split_bucket; the bucket count of a colocation group is otherwise changed by alter_distributed_table (a rebuild). |
Rebalancing, Sharding Table Lifecycle |
| Move | One bucket per move. The target gets a copy through logical replication, catches up, and the catalog switches. The old copy stays readable as kingres.orphan_<move>_<n> until move_cleanup_delay has passed and the worker or cleanup_moved_buckets() dropped it. For an erasure that must be final at once, run cleanup_moved_buckets(true) after the move. An old copy that objects of its owner depend on (a view, a foreign key) is not dropped; check_cluster() reports orphan_blocked until the dependent is dropped. A split leaves its old copies the same way and cleanup_bucket_splits() drops them. |
kingres_shard README |
| Distributed schema | A schema is placed and moved as one unit (distribute_schema, move_schema, undistribute_schema); a move leaves the old copy under the same cleanup rule. |
Sharding |
| Rebuild |
undistribute_table and alter_distributed_table (blocking, or online) copy into a shadow table, swap, verify, and keep the old copy until table_cleanup_delay; kingres.cleanup_table_operations() drops overdue copies. check_cluster() reports old_table for a copy overdue by an hour. |
Sharding Table Lifecycle |
| Removal |
DROP TABLE as for any table. A table under ledger control cannot be dropped (see below). |
Ledger |
Two-phase commit leaves bookkeeping that ages out by itself: the commit decisions in kingres.dtx_log are kept for kingres_shard.decision_retention seconds (default 300) after the participant's synchronous standbys confirm, and without limit until then; the marks in kingres.dtx_applied are kept as long and a minute; incidents in kingres.dtx_incident are shown by check_cluster() for 30 days.
kingres_timepart runs a cycle for each policy (default every hour, run_every):
-
Create ahead. Partitions are created for the cells up to
as_of + create_ahead(default 7 days) on a fixed grid, in one transaction each (CREATE TABLE ... (LIKE parent ...)thenATTACH PARTITION). -
Convert. Partitions of the grid that end at or before
as_of - columnar_afterare converted, oldest first, to the access methodcolumnarwith the policy's sort and options. Converting back toheapis the same call; a columnar partition accepts noUPDATEorDELETE, so it is converted to heap, changed and converted again. -
Retire. Partitions whose upper bound is at or before
as_of - retentionare detached and, forretention_action = 'drop'(the default), dropped. Withdetachthe table stays with its rows and its name. A partition that spans the boundary stays until its upper bound passes, so data can be kept up to onepartition_everylonger thanretention. Nothing deletes rows; the default partition and partitions off the grid are never retired.
columnar_after must not exceed retention. The history of runs and actions is kept for 90 days after the newest run and at most 1000 runs per table (timepart_prune_runs, called at the end of every run). Dropping the extension removes the policies and the whole history without a warning.
kingresd runs the policies on a scheduler and exposes them through the REST API and the console (policies, plans, runs; each run is a task, partition.maintain). A policy can also be run by SQL (timepart_run). On a user-partitioned distributed table the partitions are created, converted and retired on every server that holds a bucket.
- Rows are written in stripes and never changed.
kingres.columnar_compact(rel, min_rows)merges stripes smaller thanmin_rows(by default a quarter of the stripe size). It changes nothing logically and does not block readers or writers. -
VACUUMrecords counts, deletes catalog rows of dead files and returns the unreferenced tail of the file when it holds at least 1000 pages or a sixteenth of the file; it asks for the exclusive lock without waiting and gives up after 5 seconds. Since 0.2 the space that compaction and failed loads free inside the file is reused. -
kingres.columnar_infoshowsunreferenced_bytes;kingres.columnar_reconcile()deletes catalog rows of files no relation uses. - Conversion:
ALTER TABLE t SET ACCESS METHOD columnarrewrites underACCESS EXCLUSIVE; back withSET ACCESS METHOD heap. A rewrite gives the new file the default options. - No
UPDATEorDELETE.pg_upgradeof a columnar table is not supported in this version.
A sketch is a column value. A rollup is rebuilt for a whole window or fed each source row exactly once; uniting a window with itself leaves an hll as it was and counts everything twice in topn and tdigest. See Data Model Analytics.
- Ledger data is permanent by design. Enabling a table is permanent;
DROP TABLE,TRUNCATE,DROP SCHEMA ... CASCADEof its schema, andDROP EXTENSION kingres_ledgerwhile a ledger table exists are all rejected. No retention, compaction or archive of ledger tables is designed. - The one removal path is
ledger_remove_stray(reason), for rows that a hand wrote and that are not part of the chain. Each removal is copied intoledger_removedandledger_verifyreports it for as long as it exists. - Published tiles and checkpoints are kept for ever ("Minimum index is always 0, nothing is pruned"). The publisher deletes a partial tile 24 hours after its full tile appears. A bundle is a set of files under the data directory, available for 24 hours.
- The chain is closed, not deleted, when its database is dropped or its server is removed: a signed
chain-retiredevent is published. After a restore or a loss at failover the old log is frozen (closed) and a new epoch starts; the old log stays served. - Digests in
ledger_digestand verification records inledger_verificationaccumulate; the sources describe no pruning for them.
| Data | Lifecycle |
|---|---|
Tasks in kingres_cp.task
|
Not pruned; the control-plane README lists the lack of a retention as open. |
Audit log (audit.jsonl) |
Append-only JSON lines; rotates at 64 MiB into audit.jsonl.<first id>; segments are never deleted. |
| Metrics | No bundled store. A short in-memory history for the charts and /metrics for an external Prometheus (ADR 0020). |
| Standby replication slots | A slot that retains slot-retention-warn-bytes (default 1 GiB) raises replicationLagHigh; above slot-retention-limit-bytes (default 4 GiB) the slot is dropped and the standby is rebuilt. |
| Certificates | Renewed at a third of the lifetime left; the revocation list is valid 30 days and issued again after 10. The CA is not rotated. |
| Ledger signing keys | Created, rotated, retired (bounded by max_tree_size) and revoked by tasks; a retired key's old signatures stay valid. See Ledger Signing and Publication. |
Staged transfer files (kingres_cp.data_transfer) |
A table or database export, or an upload, is a sealed (encrypted) file in the staging directory of the manager leader. It expires after dataTransfer.retentionHours (1 to 168; 24 hours by default); a janitor deletes expired files, and an upload that received no bytes for 48 hours. An upload of a database import that is pending, running or paused is kept. Transfers are off until dataTransfer.enabled is on. |
There is no long-term archive subsystem. What exists: export and import. A table can be exported as CSV and imported again (all-or-nothing, with a commit marker), and a whole database can be exported as one zip archive (exportDatabase), the archive validated without touching any database (validateDatabaseArchive) and imported as a new database (importDatabase). The archive carries structure and data but no roles, grants, functions, triggers, policies or large objects, and a ledger table restarts its chain on import (Administrator Guide). Staged files expire as described above. Other things that keep data for a time: a detached time partition (kept as an ordinary table), the old copy of a moved bucket or rebuilt table (kept for the cleanup delay), and a WORM anchor target (an object store with Object Lock, written by the anchoring, which stores signed checkpoints and not row data). Write-ahead log archiving and point-in-time recovery are not configured by KingresDB; see Backup Restore and PITR.
- https://github.com/KingresDB/Kingres/blob/kingres-18/contrib/kingres_shard/README.md
- https://github.com/KingresDB/Kingres/blob/kingres-18/contrib/kingres_timepart/README.md
- https://github.com/KingresDB/Kingres/blob/kingres-18/contrib/kingres_columnar/README.md
- https://github.com/KingresDB/Kingres/blob/kingres-18/contrib/kingres_ledger/README.md
- https://github.com/KingresDB/Kingres/blob/kingres-18/contrib/kingres_sketch/README.md
- https://github.com/KingresDB/Kingres/blob/kingres-18/kingres/docs/design/analytics-phase12-storage.md
- https://github.com/KingresDB/Kingres/blob/kingres-18/kingres/docs/design/ledger-phase7.md
- https://github.com/KingresDB/Kingres/blob/kingres-18/kingres/control-plane/README.md
- https://github.com/KingresDB/Kingres/blob/kingres-18/kingres/docs/adr/0020-no-bundled-metrics-store.md
KingresDB's own code is licensed under AGPL-3.0-only. PostgreSQL code keeps the PostgreSQL License. Copyright of the project's own code: RooyeKhat Media Co. KingresDB is derived from PostgreSQL and is not endorsed by the PostgreSQL project. Repository | Licence | COPYRIGHT
KingresDB
1. Product
- Product Overview and Features
- Status and Roadmap
- User Guide
- Administrator Guide
- REST API Reference
- Web Console
- Command Line Client
- Extensions
- Limitations and Known Issues
- Release Notes
Features in detail
- Sharding
- Sharding Query Pushdown
- Sharding Table Lifecycle
- High Availability
- Ledger
- Ledger Signing and Publication
- Ledger Anchoring
- The Verifier
- Analytics Extensions
Administration
- Cluster Setup
- Servers Databases and Roles
- Rebalancing
- Configuration
- Memory and Warm-up
- Control Plane and REST API
- Upgrades
2. Architecture (arc42)
- Architecture
- Architecture Introduction and Goals
- Architecture Constraints
- Architecture System Context
- Architecture Containers
- Architecture Components
- Architecture Runtime Views Sharding
- Architecture Runtime Views Availability and Ledger
- Architecture Deployment
- Architecture Crosscutting Concepts
- Security Model
- Architecture Decisions
- Architecture Quality Requirements
- Architecture Risks and Technical Debt
- Enterprise Architecture
3. Data architecture
- Data Architecture
- Data Model Sharding
- Data Model Ledger
- Data Model System Database
- Data Model Analytics
- Data Lifecycle
- Backup Restore and PITR
- Data Security
- Data Quality and Integrity
4. Development
- Building from Source
- Development and Testing
- Repository Layout
- Coding Standards
- Branching and Synchronisation
- Testing Strategy
- Review Process
- Release Process
- Contributing
5. Operations