Commit 21f9cd5
committed
feat: rotate the internal PostgreSQL logs
The internal vector-db PostgreSQL redirected all output to a single
"$DATA_DIR/logfile" (pg_ctl -l) that grew without bound and was never
rotated, eventually filling the persistent storage on long-running
instances.
Drop the -l redirect and enable PostgreSQL's built-in logging collector
with the documented weekday scheme: one file per day named
postgresql-Mon.log through postgresql-Sun.log under "$DATA_DIR/log".
Size-based rotation stays off (log_rotation_size=0): with weekday
filenames PostgreSQL reopens the same file on a size rotation without
truncating, so a size cap cannot bound a day's file anyway.
The collector overwrites a weekday file only when it rotates while
running across a day boundary, not on startup, so a container that
restarts frequently would keep appending to the same-named weekday file
week after week. To keep the logs bounded to about a week regardless of
restart frequency, remove the legacy single logfile and any weekday log
at least six days old before starting the server, so last week's file is
always gone before its name is reused. This also reclaims the old
unbounded logfile on upgraded installs.
The options are passed on the pg_ctl command line, so they also take
effect for already-initialised data directories on the next restart and
need no edits to persisted configuration. Document the new log location
and retention in the README.
Fixes #303
Signed-off-by: Cesar <275373127+sanzakicesarr@users.noreply.github.com>1 parent 5b4c99d commit 21f9cd5
3 files changed
Lines changed: 15 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
| 107 | + | |
107 | 108 | | |
108 | 109 | | |
109 | 110 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
50 | 61 | | |
51 | | - | |
| 62 | + | |
52 | 63 | | |
53 | 64 | | |
54 | 65 | | |
| |||
0 commit comments