Subject fbtracemgr and fb_trace files in /tmp/firebird
Author Vladimir Zbodulja
Hi guys,
I've noticed that, when I start 'fbtracemgr' session, server starts to create files (fb_trace.{<UUID>.<n>) in /tmp/firebird (on Linux) and the number of this files keeps growing and this files are not deleted after trace session is terminated.

For example, I've started trace session with (same happens if I redirect output to some file):
    /opt/firebird/bin/fbtracemgr -u sysdba -p masterkey -SE service_mgr -START -NAME fbt-trace -CONFIG $CFG >/dev/null

$CFG points to file with this content:

database
{
       enabled = true
       log_connections = false
       log_transactions = false
       log_statement_finish = true
       log_errors = true
       print_plan = true
       explain_plan = false
       print_perf = true
       time_threshold = 0
       max_sql_length = 8192
       max_log_size = 100
}
services  
{
}

After each minute there are around 150 new files (I'm tracing SQL on an active database that has around 40 running sessions) and this keeps growing until I terminate fbtracemg (with Ctrl-C) (i.e. after 10-15 minutes session there are cca. 2000 files):

...
-rw-rw---- 1 firebird firebird 1048576 Jun  7 11:38 fb_trace.{59EE03A6-A2A6-40D4-BAB2-E4EE1D238DE1}.0002901
-rw-rw---- 1 firebird firebird 1048576 Jun  7 11:38 fb_trace.{59EE03A6-A2A6-40D4-BAB2-E4EE1D238DE1}.0002902
-rw-rw---- 1 firebird firebird 1048576 Jun  7 11:38 fb_trace.{59EE03A6-A2A6-40D4-BAB2-E4EE1D238DE1}.0002903
-rw-rw---- 1 firebird firebird 1048576 Jun  7 11:38 fb_trace.{59EE03A6-A2A6-40D4-BAB2-E4EE1D238DE1}.0002904
-rw-rw---- 1 firebird firebird 1048576 Jun  7 11:38 fb_trace.{59EE03A6-A2A6-40D4-BAB2-E4EE1D238DE1}.0002905
-rw-rw---- 1 firebird firebird 1048576 Jun  7 11:38 fb_trace.{59EE03A6-A2A6-40D4-BAB2-E4EE1D238DE1}.0002908
-rw-rw---- 1 firebird firebird 1048576 Jun  7 11:38 fb_trace.{59EE03A6-A2A6-40D4-BAB2-E4EE1D238DE1}.0002909
-rw-rw---- 1 firebird firebird 1048576 Jun  7 11:38 fb_trace.{59EE03A6-A2A6-40D4-BAB2-E4EE1D238DE1}.0002910
-rw-rw---- 1 firebird firebird 1048576 Jun  7 11:38 fb_trace.{59EE03A6-A2A6-40D4-BAB2-E4EE1D238DE1}.0002911
-rw-rw---- 1 firebird firebird 1048576 Jun  7 11:38 fb_trace.{59EE03A6-A2A6-40D4-BAB2-E4EE1D238DE1}.0002912
-rw-rw---- 1 firebird firebird 1048576 Jun  7 11:38 fb_trace.{59EE03A6-A2A6-40D4-BAB2-E4EE1D238DE1}.0002913
...

Documentation (https://firebirdsql.org/rlsnotesh/rnfb25-trace.html) states that:

The output of a user session is stored in set of temporary files, each of 1 MB. Once a file has been completely read by the application, it is automatically deleted. By default, the maximum total size of the output is limited to 10 MB. It can be changed to a smaller or larger value using the MaxUserTraceLogSize in firebird.conf.

Once the user trace session service has been started by the application, the application has to read its output, using calls to isc_service_query(). The service could be generating output faster than the application can read it. If the total size of the output reaches the MaxUserTraceLogSize limit, the engine automatically suspends the trace session. Once the application has finished reading a file (a 1 MB part of the output) that file is deleted, capacity is returned and the engine resumes the trace session automatically.

Doesn't that mean that files should be kept on the filesystem only until fbtracemsg was able to read them and then automatically deleted (so that total size of them is constant if fbtracemsg manages to read them quickly enough)? 

I'm running: LI-V3.0.5.33125 Firebird 3.0
(MaxUserTraceLogSize is commented out in firebird.conf)

BR ,
   Vladimir.