MariaDB Out-of-Order Parallel Replication and OPTIMIZE TABLE
Anti-OPTIMIZE
If you are using InnoDB (which you should be using), then OPTIMIZE TABLE is almost totally useless.  Stop running that.
If you are DELETEing huge chunks of a table, and that led you to want to OPTIMIZE, then let's discuss alternatives.
Replication issues
It is possible to avoid replicating any command(s):
 SET SESSION binlog = OFF;   -- I forget the details
 OPTIMIZE TABLE ...;
 SET ...   -- restore replication

But it seems like you would want to OPTIMIZE on the Slaves, where you are doing SELECTs?
If you have a graceful way to take a Slave out of rotation, you could do a &quot;rolling&quot; OPTIMIZE across the slaves, one at a time.
ANALYZE
If the goal is to refresh the &quot;statistics&quot;, then ANALYZE TABLE is much faster, hence less intrusive.
PARTITION
If &quot;old&quot; data is being purged, then Partitioning is much faster than DELETE, and has no need for OPTIMIZE; should we discuss that?