After upgrading my Django 1.6 application to Django 1.7, I started getting random errors when retrieving data from PostgreSQL:
DatabaseError: server sent data ("D" message) without prior row description ("T" message) lost synchronization with server: got message type " ", length -1244613424 DatabaseError: lost synchronization with server: got message type "0", length 842674226 ProgrammingError: no results to fetch ValueError: invalid literal for int() with base 10: 'feuj3f47jvsdv7tgnj43g63j'
When I quickly open 10 tabs in the browser, half of the downloads usually load, half of them get a DB error. When I update tabs with errors, they load normally.
I am running Django through uwsgi and nginx, psycopg2 version is 2.5.4.
In general, it seems that some connection with Postgres is completely broken, and the results of different queries become mixed.
Edit:
After several hours of troubleshooting, the following came out:
Django 1.6 + uwsgi - works
Django 1.7 + gunicorn - works
Django 1.7 + uwsgi - does not work, causes database errors. So the problem is with the features of uwsgi and Django 1.7. What is strange, I have another Django 1.7 project running on the same server with the same uwsgi, and it has no problems.
Any ideas?
(In fact, I do not mind switching to guns, you may have to go this route, but still I wonder why this happens)
Update 2: a more detailed study reveals absolutely crazy things happening inside Django, for example, the primary key of the model, replaced by the current user session_id (which is the source of the "invalid literal for int () with a database error of 10") and Django issuing database queries " forgets "to indicate a WHERE clause. I would probably call it memory corruption.
Update 3: We switched from uwsgi to gunicorn and the problems are now gone. Everything works great. Maybe I'm still looking for a suitable solution.