{question}
Why do I see old transaction files in my /logs directory? Are these files from months ago and stale? Should I delete these?
-rw-------. 1 memsql memsql 67108864 Jan 15 2021 testdb_log_v1_8589950976
-rw-------. 1 memsql memsql 268435456 Jan 23 2021 testdb_2_log_v1_8590065664
-rw-------. 1 memsql memsql 268435456 Mar 26 2021 testdb_25_log_v1_8590131200
-rw-------. 1 memsql memsql 268435456 Mar 26 2021 testdb_25_log_v1_8590065664
-rw-------. 1 memsql memsql 268435456 Jul 3 22:01 testdb_33_log_v1_8590065664
-rw-------. 1 memsql memsql 268435456 Jul 9 12:18 testdb_34_log_v1_8590589952
-rw-------. 1 memsql memsql 268435456 Jul 9 12:18 testdb_34_log_v1_8590524416
-rw-------. 1 memsql memsql 268435456 Oct 13 03:31 testdb_1_log_v1_8590065664
-rw-------. 1 memsql memsql 268435456 Oct 16 20:09 testdb_94_log_v1_8590065664
-rw-------. 1 memsql memsql 268435456 Oct 16 20:09 testdb_96_log_v1_8590131200
-rw-------. 1 memsql memsql 268435456 Oct 19 14:02 testdb_25_log_v1_8590000128
-rw-------. 1 memsql memsql 67108864 Oct 19 14:02 testdb_log_v1_8589934592
-rw-------. 1 memsql memsql 268435456 Oct 19 14:02 testdb_1_log_v1_8590000128
-rw-------. 1 memsql memsql 268435456 Oct 19 14:02 testdb_94_log_v1_8590000128
-rw-------. 1 memsql memsql 268435456 Oct 19 14:02 testdb_33_log_v1_8590000128
-rw-------. 1 memsql memsql 268435456 Oct 19 14:02 testdb_34_log_v1_8590458880
-rw-------. 1 memsql memsql 268435456 Oct 19 14:02 testdb_2_log_v1_8590000128
-rw-------. 1 memsql memsql 268435456 Oct 19 14:02 testdb_96_log_v1_8590065664
{question}
{answer}
Please note that this topic is discussing database transaction logs, which are your data stored on disk, and is NOT discussing trace logs, which are database node logging typically used for troubleshooting. The transaction log files are by default located at /data/logs of the SingleStore installation.
- Unless instructed to do so by our Support team, there is typically never a reason to delete these
/log
files. Doing so may result in data loss. - We will always make sure to have 5 additional log files in addition to the current one being used.
- So old log files will be reused by renaming them to have higher LSN and then putting new transaction log content into them. Their modification date will be updated however they can have an old creation date due to this. Once we'll have 5 future files, we won't reuse anymore.
- The logs are not cleaned up based on time, rather, they are cleaned up based on the global variables
snapshot_trigger_size
andsnapshots_to_keep
. snapshot_trigger_size
determines how often we take snapshots, andsnapshots_to_keep
determines when old snapshots are deleted.- It takes the value you have set for
snapshots_to_keep
number of snapshots since a blob was deleted for it to be physically removed from the disk.
To illustrate this, we will take a look at the log and snapshot files for testdb_33
:
testdb_33 log files
-rw-------. 1 memsql memsql 268435456 Jul 3 22:01 testdb_33_log_v1_8590065664
-rw-------. 1 memsql memsql 268435456 Oct 19 14:02 testdb_33_log_v1_8590000128
testdb_33 snapshot files
-rw-------. 1 memsql memsql 14131273 Oct 19 13:57 testdb_33_snapshot_v1_0_8590047837
-rw-------. 1 memsql memsql 14131273 Oct 19 14:02 testdb_33_snapshot_v1_0_8590047839
- As mentioned previously, a log file is only deleted if it is fully below the oldest snapshot. The LSN (the number at the end of the file name) in the log file
testdb_33_log_v1_8590000128
is the start LSN, and it ends at the start LSN of the next file,testdb_33_log_v1_8590065664
. - This particular log file spans a range of LSNs that contains the oldest snapshot. Thus, it cannot be recycled yet.
-rw-------. 1 memsql memsql 268435456 Oct 19 14:02 testdb_33_log_v1_8590000128
-rw-------. 1 memsql memsql 14131273 Oct 19 13:57 testdb_33_snapshot_v1_0_8590047837 <---- note how this snapshot LSN is within the log LSN range
-rw-------. 1 memsql memsql 14131273 Oct 19 14:02 testdb_33_snapshot_v1_0_8590047839 <---- note how this snapshot LSN is within the log LSN range
-rw-------. 1 memsql memsql 268435456 Jul 3 22:01 testdb_33_log_v1_8590065664
{answer}