# Can't test this, because ConnectToDatabase uses the param, but
# we can't set this before testing....
return"";
}
&::SendSQL("SHOW DATABASES");
while(&::MoreSQLData()){
my$n=&::FetchOneColumn();
if(lc($n)eqlc($value)){
return"The $n database already exists. If that's really the name you want to use for the backup, please CAREFULLY make the existing database go away somehow, and then try again.";
}
}
# We trust the admin....
trick_taint($value);
&::SendSQL("CREATE DATABASE $value");
&::SendSQL("INSERT INTO shadowlog (command) VALUES ('SYNCUP')",1);
return"";
}
sub check_shadowdbhost{
if(!Param('shadowdbhost')){
my($value)=(@_);
return"You need to specify a host when using a shadow database";
if($value&&Param("updateshadowdb")){
return"Sorry, you can't have the shadowdb on a different connection to the main database if you want Bugzilla to handle the replication for you.";
}
}
# Can't test existance of this because ConnectToDatabase uses the param,
# but we can't set this before testing....
# This can really only be fixed after we can use the DBI more openly
return"";
return"";
}
}
...
@@ -271,50 +255,10 @@ sub check_netmask {
...
@@ -271,50 +255,10 @@ sub check_netmask {
},
},
{
{
name=>'queryagainstshadowdb',
desc=>'If this is on, and the <tt>shadowdb</tt> parameter is set, then '.
'certain queries will happen against the shadow database.',
type=>'b',
default=>0,
},
{
name=>'updateshadowdb',
desc=>'If this is on, and the <tt>shadowdb</tt> parameter is set, then '.
'Bugzilla will use the old style of shadow database in which it '.
'manually propogates changes to the shadow database. Otherwise, '.
'Bugzilla will assume that the <tt>shadowdb</tt> database (if '.
'any) is being updated via replication. <b>WARNING! This '.
'manual replication is deprecated and is going away soon '.
'(<u>BEFORE</u> the next stable Bugzilla release).</b> It has '.
'several problems with data consistency, and replication is the '.
'preferred option. If this parameter is on, and you disable it, '.
'make sure that the shadow database is already set up for '.
'replication, or queries will return stale data.',
type=>'b',
default=>1,
},
# This entry must be _after_ updateshadowdb, because check_shadowdbhost uses
# that
{
name=>'shadowdbhost',
name=>'shadowdbhost',
desc=>'The host the shadow database is on. If blank, then then we '.
desc=>'The host the shadow database is on.',
'assume it\'s on the main database host (as defined in '.
'localconfig) and ingore the <tt>shadowdbport</tt> and '.
'<tt>shadowdbsock</tt> parameters below, which means that this '.
'parameter <em>must be filled in</em> if your shadow database is '.
'on a different instance of the mysql server, even if that '.
'instance runs on the same machine as the main database. Note '.
'that <tt>updateshadowdb</tt> must be off if the shadow database '.
'is on a difference mysql instance, since Bugzilla can\'t '.
'propogate changes between instances itself, and this should be '.
'left blank if the shadow database is on the same instance, '.
'since Bugzilla can then reuse the same database connection for '.
'better performance.',
type=>'t',
type=>'t',
default=>'',
default=>'',
checker=>\&check_shadowdbhost,
},
},
{
{
...
@@ -346,11 +290,12 @@ sub check_netmask {
...
@@ -346,11 +290,12 @@ sub check_netmask {
{
{
name=>'shadowdb',
name=>'shadowdb',
desc=>'If non-empty, then this is the name of another database in '.
desc=>'If non-empty, then this is the name of another database in '.
'which Bugzilla will keep a shadow read-only copy of everything. '.
'which Bugzilla will use as a read-only copy of everything. '.
'This is done so that long slow read-only operations can be used '.
'This is done so that long slow read-only operations can be used '.
'against this db, and not lock up things for everyone else. '.
'against this db, and not lock up things for everyone else. This '.
'Turning on this parameter will create the given database ; be '.
'database is on the <tt>shadowdbhost</tt>, and must exist. '.
'careful not to use the name of an existing database with useful '.'data in it!',
'Bugzilla does not update it, if you use this paramater, then '.
'you need to set up replication for your database',
print"$dir does not exist or is not a directory. No syncing performed";
exit;
}
}elsif($opteq'-force'){
$force=1;
}elsif($opteq'--'){
# do nothing - null parameter so we can use
# multi-param system() call in globals.pl
}else{
Usage();
}
}
$|=1;
my$logtostderr=0;
sub Verbose($){
my($str)=(@_);
if($verbose){
if($logtostderr){
printSTDERR$str,"\n";
}else{
print$str,"\n";
}
}
}
if(!Param("shadowdb")){
Verbose("We don't have shadow databases turned on; no syncing performed.");
exit;
}
if(!Param("updateshadowdb")){
Verbose("This shadow database is not set to be updated by Bugzilla.\nSee the mysql replication FAQ if you want to pause the main db until the\nshadowdb catches up");
# I could run the commands here, but that involves keeping a connection
# open to the main db and the shadowdb at the same time, and our current
# db stuff doesn't support that. Its not sufficient to reconnect, because
# the lock on the main db will be dropped when the connection closes...
exit1;
}
if(Param("shutdownhtml")&&!$force){
Verbose("Bugzilla was shutdown prior to running syncshadowdb. \n".
" If you wish to sync anyway, use the -force command line option");
exit;
}
my$wasshutdown="";
if($shutdown){
Verbose("Shutting down bugzilla and waiting for connections to clear");
# Record the old shutdownhtml so it can be restored at the end (this will
# only be an issue if we are called using the -force command line param)
$wasshutdown=Param("shutdownhtml");
SetParam('shutdownhtml',$shutdown_msg);
WriteParams();
# Now we need to wait for existing connections to this database to clear. We
# do this by looking for connections to the main or shadow database using