core: fix problem where z_db:insert can hang when running out of db connections.