django.db.utils.DatabaseError: Forced update did not affect any rows.
See original GitHub issuePlease see the stack trace below.
I am not absolutely convinced this is a channels issue, but the stack trace makes it look like a channels issue. My interpretation of this (somewhat confusing) stack trace is that channels/sessions.py
line 58 has the call to save()
that is causing this error.
Unfortunately, it is somewhat random. In particular, when I start investigating the problem in detail, the problem tends to disappear.
Django version 1.11.5, Channels version 1.1.8.
Some sort of race condition maybe??? I have some rough theories, none of them exactly make any sense yet.
[2017-11-27 14:39:27,803: ERROR/django.channels] Error processing message with consumer myrocc.consumers.Demultiplexer:
Traceback (most recent call last):
File "/Users/brianmay/.pyenv/versions/3.6.2/envs/myrocc/lib/python3.6/site-packages/django/contrib/sessions/backends/db.py", line 87, in save
obj.save(force_insert=must_create, force_update=not must_create, using=using)
File "/Users/brianmay/.pyenv/versions/3.6.2/envs/myrocc/lib/python3.6/site-packages/django/db/models/base.py", line 807, in save
force_update=force_update, update_fields=update_fields)
File "/Users/brianmay/.pyenv/versions/3.6.2/envs/myrocc/lib/python3.6/site-packages/django/db/models/base.py", line 837, in save_base
updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
File "/Users/brianmay/.pyenv/versions/3.6.2/envs/myrocc/lib/python3.6/site-packages/django/db/models/base.py", line 906, in _save_table
raise DatabaseError("Forced update did not affect any rows.")
django.db.utils.DatabaseError: Forced update did not affect any rows.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/brianmay/.pyenv/versions/3.6.2/envs/myrocc/lib/python3.6/site-packages/channels/sessions.py", line 54, in inner
return func(*args, **kwargs)
File "/Users/brianmay/.pyenv/versions/3.6.2/envs/myrocc/lib/python3.6/site-packages/channels/auth.py", line 42, in inner
return func(message, *args, **kwargs)
File "/Users/brianmay/.pyenv/versions/3.6.2/envs/myrocc/lib/python3.6/site-packages/channels/generic/websockets.py", line 71, in raw_connect
self.connect(message, **kwargs)
File "/Users/brianmay/.pyenv/versions/3.6.2/envs/myrocc/lib/python3.6/site-packages/channels/generic/websockets.py", line 278, in connect
consumer(message, **kwargs)
File "/Users/brianmay/.pyenv/versions/3.6.2/envs/myrocc/lib/python3.6/site-packages/channels/generic/base.py", line 32, in __init__
self.dispatch(message, **kwargs)
File "/Users/brianmay/.pyenv/versions/3.6.2/envs/myrocc/lib/python3.6/site-packages/channels/generic/base.py", line 70, in dispatch
return self.get_handler(message, **kwargs)(message, **kwargs)
File "/Users/brianmay/.pyenv/versions/3.6.2/envs/myrocc/lib/python3.6/site-packages/channels/sessions.py", line 193, in inner
return func(message, *args, **kwargs)
File "/Users/brianmay/.pyenv/versions/3.6.2/envs/myrocc/lib/python3.6/site-packages/channels/auth.py", line 73, in inner
return func(message, *args, **kwargs)
File "/Users/brianmay/.pyenv/versions/3.6.2/envs/myrocc/lib/python3.6/site-packages/channels/sessions.py", line 58, in inner
message.channel_session.save()
File "/Users/brianmay/.pyenv/versions/3.6.2/envs/myrocc/lib/python3.6/site-packages/django/contrib/sessions/backends/db.py", line 94, in save
raise UpdateError
django.contrib.sessions.backends.base.UpdateError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/brianmay/.pyenv/versions/3.6.2/envs/myrocc/lib/python3.6/site-packages/django/contrib/sessions/backends/db.py", line 87, in save
obj.save(force_insert=must_create, force_update=not must_create, using=using)
File "/Users/brianmay/.pyenv/versions/3.6.2/envs/myrocc/lib/python3.6/site-packages/django/db/models/base.py", line 807, in save
force_update=force_update, update_fields=update_fields)
File "/Users/brianmay/.pyenv/versions/3.6.2/envs/myrocc/lib/python3.6/site-packages/django/db/models/base.py", line 837, in save_base
updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
File "/Users/brianmay/.pyenv/versions/3.6.2/envs/myrocc/lib/python3.6/site-packages/django/db/models/base.py", line 906, in _save_table
raise DatabaseError("Forced update did not affect any rows.")
django.db.utils.DatabaseError: Forced update did not affect any rows.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/brianmay/.pyenv/versions/3.6.2/envs/myrocc/lib/python3.6/site-packages/channels/sessions.py", line 78, in inner
return func(*args, **kwargs)
File "/Users/brianmay/.pyenv/versions/3.6.2/envs/myrocc/lib/python3.6/site-packages/channels/auth.py", line 89, in inner
return func(message, *args, **kwargs)
File "/Users/brianmay/.pyenv/versions/3.6.2/envs/myrocc/lib/python3.6/site-packages/channels/sessions.py", line 58, in inner
message.channel_session.save()
File "/Users/brianmay/.pyenv/versions/3.6.2/envs/myrocc/lib/python3.6/site-packages/django/contrib/sessions/backends/db.py", line 94, in save
raise UpdateError
django.contrib.sessions.backends.base.UpdateError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/brianmay/.pyenv/versions/3.6.2/envs/myrocc/lib/python3.6/site-packages/django/contrib/sessions/backends/db.py", line 87, in save
obj.save(force_insert=must_create, force_update=not must_create, using=using)
File "/Users/brianmay/.pyenv/versions/3.6.2/envs/myrocc/lib/python3.6/site-packages/django/db/models/base.py", line 807, in save
force_update=force_update, update_fields=update_fields)
File "/Users/brianmay/.pyenv/versions/3.6.2/envs/myrocc/lib/python3.6/site-packages/django/db/models/base.py", line 837, in save_base
updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
File "/Users/brianmay/.pyenv/versions/3.6.2/envs/myrocc/lib/python3.6/site-packages/django/db/models/base.py", line 906, in _save_table
raise DatabaseError("Forced update did not affect any rows.")
django.db.utils.DatabaseError: Forced update did not affect any rows.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/brianmay/.pyenv/versions/3.6.2/envs/myrocc/lib/python3.6/site-packages/channels/worker.py", line 119, in run
consumer(message, **kwargs)
File "/Users/brianmay/.pyenv/versions/3.6.2/envs/myrocc/lib/python3.6/site-packages/channels/generic/base.py", line 32, in __init__
self.dispatch(message, **kwargs)
File "/Users/brianmay/.pyenv/versions/3.6.2/envs/myrocc/lib/python3.6/site-packages/channels/generic/base.py", line 70, in dispatch
return self.get_handler(message, **kwargs)(message, **kwargs)
File "/Users/brianmay/.pyenv/versions/3.6.2/envs/myrocc/lib/python3.6/site-packages/channels/sessions.py", line 220, in inner
result = func(message, *args, **kwargs)
File "/Users/brianmay/.pyenv/versions/3.6.2/envs/myrocc/lib/python3.6/site-packages/channels/auth.py", line 73, in inner
return func(message, *args, **kwargs)
File "/Users/brianmay/.pyenv/versions/3.6.2/envs/myrocc/lib/python3.6/site-packages/channels/sessions.py", line 82, in inner
session.save()
File "/Users/brianmay/.pyenv/versions/3.6.2/envs/myrocc/lib/python3.6/site-packages/django/contrib/sessions/backends/db.py", line 94, in save
raise UpdateError
django.contrib.sessions.backends.base.UpdateError
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
21761 (Confused about "Forced update did not affect any rows.")
I have a DatabaseError("Forced update did not affect any rows.") (from model.save_base). I cannot reproduce the error; Manually running save(force_update) ...
Read more >In Django, how can I prevent a "Save with update_fields did ...
Sometimes I get the following error on my "save" line ... raise DatabaseError("Save with update_fields did not affect any rows.") django.db.
Read more >Handling "Save with update_fields did not affect any rows"
Hi, the model.save() arguments `force_update` and `update_fields` cause an explicit check if the update statement matched any rows.
Read more >Django (1.5) login exception (Save with update_fields did not ...
Every once in a while, the login function throws an exception (DatabaseError: Save with update_fields did not affect any rows) and I'm
Read more >Save with update_fields did not affect any rows (while ...
Coding example for the question Save with update_fields did not affect any rows (while changing class)-django.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Honestly, it might be better to email django-developers or open an issue here to discuss so it’s more public as well.
I am going to close this bug report. I very much suspect the test framework we were using was truncating the database while the test server process was still running and processing WebSocket requests.