I get confused with the terminology such as flushing and writing to disk and synchronising to the disk. Could someone please explain me what is the difference between flushing and writing and synchronising to disk especially in context of MySQL.
I used to think that they are both the same operations, but while reading various concepts it confuses me.
For example. The documentation says for rpl_semi_sync_source_wait_point variable that if I set it to AFTER_SYNC then the source writes transactions to bin log and replica first and then syncs the binlog to disk.
AFTER_SYNC (the default): The source writes each transaction to its binary log and the replica, and syncs the binary log to disk.
This statement is itself confusing. First it says source writes each transaction to its binary log and the replica
and then it says syncs the binary log to disk.
So what exactly is happening in this case. What exactly is flushing, syncing and writing to the disk in the context of MySQL? The question is not about sync_binlog or any other parameter in MySQL. The question is about flushing, syncing and writing and about when do these activities happen?
Again when I tried to read more, in the following link, it explains that, there's a binlog cache, a page cache and an fsync operation. Thus, when a transaction happens, if I understand correctly, the buffer is made dirty, the contents of the transaction are written to binlog cache (at MySQL level) which is separate cache for each session, then binlog cache is written to page cache (at Linux level) then depending upon sync_binlog
value, it is flushed/written/synced to the files on disk.
https://betterprogramming.pub/understanding-mysqls-binlog-4ac8de4d20ee