You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have some real world concerns regarding cachalot design compared to old johnny cache.
Using timestamps as table generation keys (instead of uuid4 sha checksum as in johhny cache) seems to be prone to errors in production deployments.
First of all Python time.time() precision on Windows seems to be 100ns. Thus if time() is called multiple times in a row, it returns the same value.
This has severe consequences.
Simple calls like Django ORM get_or_create() can be executed so fast that the timestamp will be the same for the get() and for the create() and the table key will be set in create() to the same value like for the query in the get() (I hope it is clear what I mean).
Thus further calls to ORM get() will return the old value.
What should've happened instead?
Using timestamp as table generation value (at least on Windows) seems to be insufficient. I propose to use approach similar to jmoiron's johnny cache, i.e. uuid4() + sha1 hash.
Steps to reproduce
Django 4.x
OS Windows 10
Database PostgreSQL.
[//]: # (Include host configuration: OS, Django version, database, etc.)
The text was updated successfully, but these errors were encountered:
Using timestamps can be also source of various race conditions when having multiple servers. I understand FAQ recommending NTP to sync the time across servers, but this still can lead to race conditions, albeit not so easy to trigger like subsequent fast calls to get_or_create() within single process.
What happened?
I have some real world concerns regarding cachalot design compared to old johnny cache.
Using timestamps as table generation keys (instead of uuid4 sha checksum as in johhny cache) seems to be prone to errors in production deployments.
First of all Python time.time() precision on Windows seems to be 100ns. Thus if time() is called multiple times in a row, it returns the same value.
This has severe consequences.
Simple calls like Django ORM get_or_create() can be executed so fast that the timestamp will be the same for the get() and for the create() and the table key will be set in create() to the same value like for the query in the get() (I hope it is clear what I mean).
Thus further calls to ORM get() will return the old value.
What should've happened instead?
Using timestamp as table generation value (at least on Windows) seems to be insufficient. I propose to use approach similar to jmoiron's johnny cache, i.e. uuid4() + sha1 hash.
Steps to reproduce
Django 4.x
OS Windows 10
Database PostgreSQL.
[//]: # (Include host configuration: OS, Django version, database, etc.)
The text was updated successfully, but these errors were encountered: