简体   繁体   中英

Django SuspiciousOperation after upgrade to 1.10

Recently I have upgraded my apps from 1.8 to 1.10 and now I get flooded by this error:

Exception Type: SuspiciousOperation at << VARIOUS_PAGES >>

Exception Value: The request's session was deleted before the request completed. The user may have logged out in a concurrent request, for example.

I can't figure out why this happen but it seems that the session expires prematurely for some strange reason.

I ran into this today. For me, the issue was that the session keys were still in the cache, but the database session had been deleted. The middleware loaded the session via the cache, but when it attempted to write it back to the database, it triggers the DatabaseError (could not update any rows) which the Session then re-raises as UpdateError, which is then caught and raised as a SuspiciousOperation.

In my case, the problem occurred in a testing environment that had the database restored to an older version, removing the database session keys. But the cache wasn't cleared, so users that had visited the test environment, and had a cookie, began receiving 400 errors (SuspiciousOperation).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM