AsyncWriteEngine: fix some potential problems.
AsyncWriteEngine: fix some potential problems.

morfeo8marc/mapdb,pettermahlen/mapdb,SleimanJneidi/mapdb,jankotek/mapdb,sumit784/mapdb,jankotek/MapDB,cocosli/mapdb,hangum/mapdb,jankotek/mapdb,binarytemple/mapdb,codeaudit/mapdb,ffjiao/mapdb,lamfire/mapdb,jankotek/MapDB,ringoluo/mapdb