r/mysql • u/Fine-Willingness-486 • Jul 23 '25
question Stuck in Hell!!! Pls help
I work for a small firm. We have a Primary Secondary Setup of Mysql Server 8.0. System Info: Memory: 32Gb Disk: 50Gb
There are just 4 tables with large amounts of data, which have high quantum of transactions around 2.5k - 3k TPM. All the data in the tables gets replaced with new data around 3 - 5 times a day.
From the last six months, we are encountering an issue were the Primary Server just stops performing any transactions and all the processes/transactions keep waiting for commit handler. We fine tuned many configurations but none have came to our rescue. Everytime the issue occurs, there is drop in System IOPS/ Memory to disk (Writes / Read) and they stay the same. It seems like mysql stops interacting with the disk.
We always have to restart the server to bring it back to healthy state. This state is maintained from either 1½ to 2 days and the issue gets triggered.
We have spent sleepless nights, debugging the issue for last 6 months. We havent found any luck yet.
Thanks in advance.
Incase any info is required, do let me know in comments
5
u/dozensofwolves Jul 23 '25
I'm not a mysql guy but could it be a binary log issue? If you're running 3-5 massive transactions every day it could be filling up the log too fast.
3
u/bchambers01961 Jul 23 '25
Could it be a storage issue? Maybe run iostat during a period of high load to see if there’s an io bottleneck.
2
u/eroomydna Jul 23 '25
Can you share your configuration file? Perhaps you’re having flushing issues because of under provisioned memory allocations.
1
u/photo-nerd-3141 Jul 23 '25
You need to check disk space for logs, data. Also need to check the tables' free space.
This could also be caused by a deadlock or competing locks not timing out.
1
u/ZGTSLLC Jul 23 '25
I noticed this has not been asked, so what OS are you hosting MySQL on? Is it cloud-based or local server? Have you checked the network connection / card / Ethernet cable? Made sure the port is not trying to be used by any other service during that time, or that there are no cron jobs that are trying to run on the server that hosts MySQL? So many things could be impeding your setup...I hope you can get to the root cause...check your log-data, it should give you an idea of what you need to do next....
1
u/jericon Mod Dude Jul 24 '25
Based on the limited information, if this is an innodb database, look into tuning your io capacity and log file size.
When the innodb redo log gets full, it will stop all activity in the server until it can flush enough of the dirty pages to disk to free sufficient log space.
The log used in the case of a crash if changes written to memory were not yet flushed to disk. Likewise. Tuning the io capacity properly can allow MySQL to flush more to the disk.
A 50 gb disk sounds like OLD hardware too. Upgrade that. Throw in 4 ssd’s and run raid 10 on it.
1
u/Beautiful_Resist_655 Jul 24 '25
What is the logic for replacing the data every few hours. How exactly are you doing that, with truncate data and then load. How is the load being done.
1
u/mnavarrocarter Jul 26 '25
A lot of IOPS is normal if you are writing that amount of data that often. What's the reasoning behind that? Maybe there is a better way to reach your end goal than rewriting your data all the time. Just curious.
What's not normal is the server crashing. Can you tell me more about the kinds of records, what are the indexes, what are the data types on those indexes, etc.
Databases usually have to perform IO on insertion if you are getting a lot of cache misses in the buffer pool. When you insert a record in an index, database has to find the node where to insert it in the B-Tree, and if you have unordered values on the index your buffer pool will fill pretty fast and will have to go to disk to read index pages. And this will happen if A your buffer pool is too small or B you have poor index locality (you are using random uuids or other unordered data in indexes). So what's the size of your buffer pool?
Also, it would help if you can collect some metrics. Observability is crucial for these kinds of issues, otherwise any debugging you can do is just guessing. Datadog or Prometheus agents should be quite easy to install. I would look at
innodb.buffer_readsandinnodb.buffer_reads_requested1
u/Serious_Chocolate_17 Jul 26 '25
Hmm that number of transactions per minute should be fine. We have that many running per second, although I understand that each use case is different and your transactions may be huge.
I recommend installing Percona management (PMM). It's super helpful in understanding what's going on.
What isolation mode are these running in?
3
u/climbcolorado Jul 24 '25
Install Percona Monitoring and Management (PMM) as it will collect a very useful amount of data. Should help you find anything that is out of whack in the environment and also let you look at all the queries to check for locking or poor index.
If it’s innodb - I would check the innodb re-do log size. Sounds like you might be hitting the limit where the innodb engine doesn’t have enough space to undo it leading to the whole engine locking up. Pretty common with big tables and can lead to stuns of IO when it gets full and flushes constantly.
1
u/Nuoji Jul 25 '25
What does your monitoring software say? Something like JetProfiler (shameless plug) should be able to help you pinpoint what happens right before the issues commence (JP has a free version that probably is enough to help, DM me and I can get you a trial version otherwise)
1
u/IndependenceLife2126 Jul 26 '25
I don't know your process but are you...
Suggest reviewing your processes. Create a new table space and load data. Drop the old table and then rename the new table to the old table name.
Should speed up by having a new IO pointer to the new table file binary. Basically dividing the load.
1
u/GrassSpiritual6206 Jul 27 '25
Could it be a deadlock?
1
u/AppropriateSpell5405 Jul 28 '25
Sounds like you just have a deadlock.
1
u/Itchy-Call-8727 Jul 28 '25 edited Jul 28 '25
I read a few comments, and something that wasn't brought up was the system backup. Is the system being backed up by any software? I have seen some backup systems like Veem completely "stun" a VM and make the service unreachable. If you read the docs on GCP, it says a snapshot can even cause this stun issue, and that it is recommended to take a snapshot off-hours. Since the disk size is 50 GB, it sounds like a VM.
Depending on how dumps are run that can also cause the data to be inaccessible until complete. I would look into the current backup schedule and if dumps are run, the command being used since it might be able to be optimised to resolve this problem. If you are recreating the table data several times a day that's going to cause a large time for the backup process to complete.
Some other solutions that might solve your problem: do not rewrite the table data if possible. Create a new database using a naming convention and push to the new DB, and cycle out older versions off-hours. Or you could create tables and use an index lookup for what the current data is, then drop old tables off hours.
1
u/tsgiannis Jul 28 '25
Usually bizarre issues have simple causes. While is a long shot I would recommend a hard memory test and some disk testing
0
u/[deleted] Jul 23 '25
[deleted] — view deleted comment