fix race condition during sync read/write