H2 Database Purge Old Logs

Overview

The H2 Database Purge feature ensures optimal database performance and prevents uncontrolled growth of the process_table in the embedded H2 database. It automatically removes older records and their associated log files based on configurable retention limits.

This process runs periodically in the background and is controlled by the application to maintain a healthy system state without manual intervention.


Why Purging is Needed??

  • Over time, the process_table accumulates large amounts of process logs.

  • Without cleanup, the database can grow too large, impacting performance and consuming disk space.

  • Purging helps maintain stability, speed, and optimal storage usage.


How It Works

  • The application automatically removes old process records and their corresponding log files based on a retention limit.

  • Only the most recent logs are kept, ensuring you have access to the latest data while older entries are removed.

  • This cleanup runs in the background every 2 days, requiring no manual intervention.


Key Points

  • Fully Automated: No action required from your side.

  • Safe: Only older data is deleted; recent logs remain.

  • Configurable: Retention limits can be adjusted based on your requirements.

Default Retention Policy

  • The system keeps the most recent 250 records and 250 log files by default.

  • If needed, these limits can be customized in the configuration.

  • Older entries beyond these limits are automatically purged.

Property Name

Default Value

Description

h2db.purge.limit

250

Number of latest database records to keep.

log.files.limit

250

Number of latest log files to retain.

Older entries beyond these limits are automatically purged.


Configuration Example

If you want to increase the retention limits, update your system.properties file:

# Retain the latest 500 records in the H2 database

h2db.purge.limit=500

# Retain the latest 500 log files

log.files.limit=500

Benefits

  • Improved Performance: Keeps the database lightweight and responsive.

  • Optimized Storage: Prevents unnecessary disk usage.

  • Hassle-Free: Automatic, no maintenance required.


Note: If your compliance or audit requirements need longer retention, export logs periodically before they are purged

Last updated