9. Log management
By the end of this chapter: You know which logs build up where, and you manage logs and core files so that they do not fill the disk.
9.1 Log file map
All logs are in ~/gritdb1/log/.
| Category | File | Rotation |
|---|---|---|
| Installation | install_gritdb_<timestamp>.log (a new file for each installation) |
None |
| Supervisor process | grit_admin_main.log and grit_admin_channel_server.log |
Automatic |
| Screen output | grit_admin_stdout.log — screen output of the supervisor process, the GritDB engine, and the catalog. ⚠ Each start overwrites it |
None |
| PostgreSQL | postgresql.log — contains the original text of failed SQL |
None (9.4) |
| Shared (written by both the PostgreSQL side and the GritDB engine) | grit_surfer_main.log and grit_plug_producer_processor.log |
They can exceed 200 MB because they almost never rotate by size. For cleanup, see 9.5. For the size record, see 7.4 |
| GritDB work inside PostgreSQL | grit_surfer_slot_manager_worker.log and grit_recovery_worker_process.log |
Automatic |
| Catalog | grit_catalog_processor.log (start, configuration reading, and processing) |
Automatic |
| Engine — change capture | grit_plug_consumer_processor.log |
Automatic |
| Engine — storage | grit_unify_main.log, grit_unify_delta_processor.log, grit_unify_chunk_processor.log, grit_unify_writer_processor.log, grit_unify_cold_store_compactor_gc_processor.log, grit_unify_hot_store_gc_processor.log, and grit_unify_hot_store_memory_pool_gc_processor.log |
Automatic |
| Engine — query processing | grit_burst_main.log and grit_burst_query_processor.log |
Automatic |
| Abort record | GRIT_SURFER_ASSERT.log — normally 0 bytes. If it is larger than 0, an abort occurred |
None |
9.2 Format and levels
- The GritDB log format is
[timestamp][level][tid:thread][location] message. The levels areINFO,WARN, andERROR. The format and levels are the same as in QuickStart 5.1. - A line is at most 4096 bytes. Longer lines are cut and end with
.... - The first line of a new file after rotation is
[GritSurferLogger] Log rotated - old file size: <bytes> bytes. This line has no prefix fields. - The PostgreSQL log (
postgresql.log) uses the PostgreSQL default format. The line prefix is<timestamp> <time zone> [<PID>], the default oflog_line_prefix.LOG:,ERROR:,FATAL:,PANIC:, and so on come after it. A failed statement is recorded on the next line,STATEMENT:(9.7). Messages of the GritDB extension (GritSurfer: …) are also written to this file. - GritDB logs always write at the
INFOlevel.INFO,WARN, andERRORlines are written. The level keys (*.log_level) inconfig/grit_*.configdo not change the level in 1.1. Do not delete the keys (5.6). - The log size key (
grit_unify.delta.log_file_max_byte) is also not used in 1.1. The rotation size is the fixed value in 9.3. Do not delete the key (5.6).
9.3 Rotation and size
| Category | Rotation | Size |
|---|---|---|
| GritDB logs (“Automatic” in the 9.1 table) | Each file rotates at 200 MB. GritDB keeps .1 (newest) to .20 and deletes older files |
Up to about 4 GB per log |
2 shared logs (grit_surfer_main.log and grit_plug_producer_processor.log) |
Almost never rotate by size | They can keep growing past 200 MB. Leave them as they are while GritDB runs. Archive and clean them up at a stop (9.5) |
4 files that do not rotate (postgresql.log, grit_admin_stdout.log, GRIT_SURFER_ASSERT.log, and datafiles/query_text_archive.jsonl) |
None | They keep growing. Only grit_admin_stdout.log is rewritten at start. See 9.4 and 9.5 |
- You can delete or move rotated files (
.1to.20) while GritDB runs. - When all rotating GritDB logs are full,
log/reaches tens of GB. For disk planning, see 1.3. For the daily size record, see 7.4.
9.4 PostgreSQL log rotation
With the installation default, postgresql.log does not rotate. One file keeps growing, so the operator sets up rotation. The PostgreSQL side is explained in Log file maintenance.
Rotate it with the OS logrotate. The log location and name do not change. Create /etc/logrotate.d/gritdb as root.
<installation directory>/log/postgresql.log {
su gritdb gritdb
daily
rotate 30
compress
delaycompress
missingok
notifempty
copytruncate
}
-
Use an absolute path for
<installation directory>(for example,gritdb1under the home directory of the service account). -
rotate 30anddailyare examples. Match them to your retention period (9.5). -
copytruncatecopies the file, then empties it. It rotates without stopping GritDB. A few lines written between the copy and the truncation can be lost. GritDB opens and writespostgresql.login append mode, so no empty space appears at the front after the truncation. -
To check, run
sudo logrotate -d /etc/logrotate.d/gritdb. The output has no error lines. The next day, runls -l <installation directory>/log/postgresql.log*. It shows a rotated file. -
For the ERROR count on the day of a rotation (QuickStart 5.2, 7.4), count both files together with the command below. logrotate runs once a day (on Ubuntu 24.04, within 1 hour after midnight). Today’s lines written before the rotation move to
postgresql.log.1.delaycompressmeans that.1is not compressed.cat ~/gritdb1/log/postgresql.log.1 ~/gritdb1/log/postgresql.log 2>/dev/null | grep -c "^$(date +%F).*ERROR:"
You can also rotate with the PostgreSQL log collector (logging_collector). In that case, the log location changes.
⚠ If you turn on
logging_collector, the location and name of the PostgreSQL log change
- Reason: New log lines go to the file that
log_directoryandlog_filenameset. Thepostgresql.logcommands in QuickStart 5.2 and chapter 7 do not see the new lines.- Instead: Use logrotate. If you turned on the collector, write the new location and name in the operations record. In that case, also change the file name in the check commands.
9.5 Retention and cleanup
- For the retention period, follow the log retention rules of your organization.
- From the time of a failure until the support case is closed, do not delete the logs of that period. This is because QuickStart 7.4 collects all of
log/.
| File | Cleanup while running | How to clean up |
|---|---|---|
Rotated GritDB logs (*.log.<N>) |
Allowed | Delete or move the files past the retention period (below) |
2 shared logs (grit_surfer_main.log and grit_plug_producer_processor.log) |
Do not | Rename and archive them while GritDB is stopped (below) |
postgresql.log |
Set up rotation (9.4) | logrotate deletes old files |
grit_admin_stdout.log |
Do not | Rewritten at every start. After an abnormal termination, collect it before you start GritDB again (4.3) |
GRIT_SURFER_ASSERT.log |
Do not | If it is larger than 0, collect it and contact support (QuickStart 7.4). After the support case is closed, move it to another name while GritDB is stopped. GritDB creates an empty file at the next start |
install_gritdb_<timestamp>.log |
Allowed | Keep it as an installation record |
datafiles/query_text_archive.jsonl |
Can be moved | It contains original SQL text, so move it and delete it according to your retention rules (9.7) |
Delete rotated files past the retention period as the service account. First check the targets with -print.
find ~/gritdb1/log -name '*.log.[0-9]*' -mtime +<days> -print
find ~/gritdb1/log -name '*.log.[0-9]*' -mtime +<days> -delete
Archive the 2 shared logs while GritDB is stopped.
for f in grit_surfer_main.log grit_plug_producer_processor.log; do
mv ~/gritdb1/log/"$f" ~/gritdb1/log/"$f.$(date +%Y%m%d)"
done
- To check, run
ls -l ~/gritdb1/log/. It shows the files with a date suffix. After the next start, check that new files with the original names appear. - The renamed files are also cleaned up by the
findcommands above.
9.6 Core files
A core file is a file to which a process writes its memory when it ends abnormally. A GritDB engine core file is as large as the engine memory (tens of GB).
| When it is created | Section |
|---|---|
Quick stop (gritdb-stop --quick) |
4.2 |
| A normal stop switches to a quick stop because sessions remain | 4.2 |
| Abnormal termination or stop failure | 4.3 |
As the service account, check when core files are created and where they go.
ulimit -Hc
cat /proc/sys/kernel/core_pattern
- If
ulimit -Hcis0, no core file is created. The GritDB engine raises its soft limit up to this hard value. The setting is in 1.4. - If
core_patternis a path, the core file is written there. If it starts with|, the core collection program of the OS receives it. In that case, check the location and configuration of that program. - If the core file cannot be fully written within 1 minute, it is cut off. Put it on a fast disk.
- For the core location, use a disk with as much free space as the engine memory. If it is on the same file system as
datafiles/, a core file can fill the data disk. - Do not delete a core file until the support case is closed. Delete it after that (7.6).
- When you contact support, report the location and size of the core file (QuickStart 7.4).
- A core file contains the data values that were in memory. For export, see 9.7.
9.7 Export
- ⚠ Logs, core files, and the analytic query text file can contain original SQL text and data values.
| File | Contents |
|---|---|
postgresql.log |
Original text of failed statements (STATEMENT: lines and their continuation lines), error details (DETAIL:, CONTEXT:, QUERY:), values in error messages (ERROR:), and statements logged by log_statement (11.9) and log_min_duration_statement (LOG: statement:, LOG: execute <name>:, LOG: duration: … statement: lines and their continuation lines). With ddl in 11.9, it also contains passwords |
GritDB logs (grit_*.log*) |
Can contain original SQL text, data values, and file paths |
datafiles/query_text_archive.jsonl |
The full original SQL text of analytics session queries |
| Analytic query history (6.5) | The first 1024 characters of the original SQL text |
| Core files | The whole process memory (data values) |
Steps before export:
-
As the file to send, choose
$S.masked.tar.gz, which you make in step 3 below. It consists of the QuickStart 7.4 collection, the configuration actually in use, and masked logs.$S.tar.gzfrom QuickStart 7.4 contains unmasked logs, so do not send it. Allow only the service account to read it, or delete it (11.7). -
Review the places in the table above under the data export rules of your organization.
-
Mask the logs. Make the bundle again from copies without the original SQL text lines. Run the commands in the same shell as QuickStart 7.4 (
cd ~,$S).for f in ~/gritdb1/log/postgresql.log*; do zcat -f "$f" | awk '/(STATEMENT|DETAIL|CONTEXT|QUERY):/ || /LOG: +(duration: [0-9.]+ ms +)?(statement|execute|bind|parse)[^:]*:/ {skip=1; next} skip && /^\t/ {next} {skip=0; print}' > "$S/masked_$(basename "$f" .gz)" done grep -c -E '(STATEMENT|DETAIL|CONTEXT|QUERY):|LOG: +(duration: [0-9.]+ ms +)?(statement|execute|bind|parse)[^:]*:' "$S"/masked_* cp ~/gritdb1/datafiles/pgdata/postgresql.auto.conf "$S/" cp -r ~/gritdb1/config "$S/" tar -czf "$S.masked.tar.gz" --exclude='postgresql.log*' "$S" -C ~/gritdb1 log tar -tzf "$S.masked.tar.gz" | grep -c '/postgresql\.log'- The lines left out are statements and details attached to errors (
STATEMENT:,DETAIL:,CONTEXT:,QUERY:), and statements logged bylog_statementandlog_min_duration_statement(statement:,execute,bind,parse). Their continuation lines, which start with a tab, are left out too. - Rotated files (
.1,.2.gz… in 9.4) are masked too.zcat -freads uncompressed files as they are. The bundle does not include the unmaskedpostgresql.log*(--exclude). - Check that the first
grep -creturns0for each file and that the last line returns0. postgresql.auto.conf(ALTER SYSTEMvalues, 5.3) andconfig/(GritDB engine configuration, 5.6) are the configuration actually in use, so send them together with the logs.ERROR:lines can also contain values, so check them in the step 2 review.
- The lines left out are statements and details attached to errors (
-
Core files cannot be masked, so decide with your organization whether to send them. If you cannot send them, say so when you contact support.
-
Record the files sent, the date, and the recipient.
- For detailed collection and export procedures, see TroubleShooting.
If a problem occurs
- If there is not enough disk space, see GDB-RUNTIME-002 in QuickStart, chapter 7, and TroubleShooting.
Learn more
- For routine cleanup, see 7.6. For security, see 11.7.
- PostgreSQL 17 documentation: Log settings, Log file maintenance