Bug #58122 Using DBUG_EXECUTE_IF and normal DBUG printouts not compatible
Submitted: 10 Nov 2010 18:21 Modified: 20 Dec 2010 3:09
Reporter: Mikael Ronström Email Updates:
Status: Closed Impact on me:
None 
Category:Tools: MTR / mysql-test-run Severity:S3 (Non-critical)
Version:MySQL 5.1, MySQL 5.5 OS:Any
Assigned to: Bjørn Munch CPU Architecture:Any

[10 Nov 2010 18:21] Mikael Ronström
Description:
Currently when running mysql-test-run one can use
--debug to invoke DBUG trace output.

Many test cases need to also do error injection. Error
injection uses the same variable debug for control.

The debug variable is by default empty. An empty list
means all DBUG printouts are made.

If a test case defines
SET debug="+d,symbol"
to enable a special DBUG_EXECUTE_IF to be activated this
will have the undesirable side effect that all DBUG
printouts are deactivated on this connection.

How to repeat:
Run e.g. create-big test case and check debug printout.

Suggested fix:
Add a new way of starting mysql-test-run:
--debug=default
This will be the same as starting with
--mysqld=debug=t.i:d,query,info,error,enter,exit:o,var/log/trace.log

It would be great to also be able to start server with
--debug=t.i.d,query,info,error,enter,exit:o,var/log/trace.log
to not have to use the extra --mysqld but this isn't so important.
But to remember the correct string to use instead of --debug=default
isn't for mortals :)
[24 Nov 2010 13:21] Bjørn Munch
I'm confused. The debug variable may be empty by the server's default, but when running mtr --debug, it's not empty. In is set (in the command line for mysqld) to

d:t:A,<trace file>
[24 Nov 2010 13:35] Mikael Ronström
From what I understand of debug syntax
d:t:A,trace_file
means that the debug part (=d) is empty.
This means that when I do
+d,symbol it is going from empty set to
one entry = symbol
[24 Nov 2010 13:57] Bjørn Munch
Ah, I get it, I got confused by the "debug variable" used about the debug part or flag.

It looks like what you need is if the debug flag is set and is empty, if a test sets it to "+d,foo" it should remain empty since everything+something is still everything.

But this would need to be changed in the server.

It's still possible to do what is suggested here though.
[24 Nov 2010 15:00] Mikael Ronström
The proposal is to add a new flag to mysql-test-run,
e.g. --set-debug
that changes the d:t:A,trace_file to something like
d,info,enter,exit,error,query:t:A,trace_file

In this way we never operate with an empty set and
adding something doesn't remove anything.
[29 Nov 2010 12:22] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/125331

2952 Bjorn Munch	2010-11-29
      Bug #58122 Using DBUG_EXECUTE_IF and normal DBUG printouts not compatible
      Added option --debug-common which setd 'd' debug flags to the suggested list
[1 Dec 2010 11:45] Ingo Strüwing
IMHO it is not a good thing to intermix debugging with error injection.
Debugging does not influence the code's behavior. It just provides information about the code's execution.
Error injection influences the code's behavior. It does not provide information.
The final soulution would be, not to use the keyword list of the 'd' modifier for error injection. Insted a new 'e' modifier could be introduced with an independent keyword list. However, this would need changes in the server's dbug.c and not so few changes in the tests.
The solution proposed in this bug report is a compromise, which can be quickly done without server code changes.
[1 Dec 2010 12:52] Bjørn Munch
Filed Bug #58630 for the server's set debug problem.
[1 Dec 2010 13:33] Ingo Strüwing
Thanks. An alternative could be to introduce a special keyword "all". If it is present in the list, all keywords match. Then, an empty list would mean that no keyword matches. The default list for --debug would be "d,all". Now "+d,xxx" won't change the trace output. If one wants a dedicated list only, one must "-d,all" and then "+d,list".

To make this somewhat efficient, one can introduce a flag for "all". Whenever the debug keyword list is changed, an occurrence of "all" would influence the flag. On DBUG_PRINT, the first test is, if debugging is enabled at all. The second would then be, if the "all" flag is set. Only if not, the keyword list would be checked.
[1 Dec 2010 13:37] Ingo Strüwing
The patch looks fine to me. Approved.
[1 Dec 2010 13:51] Bjørn Munch
As to the latest comment suggesting "d,all", that would change existing behavior and require changes to the doc. But that probably should be discussed in the other bug, not this one.
[9 Dec 2010 11:12] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/126402

3123 Bjorn Munch	2010-12-09
      Bug #58122 Using DBUG_EXECUTE_IF and normal DBUG printouts not compatible
      Added option --debug-common which sets 'd' debug flags to the suggested list
[9 Dec 2010 16:20] Bjørn Munch
Pushed to 5.5-mtr
[17 Dec 2010 12:52] Bugs System
Pushed into mysql-5.5 5.5.9 (revid:georgi.kodinov@oracle.com-20101217124733-p1ivu6higouawv8l) (version source revid:bjorn.munch@oracle.com-20101209195322-embe21sfutgb3oy0) (merge vers: 5.5.8) (pib:24)
[17 Dec 2010 12:56] Bugs System
Pushed into mysql-trunk 5.6.1 (revid:georgi.kodinov@oracle.com-20101217125013-y8pb3az32rtbplc9) (version source revid:anitha.gopi@sun.com-20101210041312-50t9adyhwwybsm6x) (merge vers: 5.6.1) (pib:24)
[20 Dec 2010 3:09] Paul DuBois
Changes to test suite. No changelog entry needed.