- changed milestone to 0.9.0
- changed component to documentation
- changed title to document use of version_id_col with versioning example
document use of version_id_col with versioning example
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)
-
repo owner -
repo owner - changed milestone to 0.9.xx
-
repo owner -
assigned issue to
- marked as minor
- edited description
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.
-
assigned issue to
-
repo owner - marked as enhancement
-
repo owner - changed milestone to 1.0.xx
-
repo owner - changed milestone to 1.x.xx
- Log in to comment
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 http://docs.sqlalchemy.org/en/rel_0_9/orm/mapper_config.html#configuring-a-version-counter.
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.