You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Error While Running forum_migrate_course_from_mongodb_to_mysql – MongoContent.DoesNotExist #211
While executing the management command forum_migrate_course_from_mongodb_to_mysql, which is intended to migrate forum data from MongoDB to MySQL, the following error was encountered:
Traceback (most recent call last):
File "/edx/app/edxapp/edx-platform/./manage.py", line 99, in <module>
execute_from_command_line([sys.argv[0]] + django_args)
...
File "/edx/app/edxapp/venvs/edxapp/lib/python3.11/site-packages/forum/migration_helpers.py", line 128, in create_or_update_comment
mongo_thread = MongoContent.objects.get(mongo_id=mongo_thread_id)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/edx/app/edxapp/venvs/edxapp/lib/python3.11/site-packages/django/db/models/query.py", line 637, in get
raise self.model.DoesNotExist(
forum.backends.mysql.models.MongoContent.DoesNotExist: MongoContent matching query does not exist.
This could potentially happen if the thread wasn't created before and since a comment needs its parent thread id for creation, the command breaks because the thread with that id isn't there. Have you tried running the command again?
Also, was there any error in stack trace before this which could point to a thread not being created?
Can we handle cases where comments have no corresponding thread ID, especially for the existing data? We haven't re-executed the command yet, but we can share the complete logs if needed to help with debugging.
Also, there was no prior error in the stack trace indicating that the thread creation failed — this was the first point of failure we observed.
yes complete logs might give us a hint. A comment can't technically be present without a thread so if that's the case then its probably a dangling comment and we could let it fail silently.
You can find the log file in your mailbox. @AhtishamShahid , could you please share your thoughts on the dangling comment regarding whether we should allow it to fail silently?
We should prioritize that all data should be transferred even if it has broken relations, and there should be no data loss during the transfer process.
It wouldn't make much sense to have dangling comments/replies to posts that don't actually exist and won't be shown on the FE to the end users. What do you think @regisb ?
Also, my I couldn't find why this is happening in the first place i.e. a comment exists with a non-existent thread id in the mongodb.
I agree that we can improve the command by implementing point number 3 suggested by Regis. If everyone is on the same page, I can spin up a PR real quick
Activity
hassan-raza-1 commentedon Jul 30, 2025
FYI @taimoor-ahmed-1 @regisb
taimoor-ahmed-1 commentedon Aug 6, 2025
This could potentially happen if the thread wasn't created before and since a comment needs its parent thread id for creation, the command breaks because the thread with that id isn't there. Have you tried running the command again?
Also, was there any error in stack trace before this which could point to a thread not being created?
hassan-raza-1 commentedon Aug 7, 2025
Can we handle cases where comments have no corresponding thread ID, especially for the existing data? We haven't re-executed the command yet, but we can share the complete logs if needed to help with debugging.
Also, there was no prior error in the stack trace indicating that the thread creation failed — this was the first point of failure we observed.
taimoor-ahmed-1 commentedon Aug 7, 2025
yes complete logs might give us a hint. A comment can't technically be present without a thread so if that's the case then its probably a dangling comment and we could let it fail silently.
hassan-raza-1 commentedon Aug 7, 2025
You can find the log file in your mailbox.
@AhtishamShahid , could you please share your thoughts on the dangling comment regarding whether we should allow it to fail silently?
AhtishamShahid commentedon Aug 7, 2025
We should prioritize that all data should be transferred even if it has broken relations, and there should be no data loss during the transfer process.
taimoor-ahmed-1 commentedon Aug 11, 2025
It wouldn't make much sense to have dangling comments/replies to posts that don't actually exist and won't be shown on the FE to the end users. What do you think @regisb ?
Also, my I couldn't find why this is happening in the first place i.e. a comment exists with a non-existent thread id in the mongodb.
regisb commentedon Aug 11, 2025
My 2 cents:
taimoor-ahmed-1 commentedon Aug 11, 2025
I agree that we can improve the command by implementing point number 3 suggested by Regis. If everyone is on the same page, I can spin up a PR real quick
fix: Log missing content mapping in mongo2mysql cmd
fix: Log missing content mapping in mongo2mysql cmd
AhtishamShahid commentedon Aug 18, 2025
@taimoor-ahmed-1 Logging skipped comments sounds good. Please let me know when the fix is deployed.
fix: Log missing content mapping in mongo2mysql cmd
fix: Log missing content mapping in mongo2mysql cmd
fix: Log missing content mapping in mongo2mysql cmd (openedx#220)