Making sec grp auth and DB write atomic