Uploaded image for project: 'MariaDB MaxScale'
  1. MariaDB MaxScale
  2. MXS-4098

maxctrl rotate logs not working

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Not a Bug
    • Affects Version/s: 2.5.19
    • Fix Version/s: N/A
    • Component/s: Core
    • Labels:
      None

      Description

      See https://jira.mariadb.org/browse/MXS-2895

      configure maxscale qla filter:

      [query_logger]
      type=filter
      module=qlafilter
      filebase=/var/log/maxscale/query_log
      log_type=unified
      flush=true
      log_data=date, session, user, default_db, reply_time, query
       
      [Router]
      .
      .
      filters=query_logger
      

      configure logrotate:

      vim /etc/logrotate.d/maxscale_query
       
      /var/log/maxscale/query_log.unified {
      	rotate 99
      	size 1k
      	create 700 maxscale maxscale
      }
      

      add some data to log:

      for i in {1..33}
      do
          for j in {1..32}
          do
              echo "x">>/var/log/maxscale/query_log.unified
          done
      done
      

      maxscale# ls -alrth
      total 1.9M
      -rw-r--r--  1 maxscale maxscale  35K May  7  2021 maxscale.log-20210507
      -rw-r--r--  1 maxscale maxscale 1.8M Jun  1  2021 maxscale.log-20210601
      -rw-r--r--  1 maxscale maxscale  48K Jul  1  2021 maxscale.log-20210701
      -rw-r--r--  1 maxscale maxscale 4.2K Aug  1  2021 maxscale.log-20210801
      -rw-r--r--  1 maxscale maxscale  14K Apr 18 20:12 maxscale.log-20220418
      drwxr-xr-x. 9 root     root     4.0K Apr 18 20:12 ..
      -rw-r--r--  1 maxscale maxscale  630 Apr 18 20:33 maxscale.log
      drwxr-xr-x  2 maxscale maxscale  196 Apr 18 20:34 .
      -rw-r--r--  1 root     root     2.1K Apr 18 20:34 query_log.unified
      

      rotate the log

      maxscale# logrotate -f /etc/logrotate.d/maxscale_query
      maxscale# maxctrl rotate logs
      OK
      maxscale# 
      

      Now run some updates:

      ~# for i in {1..20}
      > do
      > mysql -h 10.0.0.96 -u max -pmax -ABNe 'insert into simple(blah) values(now());' test
      > done

      rotate the log again

      maxscale# logrotate -f /etc/logrotate.d/maxscale_query
      maxscale# maxctrl rotate logs
      OK
      maxscale# 
      

      Run another update:

      ~# mysql -h 10.0.0.96 -u max -pmax -ABNe 'insert into simple(blah) values(now());' test
      

      This is the result:

      maxscale# ls -alh
      total 1.9M
      drwxr-xr-x  2 maxscale maxscale  250 Apr 18 20:38 .
      drwxr-xr-x. 9 root     root     4.0K Apr 18 20:12 ..
      -rw-r--r--  1 maxscale maxscale 4.8K Apr 18 20:38 maxscale.log
      -rw-r--r--  1 maxscale maxscale  35K May  7  2021 maxscale.log-20210507
      -rw-r--r--  1 maxscale maxscale 1.8M Jun  1  2021 maxscale.log-20210601
      -rw-r--r--  1 maxscale maxscale  48K Jul  1  2021 maxscale.log-20210701
      -rw-r--r--  1 maxscale maxscale 4.2K Aug  1  2021 maxscale.log-20210801
      -rw-r--r--  1 maxscale maxscale  14K Apr 18 20:12 maxscale.log-20220418
      -rwx------  1 maxscale maxscale    0 Apr 18 20:38 query_log.unified
      -rwx------  1 maxscale maxscale 2.0K Apr 18 20:39 query_log.unified.1
      -rw-r--r--  1 root     root     2.1K Apr 18 20:34 query_log.unified.2
      maxscale# tail -n 2 query_log.unified.1
      20,2022-04-18 20:38:31,max@::ffff:10.0.0.95,15,insert into simple(blah) values(now()),test
      21,2022-04-18 20:39:02,max@::ffff:10.0.0.95,19,insert into simple(blah) values(now()),test
      

      Note how in this second rotation MaxScale did not release the handle to the file now named query_log.unified.1, and continues to write to it.

      Even if I run maxctrl rotate logs again, MaxScale continues to write to the old file:

      maxscale# tail -n 2 query_log.unified.1
      21,2022-04-18 20:39:02,max@::ffff:10.0.0.95,19,insert into simple(blah) values(now()),test
      22,2022-04-18 20:46:42,max@::ffff:10.0.0.95,18,insert into simple(blah) values(now()),test
      maxscale# maxctrl rotate logs
      OK
      maxscale# tail -n 2 query_log.unified.1
      22,2022-04-18 20:46:42,max@::ffff:10.0.0.95,18,insert into simple(blah) values(now()),test
      23,2022-04-18 20:47:14,max@::ffff:10.0.0.95,18,insert into simple(blah) values(now()),test
      

        Attachments

          Activity

            People

            Assignee:
            nantti Niclas Antti
            Reporter:
            juan.vera Juan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.