Add mutex around resultset reference counter