TT#38822 helper/sync-db: ngcp.timezone sync changes

* ngcp.timezone table is not updated if
      new timezone=old timezone
    * ngcp.timezone change is not replicated to
      preserve stability of the other (active) node
      and to address the replication issue during upgrade

Change-Id: Id8f7b291c188792a33093ac3ed706b55d1b0a654
changes/66/22066/2
Kirill Solomko 8 years ago
parent 696ac4c247
commit c3f54e65cf

@ -160,25 +160,41 @@ sub sync_smsc_peers {
sub sync_general_timezone {
my $dbh = shift;
my $tz = shift;
my $ok = 1;
my $pe = $dbh->{PrintError};
my ($sql_log_bin) = $dbh->selectrow_array('SELECT @@sql_log_bin');
unless ($tz) {
print "Error: general.timezone value is not set\n";
return;
}
eval {
die "Error: general.timezone value is not set\n" unless $tz;
my $pe = $dbh->{PrintError};
$dbh->{PrintError} = 0;
$dbh->do(<<SQL, undef, $tz, $tz);
$dbh->do("SET sql_log_bin=0");
$dbh->{PrintError} = 0;
my ($current_tz) = $dbh->selectrow_array(<<SQL);
SELECT name FROM ngcp.timezone
SQL
if ($DBI::err) {
die "Error: Could not select from ngcp.timezone: $DBI::errstr\n";
}
return $ok if $current_tz && $current_tz eq $tz;
$dbh->do(<<SQL, undef, $tz, $tz);
INSERT INTO ngcp.timezone SET name = ?
ON DUPLICATE KEY UPDATE name = ?, modified_at = CURRENT_TIMESTAMP
SQL
$dbh->{PrintError} = $pe;
if ($DBI::err) {
print "Error: Could not insert into ngcp.timezone: $DBI::errstr\n";
return;
if ($DBI::err) {
die "Error: Could not insert into ngcp.timezone: $DBI::errstr\n";
}
};
if ($@) {
print $@;
$ok = 0;
}
$dbh->{PrintError} = $pe;
$dbh->do("SET sql_log_bin=$sql_log_bin");
return 1;
return $ok;
}
## /usr/share/zoneinfo into MariaDB ##############################

Loading…
Cancel
Save