If there is an error while inserting the data in the database (in which case not all items will be inserted), this loop will go on forever, and this is bad; we need to account for that with either a timeout or some maximum retry count.