Dangling subscriptions remain after removal of content
Currently the stadtgestalten.org
instance contains few subscriptions, that refer to non-existing content objects:
for a in features.subscriptions.models.Subscription.objects.all():
try:
str(a)
except AttributeError:
try:
print(a.pk, a.subscribed_to)
except AttributeError:
print("Failed to stringify due to subscription target:", a.pk, a.subscribed_to_id)
Failed to stringify due to subscription target: 214 58
Failed to stringify due to subscription target: 222 27
Failed to stringify due to subscription target: 235 27
Failed to stringify due to subscription target: 247 158
Failed to stringify due to subscription target: 249 182
Failed to stringify due to subscription target: 259 27
Failed to stringify due to subscription target: 393 27
Failed to stringify due to subscription target: 437 558
Failed to stringify due to subscription target: 443 111
Failed to stringify due to subscription target: 446 599
I stumbled upon this, when I was browsing through existing subscriptions. Exceptions were triggered while printing the dangling subscriptions (e.g. https://stadtgestalten.org/stadt/admin/subscriptions/subscription/?p=13).
The subscriptions probably remained after content was deleted, since the connection between the subscription and the content is a GenericForeignKey. It looks like this connection cannot enforce removal of related objects (via CASCADE
).
How to progress:
- Should we remove the dangling subscriptions manually? (periodically?)
- Should/can we ensure, that the subscriptions are removed after content or subscriber deletion?
- Or should we just ignore the inconsistency? (this will worsen #629 (closed))