-
Notifications
You must be signed in to change notification settings - Fork 17
Closed
Labels
release testingAffects the upcoming release (attention needed)Affects the upcoming release (attention needed)
Description
Issue: Forum v2 MySQL Backend Cannot Find Newly Created Discussion Posts
Description
When creating a new post in the discussion forum with the MySQL backend enabled, the notification Celery task fails with a ForumV2RequestError. The thread is successfully created and visible in the Discussions MFE, but Forum v2 cannot retrieve it when processing notifications.
Prerequisites
This issue occurs when the following features are enabled:
- MySQL backend for forums
- Forum and notification Tutor plugins, OR
forum_v2.enable_mysql_backendfeature flag
Steps to Reproduce
- Enable the MySQL backend for forums
- Ensure forum and notification features are active
- Create a new post in the discussion forum
- Observe the error when the notification Celery task is triggered
Error Details
The notification worker raises a ForumV2RequestError indicating the thread does not exist, despite being visible in the Discussions MFE.
Error Message:
ForumV2RequestError('Thread does not exist with Id: 5')
Stack Trace:
lms-worker-1 | Traceback (most recent call last):
lms-worker-1 | File "/openedx/venv/lib/python3.11/site-packages/forum/backends/mysql/api.py", line 916, in validate_object
lms-worker-1 | instance = modelss[model].objects.get(pk=int(obj_id))
lms-worker-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lms-worker-1 | File "/openedx/venv/lib/python3.11/site-packages/django/db/models/manager.py", line 87, in manager_method
lms-worker-1 | return getattr(self.get_queryset(), name)(*args, **kwargs)
lms-worker-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lms-worker-1 | File "/openedx/venv/lib/python3.11/site-packages/django/db/models/query.py", line 635, in get
lms-worker-1 | raise self.model.DoesNotExist(
lms-worker-1 | forum.backends.mysql.models.CommentThread.DoesNotExist: CommentThread matching query does not exist.
lms-worker-1 |
lms-worker-1 | The above exception was the direct cause of the following exception:
lms-worker-1 |
lms-worker-1 | Traceback (most recent call last):
lms-worker-1 | File "/openedx/venv/lib/python3.11/site-packages/forum/api/threads.py", line 140, in get_thread
lms-worker-1 | thread = backend.validate_object("CommentThread", thread_id)
lms-worker-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lms-worker-1 | File "/openedx/venv/lib/python3.11/site-packages/forum/backends/mysql/api.py", line 918, in validate_object
lms-worker-1 | raise ObjectDoesNotExist from exc
lms-worker-1 | django.core.exceptions.ObjectDoesNotExist
lms-worker-1 |
lms-worker-1 | The above exception was the direct cause of the following exception:
lms-worker-1 |
lms-worker-1 | Traceback (most recent call last):
lms-worker-1 | File "/openedx/venv/lib/python3.11/site-packages/celery/app/trace.py", line 453, in trace_task
lms-worker-1 | R = retval = fun(*args, **kwargs)
lms-worker-1 | ^^^^^^^^^^^^^^^^^^^^
lms-worker-1 | File "/openedx/venv/lib/python3.11/site-packages/celery/app/trace.py", line 736, in __protected_call__
lms-worker-1 | return self.run(*args, **kwargs)
lms-worker-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^
lms-worker-1 | File "/openedx/venv/lib/python3.11/site-packages/edx_django_utils/monitoring/internal/code_owner/utils.py", line 195, in new_function
lms-worker-1 | return wrapped_function(*args, **kwargs)
lms-worker-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lms-worker-1 | File "/openedx/edx-platform/lms/djangoapps/discussion/rest_api/tasks.py", line 36, in send_thread_created_notification
lms-worker-1 | thread = Thread(id=thread_id).retrieve()
lms-worker-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lms-worker-1 | File "/openedx/edx-platform/openedx/core/djangoapps/django_comment_common/comment_client/models.py", line 68, in retrieve
lms-worker-1 | self._retrieve(*args, **kwargs)
lms-worker-1 | File "/openedx/edx-platform/openedx/core/djangoapps/django_comment_common/comment_client/thread.py", line 168, in _retrieve
lms-worker-1 | response = forum_api.get_thread(
lms-worker-1 | ^^^^^^^^^^^^^^^^^^^^^
lms-worker-1 | File "/openedx/venv/lib/python3.11/site-packages/forum/api/threads.py", line 143, in get_thread
lms-worker-1 | raise ForumV2RequestError(
lms-worker-1 | forum.utils.ForumV2RequestError: Thread does not exist with Id: 5
Root Cause
The issue originates in the notification task (send_thread_created_notification) when attempting to retrieve the thread. The MySQL backend's validate_object method fails to find the CommentThread record, triggering a cascade of exceptions:
CommentThread.DoesNotExistin the MySQL backendObjectDoesNotExistin the validation layerForumV2RequestErrorat the API level
Impact
- Notification system fails for new discussion posts
- Users do not receive notifications for forum activity
- Creates inconsistency between the Discussions MFE (where posts are visible) and the backend notification system
Metadata
Metadata
Assignees
Labels
release testingAffects the upcoming release (attention needed)Affects the upcoming release (attention needed)