Outdated Version

You are viewing an older version of this section. View current production version.

Trace Log min read


MemSQL uses a consolidated general/error log, referred to as the tracelog, to report INFO, WARNING, ERROR, and FAILURE messages.

Location and Management

The tracelog is located in the tracelogs directory with the file name memsql.log. When the server is started, it opens this file in append mode and begins to log messages.

You can rotate the log by moving the memsql.log file and then sending SIGHUP to the memsqld process. This will trigger the server to reopen memsql.log and continue writing.

MemSQL manages code compilation with a separate process. This process also maintains a tracelog named command.log.

Use the logrotate utility combined with a configuration file to automatically manage MemSQL log rotation. The example shown below rotates two log files.

Note: The example paths use the default folder location for MemSQL with an example ID value in the folder name for a master aggregator node. You should replace them with the values for your node. Also, this example assumes you are logged in as root when running logrotate.

# cat > /var/tmp/logrotate.conf <<EOF
/var/lib/memsql/master-3306-MI4478312f/tracelogs/memsql.log /var/lib/memsql/master-3306-MI4478312f/tracelogs/query.log {
         daily
         rotate 7
         missingok
         compress
         sharedscripts
         postrotate
             # Send SIGHUP to both memsqld processes
             killall -q -s1 memsqld
         endscript
}
EOF

Manually run logrotate and point to the configuration file created above.

# logrotate -f /var/tmp/logrotate.conf

List the compressed log files.

# ls /var/lib/memsql/master-3306-MI4478312f/tracelogs/*.gz

For more information about logrotate, see the logrotate manpage.

Logging Queries

MemSQL supports logging queries by setting the general_log variable. When set, MemSQL logs queries into the queries.log file in the tracelogs directory. The general_log variable supports three values:

  • OFF (default). No queries are logged.
  • PARTIAL. Logs a sample of the queries running through the system. This mode is designed for minimal overhead: if multiple queries are trying to write to the query log simultaneously, only one will succeed and the other writes will be abandoned.
  • ON. Every query running through the system is logged. This mode has a significantly negative impact on performance as query execution now depends on writes to the tracelog.

To log user queries, you can set the general_log variable on all aggregator nodes. For more information on how to set system variables, see How to Update System Variables.

Related Topics