Since MongoDB 3.6, drivers are supposed to automatically retry writes once on network errors or elections. The server deduplicates using the session's transaction number, so it's safe.
Different from failover retry (#2850) — this is a session-level mechanism that the server coordinates, not just topology re-selection.
Requires sessions. #2854