Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-4977

./mysql-test/mysql-test-run.pl not identifying mariadb version

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 5.5.32
    • Fix Version/s: 5.5.34
    • Component/s: None
    • Labels:
      None
    • Environment:
      5.5.32-MariaDB-1~wheezy for debian-linux-gnu on x86_64

      Description

      I followed the following steps after having an apt sources like for mariadb

      apt-get build-dep mariadb-5.5
      apt-get install cmake libaio1 libaio-dev fakeroot valgrind
      apt-get source mariadb-5.5
      cd mariadb-5.5*

      edited debian/control and debian/rules as per https://kb.askmonty.org/en/how-to-produce-a-full-stack-trace-for-mysqld-the-mariadb-server/#comment_359 (except using 5.5 as version number)
      edit debian/rules added -DCMAKE_BUILD_TYPE=Debug to cmake as per https://kb.askmonty.org/en/compiling-mariadb-for-debugging/

      dpkg-buildpackage -us -uc (http://www.debian.org/doc/manuals/maint-guide/build.en.html)

      resulted in error:
      "mysql-test-run: *** ERROR: Could not find version of MariaDB"

      added "mtr_report("List: ", join("\n", @list));" before the mtr_error in ./mysql-test/mysql-test-run.pl rerunnign with dpkg-buildpackage -nc -us -uc revealed:
      "List: /home/danblack/mariadb-5.5-5.5.32+maria/builddir/sql/mysqld Ver 5.5.32-MariaDB-1~wheezy for debian-linux-gnu on x86_64 (mariadb.org binary distribution)..."

      A quick tests shows the regex not matching:

      perl
      $a="/home/danblack/mariadb-5.5-5.5.32+maria/builddir/sql/mysqld Ver 5.5.32-MariaDB-1~wheezy for debian-linux-gnu on x86_64 (mariadb.org binary distribution)";
      $exe_mysqld="/home/danblack/mariadb-5.5-5.5.32+maria/builddir/sql/mysqld";
      $a =~ /^$exe_mysqld\s+Ver\s(\d+)\.(\d+)\.(\d+)(\S*)/;
      print "0=$0 1=$1 2=$2 ";
      0=- 1= 2=

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            elenst Elena Stepanova added a comment -

            Hi Daniel,

            The regex does not find a match because you have a '+' in your file path. The logic might be worth fixing, but as a workaround, could you please try to remove it?

            Show
            elenst Elena Stepanova added a comment - Hi Daniel, The regex does not find a match because you have a '+' in your file path. The logic might be worth fixing, but as a workaround, could you please try to remove it?
            Hide
            danblack Daniel Black added a comment -

            Yes renaming works. Thanks for identifying the obvious regex fault.

            Logging: ./mysql-test-run.pl --force
            Using suites: main-,archive-,binlog-,csv-,federated-,funcs_1-,funcs_2-,handler-,heap-,innodb-,maria-,optimizer_unfixed_bugs-,oqgraph-,parts-,percona-,perfschema-,plugins-,rpl-,sphinx-,sys_vars-,unit-,vcol-
            vardir: /home/danblack/mariadb-5.5-5.5.32_maria/builddir/mysql-test/var
            Removing old var directory...
            Creating var directory '/home/danblack/mariadb-5.5-5.5.32_maria/builddir/mysql-test/var'...
            Checking supported features...
            MariaDB Version 5.5.32-MariaDB-1~wheezy

            Given the standard "apt-get source mariadb-5.5" creates this directory name I still think its worth fixing.

            Show
            danblack Daniel Black added a comment - Yes renaming works. Thanks for identifying the obvious regex fault. Logging: ./mysql-test-run.pl --force Using suites: main-,archive-,binlog-,csv-,federated-,funcs_1-,funcs_2-,handler-,heap-,innodb-,maria-,optimizer_unfixed_bugs-,oqgraph-,parts-,percona-,perfschema-,plugins-,rpl-,sphinx-,sys_vars-,unit-,vcol- vardir: /home/danblack/mariadb-5.5-5.5.32_maria/builddir/mysql-test/var Removing old var directory... Creating var directory '/home/danblack/mariadb-5.5-5.5.32_maria/builddir/mysql-test/var'... Checking supported features... MariaDB Version 5.5.32-MariaDB-1~wheezy Given the standard "apt-get source mariadb-5.5" creates this directory name I still think its worth fixing.
            Hide
            danblack Daniel Black added a comment -

            Since exe_mysqld isn't a regex escape everything that makes it look like one.

            so add:
            $exe_mysqld =~ s/([\\.+*{}()[\]])/\\\1/g;

            before: mtr_error("Could not find version of MariaDB")

            to test:
            perl e '$a="/home/danblack/maria
            db
            ()5.5-5.5.32+m[]a*ria"; $a =~ s/([\\.+*{}()[\]])/\\\1/g; print "$a\n";'
            /home/danblack/maria\\db-()5\.5-5\.5\.32+m[]a*ria

            Show
            danblack Daniel Black added a comment - Since exe_mysqld isn't a regex escape everything that makes it look like one. so add: $exe_mysqld =~ s/([\\.+*{}() [\]] )/\\\1/g; before: mtr_error("Could not find version of MariaDB") to test: perl e '$a="/home/danblack/maria db ()5.5-5.5.32+m[]a*ria"; $a =~ s/([\\.+*{}() [\]] )/\\\1/g; print "$a\n";' /home/danblack/maria\\db-()5\.5-5\.5\.32+m[]a*ria
            Hide
            elenst Elena Stepanova added a comment -

            I don't feel quite safe modifying exe_mysqld, it might happen that it's used somewhere else. On the other hand, there seems no good reason to match the line with the complete path to mysqld, it should be enough to start with the file name, something like:

            === modified file 'mysql-test/mysql-test-run.pl'
            — mysql-test/mysql-test-run.pl 2013-07-16 17:09:54 +0000
            +++ mysql-test/mysql-test-run.pl 2013-09-05 23:35:53 +0000
            @@ -1889,8 +1889,9 @@
            $list =~ s/\n

            {22}

            (\S)/ $1/g;

            my @list= split '\n', $list;
            + my $bn = basename($exe_mysqld);
            mtr_error("Could not find version of MariaDB")

            • unless shift(@list) =~ /^$exe_mysqld\s+Ver\s(\d+)\.(\d+)\.(\d+)(\S*)/;
              + unless shift(@list) =~ /$bn\s+Ver\s(\d+)\.(\d+)\.(\d+)(\S*)/;
              $mysql_version_id= $1*10000 + $2*100 + $3;
              $mysql_version_extra= $4;
              mtr_report("MariaDB Version $1.$2.$3$4");

            I'll pass it to serg to decide.

            Show
            elenst Elena Stepanova added a comment - I don't feel quite safe modifying exe_mysqld, it might happen that it's used somewhere else. On the other hand, there seems no good reason to match the line with the complete path to mysqld, it should be enough to start with the file name, something like: === modified file 'mysql-test/mysql-test-run.pl' — mysql-test/mysql-test-run.pl 2013-07-16 17:09:54 +0000 +++ mysql-test/mysql-test-run.pl 2013-09-05 23:35:53 +0000 @@ -1889,8 +1889,9 @@ $list =~ s/\n {22} (\S)/ $1/g; my @list= split '\n', $list; + my $bn = basename($exe_mysqld); mtr_error("Could not find version of MariaDB") unless shift(@list) =~ /^$exe_mysqld\s+Ver\s(\d+)\.(\d+)\.(\d+)(\S*)/; + unless shift(@list) =~ /$bn\s+Ver\s(\d+)\.(\d+)\.(\d+)(\S*)/; $mysql_version_id= $1*10000 + $2*100 + $3; $mysql_version_extra= $4; mtr_report("MariaDB Version $1.$2.$3$4"); I'll pass it to serg to decide.
            Hide
            danblack Daniel Black added a comment -

            > I don't feel quite safe modifying exe_mysqld, it might happen that it's used somewhere else.

            It was a local variable that wasn't used again.

            > On the other hand, there seems no good reason to match the line with the complete path to mysqld, it should be enough to start with the file name, something like:

            It can get the incorrect version if a exe_mysql contains for example "/test/mysqld Ver 5.6.5/mariadb-5.5-5.5.32+maria/builddir/sql/mysqld"

            Show
            danblack Daniel Black added a comment - > I don't feel quite safe modifying exe_mysqld, it might happen that it's used somewhere else. It was a local variable that wasn't used again. > On the other hand, there seems no good reason to match the line with the complete path to mysqld, it should be enough to start with the file name, something like: It can get the incorrect version if a exe_mysql contains for example "/test/mysqld Ver 5.6.5/mariadb-5.5-5.5.32+maria/builddir/sql/mysqld"
            Hide
            elenst Elena Stepanova added a comment -

            You are right of course, sorry, blame late night for that. Assigning back to myself to take another look.

            Show
            elenst Elena Stepanova added a comment - You are right of course, sorry, blame late night for that. Assigning back to myself to take another look.
            Hide
            elenst Elena Stepanova added a comment -

            Hi Sergei,

            See the original suggestion by Daniel here: https://mariadb.atlassian.net/browse/MDEV-4977?focusedCommentId=34410&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-34410 .

            If the standard installation procedure creates a path which is not further recognized by MTR, I think it should be fixed.

            Show
            elenst Elena Stepanova added a comment - Hi Sergei, See the original suggestion by Daniel here: https://mariadb.atlassian.net/browse/MDEV-4977?focusedCommentId=34410&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-34410 . If the standard installation procedure creates a path which is not further recognized by MTR, I think it should be fixed.
            Hide
            danblack Daniel Black added a comment -

            Patch added for clarity

            Show
            danblack Daniel Black added a comment - Patch added for clarity
            Hide
            danblack Daniel Black added a comment -

            Nice use of \Q\E in regex, thanks Sergei

            Show
            danblack Daniel Black added a comment - Nice use of \Q\E in regex, thanks Sergei

              People

              • Assignee:
                serg Sergei Golubchik
                Reporter:
                danblack Daniel Black
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 5 minutes
                  5m