TT#190250 switch replication binlog_format

IODKU statements can fail for master-master replication.
switching to 'STATEMENT' binlog_format to mitigate.

Change-Id: I5e7d2438c6338e6cc7b17bf9c51a8a4712f72454
mr11.2
Rene Krenn 3 years ago
parent 444873813a
commit cf6b9b75c4

@ -288,6 +288,7 @@ sub connect_billdbh {
FATAL "Error connecting to db: ".$DBI::errstr
unless defined($billdbh);
$billdbh->do('SET time_zone = ?',undef,$connection_timezone) or FATAL 'error setting connection timezone' if $connection_timezone;
$billdbh->do("SET SESSION binlog_format = 'STATEMENT'") or FATAL 'error setting session binlog_format';
INFO "Successfully connected to billing db...";
}
@ -302,6 +303,7 @@ sub connect_acctdbh {
FATAL "Error connecting to db: ".$DBI::errstr
unless defined($acctdbh);
$acctdbh->do('SET time_zone = ?',undef,$connection_timezone) or FATAL 'error setting connection timezone' if $connection_timezone;
$acctdbh->do("SET SESSION binlog_format = 'STATEMENT'") or FATAL 'error setting session binlog_format';
INFO "Successfully connected to accounting db...";
}
@ -322,6 +324,7 @@ sub connect_provdbh {
FATAL "Error connecting to db: ".$DBI::errstr
unless defined($provdbh);
$provdbh->do('SET time_zone = ?',undef,$connection_timezone) or FATAL 'error setting connection timezone' if $connection_timezone;
$provdbh->do("SET SESSION binlog_format = 'STATEMENT'") or FATAL 'error setting session binlog_format';
INFO "Successfully connected to provisioning db...";
}
@ -342,6 +345,7 @@ sub connect_dupdbh {
FATAL "Error connecting to db: ".$DBI::errstr
unless defined($dupdbh);
$dupdbh->do('SET time_zone = ?',undef,$connection_timezone) or FATAL 'error setting connection timezone' if $connection_timezone;
$dupdbh->do("SET SESSION binlog_format = 'STATEMENT'") or FATAL 'error setting session binlog_format';
INFO "Successfully connected to duplication db...";
}
@ -712,13 +716,13 @@ EOS
) or FATAL "Error preparing get contract balance statement: ".$billdbh->errstr;
$sth_new_cbalance = $billdbh->prepare(
"INSERT INTO billing.contract_balances (".
"INSERT IGNORE INTO billing.contract_balances (".
" contract_id, cash_balance, initial_cash_balance, cash_balance_interval, free_time_balance, initial_free_time_balance, free_time_balance_interval, underrun_profiles, underrun_lock, start, end".
") VALUES (?, ?, ?, ?, ?, ?, ?, IF(? = 0, NULL, FROM_UNIXTIME(?)), IF(? = 0, NULL, FROM_UNIXTIME(?)), FROM_UNIXTIME(?), FROM_UNIXTIME(?))"
) or FATAL "Error preparing create contract balance statement: ".$billdbh->errstr;
$sth_new_cbalance_infinite_future = $billdbh->prepare(
"INSERT INTO billing.contract_balances (".
"INSERT IGNORE INTO billing.contract_balances (".
" contract_id, cash_balance, initial_cash_balance, cash_balance_interval, free_time_balance, initial_free_time_balance, free_time_balance_interval, underrun_profiles, underrun_lock, start, end".
") VALUES (?, ?, ?, ?, ?, ?, ?, IF(? = 0, NULL, FROM_UNIXTIME(?)), IF(? = 0, NULL, FROM_UNIXTIME(?)), FROM_UNIXTIME(?), '9999-12-31 23:59:59')"
) or FATAL "Error preparing create contract balance statement: ".$billdbh->errstr;
@ -797,7 +801,7 @@ EOS
"SELECT id,value FROM provisioning.voip_usr_preferences WHERE attribute_id = ? AND subscriber_id = ?"
) or FATAL "Error preparing get usr preference value statement: ".$provdbh->errstr;
$sth_create_usr_preference_value = $provdbh->prepare(
"INSERT INTO provisioning.voip_usr_preferences (subscriber_id, attribute_id, value) VALUES (?, ?, ?)"
"INSERT IGNORE INTO provisioning.voip_usr_preferences (subscriber_id, attribute_id, value) VALUES (?, ?, ?)"
) or FATAL "Error preparing create usr preference value statement: ".$provdbh->errstr;
$sth_update_usr_preference_value = $provdbh->prepare(
"UPDATE provisioning.voip_usr_preferences SET value = ? WHERE id = ?"
@ -3672,7 +3676,7 @@ sub main {
next CDR;
}
# required to avoid contract_balances duplications during catchup:
begin_transaction($billdbh,'READ COMMITTED');
begin_transaction($billdbh); #,'READ COMMITTED');
# row locks are released upon commit/rollback and have to cover
# the whole transaction. thus locking contract rows for preventing
# concurrent catchups will be our very first SQL statement in the

Loading…
Cancel
Save