Calculate timestamps within DB, not client

Bug #1787345 reported by Yikun Jiang on 2018-08-16
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
oslo.db
Wishlist
Yikun Jiang

Bug Description

Calculating the timestamp in the clients can lead to problems because network latency is variable, clients experience slightly different clock drift.

SQLAlchemy allows us to do this by passing func.now() which tells the DB to calculate the timestamp itself

So, in order to make the updated_at and created_at more accurate, we should calculate the timestamp in db.[1]

[1] https://github.com/openstack/oslo.db/blob/3ef34da/oslo_db/sqlalchemy/models.py#L138-L139
[2] https://stackoverflow.com/questions/12154129/how-can-i-automatically-populate-sqlalchemy-database-fields-flask-sqlalchemy
[3] https://stackoverflow.com/questions/13370317/sqlalchemy-default-datetime
[4] http://docs.sqlalchemy.org/en/latest/core/defaults.html#client-invoked-sql-expressions

Changed in oslo.db:
assignee: nobody → Yikun Jiang (yikunkero)
status: New → In Progress
Ben Nemec (bnemec) on 2018-08-16
Changed in oslo.db:
importance: Undecided → Wishlist
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers