From 1a92d0b7d5e4f98b3c700e88f94d427be1e36be8 Mon Sep 17 00:00:00 2001 From: Kirill Solomko Date: Wed, 6 May 2026 16:00:51 +0200 Subject: [PATCH] MT#65050 add stats.call_info site_id column * the column is needed to separate the date per site, when multi site is enabled, as well as to solve possible replication issues when mediators on each site concurrently write into the table concurrently. Change-Id: Iba46ac1bcb7d635fade3896f6e2b04b3396058e8 --- db_scripts/diff/15885.down | 6 ++++++ db_scripts/diff/15885.up | 6 ++++++ schema/ngcp.sql | 3 ++- schema/stats.json | 40 ++++++++++++++++++++++++++++++-------- schema/stats.sql | 3 ++- 5 files changed, 48 insertions(+), 10 deletions(-) create mode 100644 db_scripts/diff/15885.down create mode 100644 db_scripts/diff/15885.up diff --git a/db_scripts/diff/15885.down b/db_scripts/diff/15885.down new file mode 100644 index 00000000..dc17725f --- /dev/null +++ b/db_scripts/diff/15885.down @@ -0,0 +1,6 @@ +USE stats; + +ALTER TABLE stats.call_info + DROP KEY `call_info_site_sip_code_period_idx`, + ADD UNIQUE KEY `call_info_sip_code_period_idx` (`sip_code`,`period`), + DROP COLUMN `site_id`; diff --git a/db_scripts/diff/15885.up b/db_scripts/diff/15885.up new file mode 100644 index 00000000..58070413 --- /dev/null +++ b/db_scripts/diff/15885.up @@ -0,0 +1,6 @@ +USE stats; + +ALTER TABLE stats.call_info + ADD `site_id` int(2) unsigned DEFAULT 1, + DROP KEY `call_info_sip_code_period_idx`, + ADD UNIQUE KEY `call_info_site_sip_code_period_idx` (`site_id`,`sip_code`,`period`); diff --git a/schema/ngcp.sql b/schema/ngcp.sql index 41684d39..cbb02e2f 100644 --- a/schema/ngcp.sql +++ b/schema/ngcp.sql @@ -25,7 +25,7 @@ CREATE TABLE `db_schema` ( PRIMARY KEY (`id`), UNIQUE KEY `rev_idx` (`revision`,`node`,`site_id`), KEY `release_idx` (`release`) -) ENGINE=InnoDB AUTO_INCREMENT=928 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; +) ENGINE=InnoDB AUTO_INCREMENT=929 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8mb4 */; @@ -30980,6 +30980,7 @@ INSERT INTO `db_schema` VALUES (924,15879,'spce','1970-01-01 00:00:01','trunk',1 INSERT INTO `db_schema` VALUES (925,15880,'spce','1970-01-01 00:00:01','trunk',1); INSERT INTO `db_schema` VALUES (926,15881,'spce','1970-01-01 00:00:01','trunk',1); INSERT INTO `db_schema` VALUES (927,15884,'spce','1970-01-01 00:00:01','trunk',1); +INSERT INTO `db_schema` VALUES (928,15885,'spce','1970-01-01 00:00:01','trunk',1); COMMIT; SET AUTOCOMMIT=@OLD_AUTOCOMMIT; SET @OLD_AUTOCOMMIT=@@AUTOCOMMIT, @@AUTOCOMMIT=0; diff --git a/schema/stats.json b/schema/stats.json index ff5cc12b..d579db5a 100644 --- a/schema/stats.json +++ b/schema/stats.json @@ -48,6 +48,18 @@ "TABLE_NAME" : "call_info", "key_col" : "call_info/sip_code" }, + "call_info/site_id" : { + "CHARACTER_SET_NAME" : null, + "COLLATION_NAME" : null, + "COLUMN_DEFAULT" : "1", + "COLUMN_NAME" : "site_id", + "COLUMN_TYPE" : "int(2) unsigned", + "EXTRA" : "", + "IS_NULLABLE" : "YES", + "ORDINAL_POSITION" : 5, + "TABLE_NAME" : "call_info", + "key_col" : "call_info/site_id" + }, "cdr_info/customer_cost" : { "CHARACTER_SET_NAME" : null, "COLLATION_NAME" : null, @@ -279,29 +291,41 @@ "TABLE_NAME" : "call_info", "key_col" : "call_info/PRIMARY/1" }, - "call_info/call_info_sip_code_period_idx/1" : { + "call_info/call_info_site_sip_code_period_idx/1" : { + "COLLATION" : "A", + "COLUMN_NAME" : "site_id", + "INDEX_NAME" : "call_info_site_sip_code_period_idx", + "INDEX_TYPE" : "BTREE", + "NON_UNIQUE" : 0, + "NULLABLE" : "YES", + "SEQ_IN_INDEX" : 1, + "SUB_PART" : null, + "TABLE_NAME" : "call_info", + "key_col" : "call_info/call_info_site_sip_code_period_idx/1" + }, + "call_info/call_info_site_sip_code_period_idx/2" : { "COLLATION" : "A", "COLUMN_NAME" : "sip_code", - "INDEX_NAME" : "call_info_sip_code_period_idx", + "INDEX_NAME" : "call_info_site_sip_code_period_idx", "INDEX_TYPE" : "BTREE", "NON_UNIQUE" : 0, "NULLABLE" : "", - "SEQ_IN_INDEX" : 1, + "SEQ_IN_INDEX" : 2, "SUB_PART" : null, "TABLE_NAME" : "call_info", - "key_col" : "call_info/call_info_sip_code_period_idx/1" + "key_col" : "call_info/call_info_site_sip_code_period_idx/2" }, - "call_info/call_info_sip_code_period_idx/2" : { + "call_info/call_info_site_sip_code_period_idx/3" : { "COLLATION" : "A", "COLUMN_NAME" : "period", - "INDEX_NAME" : "call_info_sip_code_period_idx", + "INDEX_NAME" : "call_info_site_sip_code_period_idx", "INDEX_TYPE" : "BTREE", "NON_UNIQUE" : 0, "NULLABLE" : "", - "SEQ_IN_INDEX" : 2, + "SEQ_IN_INDEX" : 3, "SUB_PART" : null, "TABLE_NAME" : "call_info", - "key_col" : "call_info/call_info_sip_code_period_idx/2" + "key_col" : "call_info/call_info_site_sip_code_period_idx/3" }, "cdr_info/PRIMARY/1" : { "COLLATION" : "A", diff --git a/schema/stats.sql b/schema/stats.sql index 553b8677..7e757d9c 100644 --- a/schema/stats.sql +++ b/schema/stats.sql @@ -13,8 +13,9 @@ CREATE TABLE `call_info` ( `sip_code` varchar(3) NOT NULL, `period` datetime NOT NULL, `amount` int(11) unsigned NOT NULL, + `site_id` int(2) unsigned DEFAULT 1, PRIMARY KEY (`id`), - UNIQUE KEY `call_info_sip_code_period_idx` (`sip_code`,`period`) + UNIQUE KEY `call_info_site_sip_code_period_idx` (`site_id`,`sip_code`,`period`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */;