Fix a regression from the MariaDB change that broke course archival procedures if the DBD:mysql driver is used#1284
Conversation
b65eadf to
67d8c5f
Compare
Std.pm. The code in sql_single.pm is modified in the same way for consistency (althought that wasn't broken). The modification is to always use the new parsing of the DSN string regardless of the DBD driver used.
0527485 to
b59c29f
Compare
b59c29f to
b4526e4
Compare
much more like the method used in the _OdbcParse method used before). This allows for things like `dbi:MariaDB:database=webwork;mariadb_socket=/var/run/mysqld/mysqld.conf` which Ubuntu 18.04 will need to use the cpan DBD::MariaDB package due to a bug in the mariadb_config output.
b4526e4 to
3ba4640
Compare
|
I can test, but not sure what to test. |
|
It seems like from the title if |
|
@taniwallach: I modified the parsing of @Alex-Jordan: Yes, it is a regression from #1160. It only affects archiving courses if you are using the DBD::mysql database driver, or if you are using the DBD:MariaDB driver and have to add something like the mariadb_socket option in my comment above. @pstaabp: Select |
|
It would probably also be good to check that you can also archive a course using |
|
In to Trying to archive a course, I get the error: Note: the line number should be lower, because I dumped out the $dsn variable as: "dbi:mysql:webwork" |
|
That |
|
@pstaabp: What do you have in site.conf for |
|
Not sure where that came from. The new code builds up the I was able to archive using both mysql and MariaDB. I didn't select the socket though. Should I? |
|
@pstaabp: You probably don't need to mess with the socket. Those using webwork on Ubuntu 18.04 with the MariaDB driver probably will need that, but Ubuntu 20.04 does not. |
pstaabp
left a comment
There was a problem hiding this comment.
This fixes the archive problem using mysql.
|
I think the changes are good, and also will support additional DSN settings in the I have tried to trigger the bug inside a Docker setup which is running the WeBWorK-2.16 branch, and the code in I set near the top of when I make an archive, but the archive file was created, where for @drgrice1 it fails. Maybe the problem only really occurs for without a |
taniwallach
left a comment
There was a problem hiding this comment.
This certainly fixes the bug where a match was used instead of a substitution, which seems to have triggered a bug in some settings.
I tested with the modified version of lib/WeBWorK/DB/Schema/NewSQL/Std.pm in Docker using both database drivers, and it certainly works for me and I can archive a course with both drivers. However, I could do so before also.
I think this can be merged.
|
@pstaab - Were you able to trigger the error before the patch? In any case, this is certainly better than the old code, so I think it should be merged ASAP. |
@taniwallach The only errors I had were self-inflected by changing things I shouldn't. I think this is good to go. |
|
Yes, this only happens when you use the perl -MDBD::mysql -e 'my %dsn; DBD::mysql->_OdbcParse("DBI:mysql:database=webwork", \%dsn, ["database", "host", "port"]); print join(", ", map { "$_ => $dsn{$_}"} keys %dsn). "\n"'compared to perl -MDBD::mysql -e 'my %dsn; DBD::mysql->_OdbcParse("DBI:mysql:database=webwork;host=db;port=3306", \%dsn, ["database", "host", "port"]); print join(", ", map { "$_ => $dsn{$_}"} keys %dsn). "\n"'The first returns This is because the while loop in _OdbcParse does the following: This is also why the method still works with |
|
The point is that the _OdbcParse method does not expect "DBI::driver" at the beginning of the dsn string. The substitution removed that before. Of course the match does not. |
|
@drgrice1 Thanks for the detailed explanation... I did realize at some point that only the shorter It is clear that the new code sets aside the leading We no longer allow "aliases" ( |
|
Yeah. It wouldn't be too hard to implement that if we still want that. |
I think we are better off sticking to a single standard, and making that clear in the release notes for anyone who wants to use a custom However, it is possible that some sites have a need for a custom
and I'm not sure if that was tested in terms of archiving courses. I suspect that archiving did not work with that in the prior code, but we can see how to handle that in the future, if we have a cloud DB to test with. We can then extend the standard for the WW |
|
That dsn would have worked with the _OdbcParse method (and will also work with the code implemented here with minor modification). However, the additional arguments would not (and still will not with the code implemented here) be passed on to the mysqldump command for course archiving. It would not be hard to pass those arguments along also by modifying to code that creates the |
This is just one sample of what sort of custom If I was certain what was needed for common "cloud DB" usage, I would say we should try to fix this before WW 2.16 is finalized, but I don't really know what is needed. I may be a bit wiser in a few weeks, as one of the Israeli institutions I am working with expressed interest in moving the database for their WW server to an AWS RDS database. However, I don't have any timeline on when they want to try that out.If and when I can test things out, I will look into what is needed. If someone already has suitable experience and resources for looking into this sooner - all the better. |
|
The point is that you could just pass along all of the arguments that are parsed out. For example, if the dsn is %dsn = {
database => 'webwork',
host => 'webwork-secure-do-user-3930413-0.db.ondigitalocean.com',
port => '25060',
mysql_ssl => '1',
mysql_ssl_ca_file => '/mnt/c/Users/Henry/Desktop/Perl/ca-certificate.crt'
}Then you pass all of those on to |
Fix course archival procedures (or anything that calls _get_db_info in Std.pm. The code in sql_single.pm is modified in the same way for consistency (althought that wasn't broken). The modification is to always use the new parsing of the DSN string regardless of the DBD driver used.