MySQL tc_positions.idb is getting bigger and bigger

Synergy Dave3 years ago

Hello,
I noticed that tc_positions table is using all my disk space, I've configured traccar to keep 1 day history but the table is getting about 4GB bigger every day.

$ sudo du -h /var/lib/mysql/gpstraccar/tc_positions.ibd
38G     /var/lib/mysql/gpstraccar/tc_positions.ibd

counting records in tc_positions, returns:


Database changed
mysql> select count(*) from tc_positions;
+----------+
| count(*) |
+----------+
| 98989855 |
+----------+
1 row in set (49.16 sec)

mysql>

mySQL config /etc/mysql/mysql.conf.d/mysqld.cnf:

# Here is entries for some specific programs
# The following values assume you have at least 32M ram

[mysqld]
#
# * Basic Settings
#
user            = mysql
# pid-file      = /var/run/mysqld/mysqld.pid
# socket        = /var/run/mysqld/mysqld.sock
# port          = 3306
# datadir       = /var/lib/mysql


# If MySQL is running as a replication slave, this should be
# changed. Ref https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_tmpdir
# tmpdir                = /tmp
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address            = 127.0.0.1
mysqlx-bind-address     = 127.0.0.1
#
# * Fine Tuning
#
key_buffer_size         = 16M
# max_allowed_packet    = 64M
# thread_stack          = 256K

# thread_cache_size       = -1

# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover-options  = BACKUP


# max_connections        = 151

# table_open_cache       = 4000

#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
#
# Log all queries
# Be aware that this log type is a performance killer.
# general_log_file        = /var/log/mysql/query.log
# general_log             = 1
#
# Error log - should be very few entries.
#
log_error = /var/log/mysql/error.log
#
# Here you can see queries with especially long duration
# slow_query_log                = 1
# slow_query_log_file   = /var/log/mysql/mysql-slow.log
# long_query_time = 2
# log-queries-not-using-indexes
#
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
#       other settings you may need to change.
# server-id             = 1
# log_bin                       = /var/log/mysql/mysql-bin.log
# binlog_expire_logs_seconds    = 2592000
# max_binlog_size   = 100M
# binlog_do_db          = include_database_name
# binlog_ignore_db      = include_database_name
#
skip-log-bin
#

innodb_buffer_pool_size = 16G

anyone has faced similair problem?
mysql version is: mysql Ver 8.0.27-0ubuntu0.20.04.1 for Linux on x86_64 ((Ubuntu))

thank you

Anton Tananaev3 years ago

What version of Traccar are you using and how did you configure it to only store one day?

Synergy Dave3 years ago

Hello,
I'm using this entry in traccar.xml
<entry key='database.historyDays'>1</entry>

version traccar-linux-64-4.11.zip

I noticed that I don't have a database.deletePositions entry, could this be the reason?

Thank you,

Anton Tananaev3 years ago

I don't remember when we removed that configuration parameter, but you shouldn't use it either way. Please check documentation on how to set up external script to clean up history.