document use of version_id_col with versioning example

Issue #2861 new
Anonymous created an issue

Problem description: Two requests from client application works on this same record in short period of time and sometimes appears integrity error from database on compound key of historical record: id,version.

My guess/investigations: When two requests perform operation on this same database record and for example first finished operation, then second have not actual information about newest version of historical record and try to save new one with this same version as first.

Versioning used from example of SqlAlchemy and trigered in event before_flush.

Comments (6)

  1. Michael Bayer repo owner

    sure, this is a natural effect of the two transactions not being entirely isolated. If you have your isolation set at at least REPEATABLE READ then you wouldn't get this issue.

    you can alleviate this condition using a different kind of "versioning" which is the mapper-level versioning feature, see

    I've committed a proof of concept for this in ac54ba0f2d8df5a76b685284. A change could be to make this a flag on the Versioned class itself and to add documentation.

  2. Michael Bayer repo owner

    to clarify, we're talking about examples/versioning, and adding information to that example that shows how to use the mapper version_id_col feature, which is a totally different thing with a similar name, at the same time.

  3. Log in to comment