My favorites | Sign in
Project Home Downloads Wiki Issues Source
New issue   Search
for
  Advanced search   Search tips   Subscriptions
Issue 342: Make mk-table-checksum work better with binlog-do-db
  Back to list
Status:  Duplicate
Merged:  issue 982
Owner:  ----
Closed:  Apr 2010


Sign in to add a comment
 
Project Member Reported by baron.schwartz, Apr 15, 2009
If a user has binlog-do-db=somedb, then checksumming through replication
will currently fail, because mk-table-checksum switches its database each
time it runs a checksum query:

4105 sub do_tbl_replicate {
4106    my ( $host, $query, $info, $chunk_num, $hdr, $explain, $final_opts
) = @_;
4107    MKDEBUG && _d("do_tbl_replicate for", $info->{table});
4108    my $dbh = $main_dbh;
4109    $dbh->do("USE " . $q->quote($info->{database}) );

This functionality has two purposes:

1) Most people who want to limit replication to only certain databases will
be well served by switching to that database to run the checksum query.
2) There was a bug in an older MySQL server (maybe it still exists?) that
caused something to fail with views or stored functions, unless the current
database was set to the same database as the function.  This bug caused a
failure even though mk-table-checksum does not touch those features.

However, I know of at least one real-life case where binlog-do-db=something
and the customer wants to replicate all databases.  To work right in this
case, we need to change the working database to that database, and not move
away from it after that.

To solve this, we need

1) a check for binlog-do-db (in SHOW MASTER STATUS).  If it's defined, we
should warn if checksumming a database that isn't mentioned.
2) a check for binlog-ignore-db.  Ditto, but the reverse.
3) both of the above should be enabled through a single option that can be
negated.
4) an option, enabled by default, that says "use the database you're
checksumming" which will permit the above code snippet to run.
5) a --database|D option that will set the default database when each
connection is opened.
6) tests for all these scenarios, of course.

Then, the documentation should explain that you have to set -D, set
--no-check-do-ignore-db (or whatever we call it), and set
--no-use-table-database (or whatever we call it) to make checksumming work
in the mentioned scenario.
Apr 15, 2009
Project Member #1 baron.schwartz
The workaround is to manually edit mk-table-checksum and change line 4109 to

4109    $dbh->do("USE somedb");
Aug 29, 2009
#2 dan...@percona.com
 Issue 428  has been merged into this issue.
Aug 29, 2009
#3 dan...@percona.com
This is similar to  issue 533 , except that issue deals with replicate-do-db.
Jan 31, 2010
Project Member #4 baron.schwartz
(No comment was entered for this change.)
Labels: Tag-defaultdb Tag-replication
Mar 23, 2010
#5 dan...@percona.com
(No comment was entered for this change.)
Labels: -Priority-Medium Effort-Moderate Benefit-Minimal
Apr 28, 2010
Project Member #6 baron.schwartz
Even though this issue is older, I'm going to mark it a dupe of 982, because that one
was reported by a user, and there is more and better discussion on it.
Status: Duplicate
Mergedinto: 982
Sign in to add a comment

Powered by Google Project Hosting