fix mongo write overflow stack