In the standard versioning service, the version incrementing is based on the last version extraction.
In the SQL core storage, the last version is identified by sorting the version series on the created version attribute. In case of multiple version being created at the same time, the version id is random and could harm the application.
The caller is at org.nuxeo.ecm.core.versioning.StandardVersioningService.doCheckOut(Document) and the wrong implementation is at org.nuxeo.ecm.core.storage.sql.PersistenceContext.getVersionIds(Serializable).