docs(architecture): remove deprecated auditlog prep script step and correct numbering
This commit is contained in:
@@ -28,13 +28,7 @@ The solution is divided into a series of SQL scripts that must be executed seque
|
|||||||
* Creates the `partitions.config` table (which stores retention policies).
|
* Creates the `partitions.config` table (which stores retention policies).
|
||||||
* Creates the `partitions.version` table for tracking the installed version.
|
* Creates the `partitions.version` table for tracking the installed version.
|
||||||
|
|
||||||
### 2. `01_auditlog_prep.sql`
|
### 2. `01_maintenance.sql`
|
||||||
* **Purpose:** Prepares the Zabbix `auditlog` table for partitioning.
|
|
||||||
* **Actions:**
|
|
||||||
* PostgreSQL range partitioning requires the partition key (in this case, `clock`) to be part of the Primary Key.
|
|
||||||
* This script dynamically locates the existing Primary Key (usually just `auditid`) and alters it to a composite key `(auditid, clock)`.
|
|
||||||
|
|
||||||
### 3. `01_maintenance.sql`
|
|
||||||
* **Purpose:** Contains the core PL/pgSQL procedural logic that manages the lifecycle of the partitions.
|
* **Purpose:** Contains the core PL/pgSQL procedural logic that manages the lifecycle of the partitions.
|
||||||
* **Key Functions/Procedures:**
|
* **Key Functions/Procedures:**
|
||||||
* `partition_exists()`: Queries `pg_class` to verify if a specific child partition partition exists.
|
* `partition_exists()`: Queries `pg_class` to verify if a specific child partition partition exists.
|
||||||
@@ -43,14 +37,15 @@ The solution is divided into a series of SQL scripts that must be executed seque
|
|||||||
* `maintain_table()`: The orchestrator for a single table. It calculates the necessary UTC timestamps, calls `create_partition()` to build the future buffer, calls `create_partition()` recursively backward to cover the retention period, and finally calls `drop_old_partitions()`.
|
* `maintain_table()`: The orchestrator for a single table. It calculates the necessary UTC timestamps, calls `create_partition()` to build the future buffer, calls `create_partition()` recursively backward to cover the retention period, and finally calls `drop_old_partitions()`.
|
||||||
* `run_maintenance()`: The global loop that iterates through `partitions.config` and triggers `maintain_table()` for every configured Zabbix table.
|
* `run_maintenance()`: The global loop that iterates through `partitions.config` and triggers `maintain_table()` for every configured Zabbix table.
|
||||||
|
|
||||||
### 4. `02_enable_partitioning.sql`
|
### 3. `02_enable_partitioning.sql`
|
||||||
* **Purpose:** The migration script that actually executes the partition conversion on the live database.
|
* **Purpose:** The migration script that actually executes the partition conversion on the live database.
|
||||||
* **Actions:**
|
* **Actions:**
|
||||||
|
* It dynamically locates the existing Primary Key on the active `auditlog` table (usually just `auditid`) and alters it to a composite key `(auditid, clock)` so it supports range partitioning.
|
||||||
* It takes the original Zabbix table (e.g., `history`) and renames it to `history_old` (`ALTER TABLE ... RENAME TO ...`).
|
* It takes the original Zabbix table (e.g., `history`) and renames it to `history_old` (`ALTER TABLE ... RENAME TO ...`).
|
||||||
* It immediately creates a new partitioned table with the original name, inheriting the exact structure of the old table (`CREATE TABLE ... (LIKE ... INCLUDING ALL) PARTITION BY RANGE (clock)`).
|
* It immediately creates a new partitioned table with the original name, inheriting the exact structure of the old table (`CREATE TABLE ... (LIKE ... INCLUDING ALL) PARTITION BY RANGE (clock)`).
|
||||||
* It triggers the first maintenance run so new incoming data has immediate partitions to land in.
|
* It triggers the first maintenance run so new incoming data has immediate partitions to land in.
|
||||||
|
|
||||||
### 5. `03_monitoring_view.sql`
|
### 4. `03_monitoring_view.sql`
|
||||||
* **Purpose:** Provides an easy-to-read observability layer.
|
* **Purpose:** Provides an easy-to-read observability layer.
|
||||||
* **Actions:**
|
* **Actions:**
|
||||||
* Creates the `partitions.monitoring` view by joining `pg_class`, `pg_inherits`, `pg_tablespace`, and `pg_size_pretty`.
|
* Creates the `partitions.monitoring` view by joining `pg_class`, `pg_inherits`, `pg_tablespace`, and `pg_size_pretty`.
|
||||||
|
|||||||
Reference in New Issue
Block a user