Given a batch of 100 books, and 100 threads, with 1 book per thread and 1 transaction per book (that could potentially rollback):
How can you safely insert those books into a MySQL table with a guarantee that each book is given an auto incrementing "local id" (i.e, "1001, 1002, ..." without gaps (remember they can potentially rollback).
Example Schema for books
id | account_id | book_title | book_author | local_id
6 12 Asdf Jkl; 1000
82 12 John Jane 1001