Some times i am getting error after deploying. Which last for 1 minute

Hi, I liked the zero downtime deployment. But sometimes i get “Server error”. Which last up to 1 minute.
i will get error message in live for up to 1 minute
My project is django based web app
In “sentry” the error is showing as “unsupported pickle protocol: 5”
I am using SQLlite as databse. Is it because of that that error is coming
But it will not happen at all deployment. Only some.

How can i stop that error from happening ?

HI there,

Thanks for reaching out.

unsupported pickle protocol: 5 appears to be a Python library error, I’m not a Python expert, but it seems this might mean you are trying to deserialize data created with a different protocol version?

If you are using SQLite, I guess you are also using a disk? Disks currently prevent zero downtime deploys, while the disk is switched between instances. Could that be part of the issue? If you’re not using a disk, you’ll likely be losing your SQLite data on each deploy.

Please let us know if we can assist any further.

Alan

I am not using disk.
I know the data stored in SQLite lose in each deploy. it is ok
How can i stop this error ?
Is it because django lose some data such as session information ?

This Stackoverflow post seems to be point to unsupported pickle protocol: 5 being an issue when the serialize/deserialize is done between different versions of Python. Could that be the issue here?

To assist in debugging further we’d likely need more detail:

  • Is it happening only at deploy/boot time? Or does it happen at other times/with other requests?
  • Have you managed to consistently reproduce the issue?
  • Do you have more complete logs/stacktrace around the error message?

Thanks

Alan

1)It happens only after deployment in render. Before i deployed in Heroku and cPanel. “I never saw this error any where else”
I am using Python 3.9.6
I am using SQLite, so every time i deploy, i am bringing new database created by python 3.9.6 in my desktop. Is that the reason?
also i am using “django user agents” which catch some user info in database(SQLite). Is that the reason?
also it resolve automatically within 2 minutes.

2)It happened to my last deployment too
3) error log of this is very large

Mostly database catch of “django user agents” is making the trouble.
Disabling catch option in “django user agents” is the only solution ?

Thanks for the updates.

I am using Python 3.9.6

The Web Service is using the default Python version 3.7.10, the StackOverflow linked above seemed to mention a similar issue with version disparity. You can set the Python version by setting an environment variable PYTHON_VERSION. Ensuring the environments are as similar as possible would be a good first step.

Disabling catch option in “django user agents” is the only solution ?

I’m not sure, maybe you could try removing it to see if the issue stops?

I’m not currently seeing anything in the Deploy or Service logs that shows the error you’ve described.

Can you reproduce it consistently? Does this only happen if you make a request to the app straight after a deploy/during boot? Is the app doing any extra initialization tasks at boot time that could be causing this error?

Alan

I disabled database catch of “django user agents”
I will inform you if problem occur again

Want to add what I found to be a solution to random pickle errors right after deploy but going away after some time.

Although the user agent cache may be the problem in this specific case, I’ve found that any use of the django cache in general can produce this.

But there is an option in CACHES to specify the pickle version, so that even if pickle 5 is available, the lower version supported by all your environments is used. Add OPTIONS, for example:

CACHES = {
‘default’: {
‘BACKEND’: ‘django.core.cache.backends.db.DatabaseCache’,
‘LOCATION’: ‘work_ajax_cache’,
‘TIMEOUT’: 60 * 60,
‘OPTIONS’: {
‘PICKLE_VERSION’: 4,
}
},
‘tasks’: {
‘BACKEND’: ‘django.core.cache.backends.db.DatabaseCache’,
‘LOCATION’: ‘tasks_querysetcache’,
‘TIMEOUT’: 15,
‘OPTIONS’: {
‘PICKLE_VERSION’: 4,
},
}
}

Restart your servers after this change, then go into python console and do:

from django.core.cache import cache
cache.clear()