Query:
SELECT COUNT(online.account_id) cnt from online;
But online table is also modified by an event, so frequently I can see lock by runn
SELECTs do not normally do any locking that you care about on InnoDB tables. The default transaction isolation level means that selects don't lock stuff.
Of course contention still happens.