The default flushes and syncs the log on every commit, which is the only setting that survives an operating system crash without losing transactions.
-- 1: flush and sync on every commit. no loss. slowest.
-- 2: flush on commit, sync once a second. survives a
-- MySQL crash, loses ~1s on an OS crash.
-- 0: flush and sync once a second. loses ~1s on either.
SET GLOBAL innodb_flush_log_at_trx_commit = 2;
-- and the pairing that is often missed:
SET GLOBAL sync_binlog = 1; -- or replication can diverge
Setting this to 2 is a legitimate decision for a system where a second of lost writes is acceptable, and it must be a decision rather than a tuning-guide copy — the person who can accept it is not usually the person editing the configuration. sync_binlog governs a different file and setting one without the other produces a replica that can be ahead of a recovered primary.