Conversation
felixrindt
left a comment
There was a problem hiding this comment.
blocked by django-tenants/django-tenants#959
this is merged and released in 3.6 of django-tenants |
|
@dependabot rebase |
|
We found out that Cursors in pscopg3 use a threading.Lock on the Connection object to execute queries. Inside the lock, field values are serialized. What happens in the ModelLogging module is
We don't know why the value serialization happens inside the connection lock yet. Seams like this is before any DB interaction, but maybe it's needed for psycopgs implementation to be threadsafe. Thus, we need to move the serialization outside the lock (before we call save) or avoid queries (with that locked connection) inside our serialization method. This could be done using
|
|
|
||
| # Pre-serialize to resolve model instances, querysets, and str() calls | ||
| # outside of psycopg3's connection lock (which would deadlock on DB queries). | ||
| log_data = json.loads(json.dumps(log_data, cls=LogJSONEncoder)) |
There was a problem hiding this comment.
hmm crazy we have to go through the str type here instead of just serializing the fields inside the dict/list structure
closes #949