[PLAT-3561, PLAT-3562] Make batch writer more robus