even if you deploy your application in a Servlet or EJB container, there are still compelling reasons to use Shiro's Session support instead of the container's
However, those locks limit concurrency and scalability when
multiple transactions are executing insert statements at the
same time
For INSERT statements where the
number of rows to be inserted is known at the beginning of
processing the statement, InnoDB quickly
allocates the required number of auto-increment values without
taking any lock, but only if there is no concurrent session
already holding the table-level AUTO-INC lock
(because that other statement will be allocating auto-increment
values one-by-one as it proceeds)
obtains
auto-increment values under the control of a mutex (a
light-weight lock) that is not held until
the statement completes, but only for the duration of the
allocation process
recovery scenarios when SQL statements are
replayed from the binary log
Using auto-increment with replication
set
innodb_autoinc_lock_mode to
0 or 1 and use the same value on the master and its slaves
Auto-increment values are not ensured to be the same on the
slaves as on the master if you use
innodb_autoinc_lock_mode =
2 (“interleaved”) or configurations where the
master and slaves do not use the same lock mode