Out of Memory (OOM) Issues With Percona
Out of Memory (OOM) Issues With Percona in Percona Issues.
Out of Memory (OOM) Issues With Percona#
Case 1: Percona Undergoes OOM for a Specific Duration#
Solution:
To rectify the issue, refer to OOM Issues With Services
Case 2: Percona Failed to Start#
Percona failed to start, primarily due to an Out of Memory (OOM) condition.
High server utilization was noted, with most services running on the primary server.
Solution:
- Service Relocation:
- Shift the Signal detector and Event detector services to a secondary node.
- Update the respective consul keys and restart these services.
- Memory Allocation Adjustment:
- Acknowledge that the replication was not required, as confirmed by PD (Process Detection).
- Modify the percona.nomad script by removing fields related to percona-node 2 .
- Execute the nomad plan percona.nomad to apply the changes.
- Service Configuration:
- Configure Percona to run in stand-alone mode with the following settings:
- Service IP: 192.0.2.28
- Service Port: 3307
- Configure Percona to run in stand-alone mode with the following settings:
Percona will successfully start and operational in a stand-alone mode, addressing the memory constraints.
Case 3: High CPU and Memory Consumption#
Percona was experiencing frequent Out-Of-Memory (OOM) issues due to high CPU and memory consumption.
-
Fine-Tuning Redis Microservice: Update Consul Keys
Adjustments were made to fine-tune the Redis microservice, optimizing its performance. The following Consul keys were updated:
service/redismicroservice/scheduler/rateofexecution:600000 service/redismicroservice/threadpoolcoresize:200 service/redismicroservice/threadpoolmaxsize:200 service/redismicroservice/perconadb/idleconnections:50 service/redismicroservice/perconadb/maxpoolsize:100 service/redismicroservice/share/live/connection:false -
Query Execution in MySQL: Multiple queries to the command_audit_details table were found in an 'executing ' state, contributing to high CPU and memory consumption.
[root@1ef500b7a344 /]# mysqladmin proc | grep -i query +------+-----------------+---------------------+-------------------- ----+---------+------+-----------------------------+---------------- -------------------------------------------------------------------- ------------------+---------+-----------+---------------+ | Id | User | Host | db | Command | Time | State | Info | Time_ms | Rows_sent | Rows_examined | +------+-----------------+---------------------+-------------------- ----+---------+------+-----------------------------+---------------- -------------------------------------------------------------------- ------------------+---------+-----------+---------------+ | 968 | appsonedb | 192.0.2.29:53628 | appsone | Query | 1 | executing | select count(*) from command_audit_details where exit_status=0 and supervisor_identifier='d0475c22- | 1097 | 0 | 0 | | | 5845 | 0 | 0 | | 975 | appsonedb | 192.0.2.29:55208 | appsone | Query | 1 | executing | select count(*) from command_audit_details where exit_status=0 and supervisor_identifier='70552786- | 1101 | 0 | 0 | | 977 | appsonedb | 192.0.2.29:53766 | appsone | Query | 1 | executing | select count(*) from command_audit_details where exit_status=0 and supervisor_identifier='a18d963e- | 1097 | 0 | 0 | | 980 | appsonedb | 192.0.2.29:39218 | appsone | Query | 1 | executing | select count(*) from command_audit_details where exit_status=0 and supervisor_identifier='8c42b613- | 1100 | 0 | 0 | | 981 | appsonedb | 192.0.2.29:39228 | appsone | Query | 1 | executing | select count(*) from command_audit_details where exit_status=0 and supervisor_identifier='1bffef9d- | 1097 | 0 | 0 | | 982 | appsonedb | 192.0.2.29:39244 | appsone | Query | 1 | executing | select count(*) from command_audit_details where exit_status=0 and supervisor_identifier='d02b707e- | 1099 | 0 | 0 | | | 29473 | 0 | 0 | | 988 | appsonedb | 192.0.2.29:59882 | appsone | Query | 1 | executing | select count(*) from command_audit_details where exit_status=0 and supervisor_identifier='24c857a5- | 1088 | 0 | 0 | | 1383 | root | localhost | | Query | 0 | init | show processlist | 0 | 0 | 0 | +------+-----------------+---------------------+-------------------- ----+---------+------+-----------------------------+---------------- -------------------------------------------------------------------- ------------------+---------+-----------+---------------+
Solution:
Upon inspecting the command_audit_details and command_metadata_audit_details tables in Percona, it was observed that their row counts were excessively high. To address this, both tables were truncated.
Post-Resolution: Percona's resource utilization will return to normal levels and resolves the frequent OOM issues.
Data Replication Failure from Master Node to Slave#
Follow the below steps to detect Data Replication Failure from the Master Node to the Slave
Procedure:
-
Check slave status in percona node 2 (slave node) with the below command:
mysql> show slave status \G;Expected Output:
*************************** 1. row *************************** Slave_IO_State: Waiting for source to send event Master_Host: 192.0.2.30 Master_User: replicator Master_Port: 3306 Connect_Retry: 60 Master_Log_File: mysql-bin.000066 Read_Master_Log_Pos: 206528706 Relay_Log_File: server2-relay-bin.000051 Relay_Log_Pos: 6210487 Relay_Master_Log_File: mysql-bin.000066 Slave_IO_Running: No Slave_SQL_Running: No Replicate_Do_DB: Replicate_Ignore_DB: Replicate_Do_Table: Replicate_Ignore_Table: Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table: Last_Errno: 0 Last_Error: Skip_Counter: 0 Exec_Master_Log_Pos: 206528706 Relay_Log_Space: 41124938 Until_Condition: None Until_Log_File: Until_Log_Pos: 0 Master_SSL_Allowed: No Master_SSL_CA_File: Master_SSL_CA_Path: Master_SSL_Cert: Master_SSL_Cipher: Master_SSL_Key: Seconds_Behind_Master: 775460 Master_SSL_Verify_Server_Cert: No Last_IO_Errno: 0 Last_IO_Error: Last_SQL_Errno: 0 Last_SQL_Error: Replicate_Ignore_Server_Ids: Master_Server_Id: 1 Master_UUID: 1b021119-aba9-11ea-b0df-0242ac110004 Master_Info_File: mysql.slave_master_info SQL_Delay: 0 SQL_Remaining_Delay: NULL Slave_SQL_Running_State: Replica has read all relay log; waiting for more updates Master_Retry_Count: 86400 Master_Bind: Last_IO_Error_Timestamp: Last_SQL_Error_Timestamp: Master_SSL_Crl: Master_SSL_Crlpath: Retrieved_Gtid_Set: Executed_Gtid_Set: Auto_Position: 0 Replicate_Rewrite_DB: Channel_Name: Master_TLS_Version: Master_public_key_path: Get_master_public_key: 0 Network_Namespace: 1 row in set, 1 warning (0.00 sec)If the output shows the below fields as 'no ', this means the slave is not in a running state.
Slave_IO_Running: No
Slave_SQL_Running: No
-
If the slave is not running, run the below command:
mysql> reset slave;Expected Output: Query OK, 0 rows affected, 1 warning (0.01 sec)
Note: Please use this command only if the percona slave is down since the beginning. Otherwise, skip this command as using this command will start the slave sync from the very beginning and will take time.
-
Start the slave using the below command:
mysql> start slave user='replicator' password='<password>' default_auth='mysql_native_password';Expected Output: Query OK, 0 rows affected, 1 warning (0.02 sec)
-
Check the below parameter in the above slave status,
Seconds_Behind_Master: 775460
The above value means that node2 is still replicating data from node 1.
Wait for this parameter to become 0.
-
Restart the Redis microservice.
Stop service:
nomad stop redis microserviceStart service:
nomad start redis microservice -
If both of the below values are still 'no ' and the error code is displaying the status,
Slave_IO_Running: No
Slave_SQL_Running: No
Navigate to the below directory.
Appsone_Service/conf/PERCONA/my.cnfExpected Output:
# The MySQL server [mysqld] server_id = 2 event_scheduler = 0 tls_version=TLSv1.2,TLSv1.3 local-infile = 0 symbolic-links = 0 max_connections = 70 mysqlx_max_connections = 70 table_open_cache = 220 innodb_file_per_table # Added for percona replication log_bin = /var/lib/mysql/mysql-bin.log binlog_do_db = appsone binlog_do_db = appsonekeycloak binlog_do_db = appsone_mle # No MyISAM engines: reduced key_buffer_size # SRD 13-Feb key_buffer_size = 32M max_allowed_packet = 16M #query_cache_size = 128M #query_cache_limit = 100M join_buffer_size = 1M # These two parameters are used for TMP tables and MUST be the same size max_heap_table_size = 16M tmp_table_size = 16M slave-skip-errors = 1007,1396,1146,1062,1032,1060,1507,1045,1517 ## NETWORKINGAdd the below error code in my.cnf file under TMP tables section for all the nodes.
slave-skip-errors = {error codes in comma separated}For Example:
slave-skip-errors = 1007,1396,1146,1062,1032,1060,1507,1045,1517Expected output:
# The MySQL server [mysqld] server_id = 2 event_scheduler = 0 tls_version=TLSv1.2,TLSv1.3 local-infile = 0 symbolic-links = 0 max_connections = 70 mysqlx_max_connections = 70 table_open_cache = 220 innodb_file_per_table # Added for percona replication log_bin = /var/lib/mysql/mysql-bin.log binlog_do_db = appsone binlog_do_db = appsonekeycloak binlog_do_db = appsone_mle # No MyISAM engines: reduced key_buffer_size # SRD 13-Feb key_buffer_size = 32M max_allowed_packet = 16M #query_cache_size = 128M #query_cache_limit = 100M join_buffer_size = 1M # These two parameters are used for TMP tables and MUST be the same size max_heap_table_size = 16M tmp_table_size = 16M slave-skip-errors = 1007,1396,1146,1062,1032,1060,1507,1045,1517 ## NETWORKING -
Restart Percona by the below stop and start commands:
Stop percona
nomad stop perconaStart percona
nomad start percona -
Navigate to HEAL Percona server, under the below installation path,
a1home -
Set the value of the consul key as 1.
consul kv put service/percona/replication/status 1Expected Output:
Success! Data written to: service/percona/replication/status -
Start the percona service, using the below script,
sh startServices.sh PERCONAExpected Output:
[29-08-23 15:16:26]:[Info]:- [Starting Percona] Job registration successful Evaluation ID: da813670-3af3-a12b-e46d-c4fc346dcf8f [29-08-23 15:16:56]:[Info]:- [percona started successfully.] [29-08-23 15:16:56]:[Info]:- [Percona Started] [29-08-23 15:16:56]:[Info]:- [Percona is running in ha mode] [29-08-23 15:16:57]:[Info]:- [Enabling percona master slave replication between 192.0.2.19 and 192.0.2.21] [29-08-23 15:16:57]:[Info]:- [Updating server id in my.cnf] [29-08-23 15:16:57]:[Info]:- [Restarting percona] ==> 2023-08-29T15:16:57+05:30: Monitoring evaluation "2feca93e" 2023-08-29T15:16:57+05:30: Evaluation triggered by job "percona" 2023-08-29T15:16:58+05:30: Evaluation within deployment: "25147efe" 2023-08-29T15:16:58+05:30: Evaluation status changed: "pending" -> "complete" ==> 2023-08-29T15:16:58+05:30: Evaluation "2feca93e" finished with status "complete" ==> 2023-08-29T15:16:58+05:30: Monitoring deployment "25147efe" ! Deployment "25147efe" cancelled 2023-08-29T15:16:58+05:30 ID = 25147efe Job ID = percona Job Version = 0 Status = cancelled Description = Cancelled because job is stopped Deployed Task Group Desired Placed Healthy Unhealthy Progress Deadline percona-node1 1 1 1 0 2023-08- 29T15:26:57+05:30 percona-node2 1 1 0 0 2023-08- 29T15:26:26+05:30 Job registration successful Evaluation ID: 0f0556c8-75af-8cd7-5a03-5fcfcf4beac6 [29-08-23 15:17:08]:[Info]:- [Waiting till all instance of percona are started.] [29-08-23 15:17:38]:[Info]:- [percona started successfully.] -
Check the slave status by executing the below command:
mysql> show slave status \G;Expected Output:
*************************** 1. row *************************** Slave_IO_State: Waiting for source to send event Master_Host: 192.0.2.6 Master_User: replicator Master_Port: 3306 Connect_Retry: 60 Master_Log_File: mysql-bin.000066 Read_Master_Log_Pos: 206528706 Relay_Log_File: server2-relay-bin.000051 Relay_Log_Pos: 6210487 Relay_Master_Log_File: mysql-bin.000066 Slave_IO_Running: No Slave_SQL_Running: No Replicate_Do_DB: Replicate_Ignore_DB: Replicate_Do_Table: Replicate_Ignore_Table: Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table: Last_Errno: 0 Last_Error: Skip_Counter: 0 Exec_Master_Log_Pos: 206528706 Relay_Log_Space: 41124938 Until_Condition: None Until_Log_File: Until_Log_Pos: 0 Master_SSL_Allowed: No Master_SSL_CA_File: Master_SSL_CA_Path: Master_SSL_Cert: Master_SSL_Cipher: Master_SSL_Key: Seconds_Behind_Master: 775440 Master_SSL_Verify_Server_Cert: No Last_IO_Errno: 0 Last_IO_Error: Last_SQL_Errno: 0 Last_SQL_Error: Replicate_Ignore_Server_Ids: Master_Server_Id: 1 Master_UUID: 1b021119-aba9-11ea-b0df-0242ac110004 Master_Info_File: mysql.slave_master_info SQL_Delay: 0 SQL_Remaining_Delay: NULL Slave_SQL_Running_State: Replica has read all relay log; waiting for more updates Master_Retry_Count: 86400 Master_Bind: Last_IO_Error_Timestamp: Last_SQL_Error_Timestamp: Master_SSL_Crl: Master_SSL_Crlpath: Retrieved_Gtid_Set: Executed_Gtid_Set: Auto_Position: 0 Replicate_Rewrite_DB: Channel_Name: Master_TLS_Version: Master_public_key_path: Get_master_public_key: 0 Network_Namespace: 1 row in set, 1 warning (0.00 sec)In the above post service started successfully, check the below parameter:
Seconds_Behind_Master: 775440
It means that node 2 is still replicating data from node 1.
Wait for this parameter to become 0.
-
Restart the Redis microservice.
Stop Redis
nomad stop redis
Start Redis
nomad start redis