plone / guillotina

Python AsyncIO data API to manage billions of resources
https://guillotina.readthedocs.io/en/latest/
Other
187 stars 51 forks source link

[WIP] [Proposal] Remove TID sequence in favor of a "local" version id #1034

Closed masipcat closed 3 years ago

masipcat commented 3 years ago

And maybe we can add a last_txn_timestamp so we can still track changes globally

jordic commented 3 years ago

so, should we add a trigger that ensures that incoming tid is always greater than stored one?

masipcat commented 3 years ago

so, should we add a trigger that ensures that incoming tid is always greater than stored one?

I don't see why this is needed. When the object is created we set de serial/TID to 1. When the object is updated we increment the serial by one and during the UPDATE statement we check that the serial in pg is the serial before the increment (so we are updating the same object we read at the begining of the txn).

EDIT: the logic is here: https://github.com/plone/guillotina/blob/9223322641331997ad477254ecfa185597c5ca2e/guillotina/db/storages/pg.py#L165-L170

jordic commented 3 years ago

Coll, got it should work, I just don't remember the trick on counting updated rows, seems simple than a db trigger.