Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: don't call signal handlers like XBLOCK_UPDATED before commit #34847

Conversation

bradenmacdonald
Copy link
Contributor

@bradenmacdonald bradenmacdonald commented May 22, 2024

Description

This backports an import fix, #34800, to Redwood. I also included #34838, a tiny fix to some comments (no code changes).

Without this fix, authors may make changes to course content in Studio but won't see those changes when they use the new studio course search feature; the search index would only show an older version of the content.

Supporting information

See #34800

Testing instructions

  1. Enable Content Search beta
  2. Make changes to a course in Studio - e.g. rename a subsection
  3. Verify that the changes are always reflected (almost) right away in the studio search results

Deadline

Ideally before Redwood official release

Private ref: FAL-3715

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label May 22, 2024
@openedx-webhooks
Copy link

Thanks for the pull request, @bradenmacdonald! Please note that it may take us up to several weeks or months to complete a review and merge your PR.

Feel free to add as much of the following information to the ticket as you can:

  • supporting documentation
  • Open edX discussion forum threads
  • timeline information ("this must be merged by XX date", and why that is)
  • partner information ("this is a course on edx.org")
  • any other information that can help Product understand the context for the PR

All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here.

Please let us know once your PR is ready for our review and all tests are green.

Copy link
Contributor

@pomegranited pomegranited left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@bradenmacdonald I encountered issues when deleting content from my course in Studio (details inline), but that's not a blocker for merging here.

return xblock

@strip_key
def delete_item(self, location, user_id, **kwargs): # lint-amnesty, pylint: disable=arguments-differ
"""
Delete the given item from persistence. kwargs allow modulestore specific parameters.
"""
store = self._verify_modulestore_support(location.course_key, 'delete_item')
course_key = location.course_key
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bradenmacdonald I had issues with deleting content from my course -- deleted blocks still show up in search?

But I'm not sure if there's something wrong with my setup, because I've got redis errors in the traceback.

cms-1  | 2024-05-22 23:47:11,093 ERROR 327 [django.dispatch] [user 6] [ip 172.18.0.1] dispatcher.py:213 - Error calling handle_item_deleted in Signal.send_robust() (BlockKey(type='vertical', id='f69a018879e5421f93fc631e8edd15da'))
cms-1  | Traceback (most recent call last):
cms-1  |   File "/openedx/venv/lib/python3.8/site-packages/django/dispatch/dispatcher.py", line 211, in send_robust
cms-1  |     response = receiver(signal=self, sender=sender, **named)
cms-1  |   File "/openedx/edx-platform/cms/djangoapps/contentstore/signals/handlers.py", line 207, in handle_item_deleted
cms-1  |     deleted_block = modulestore().get_item(usage_key)
cms-1  |   File "/openedx/edx-platform/xmodule/modulestore/mixed.py", line 90, in inner
cms-1  |     retval = func(field_decorator=strip_key_collection, *args, **kwargs)
cms-1  |   File "/openedx/edx-platform/xmodule/modulestore/mixed.py", line 257, in get_item
cms-1  |     return store.get_item(usage_key, depth, **kwargs)
cms-1  |   File "/openedx/edx-platform/xmodule/modulestore/split_mongo/split_draft.py", line 283, in get_item
cms-1  |     return super().get_item(usage_key, depth=depth, **kwargs)
cms-1  |   File "/openedx/edx-platform/xmodule/modulestore/split_mongo/split.py", line 1183, in get_item
cms-1  |     items = self._load_items(course, [BlockKey.from_usage_key(usage_key)], depth, **kwargs)
cms-1  |   File "/openedx/edx-platform/xmodule/modulestore/split_mongo/split.py", line 780, in _load_items
cms-1  |     return [runtime.load_item(block_key, course_entry, **kwargs) for block_key in block_keys]
cms-1  |   File "/openedx/edx-platform/xmodule/modulestore/split_mongo/split.py", line 780, in <listcomp>
cms-1  |     return [runtime.load_item(block_key, course_entry, **kwargs) for block_key in block_keys]
cms-1  |   File "/openedx/edx-platform/xmodule/modulestore/split_mongo/caching_descriptor_system.py", line 127, in _load_item
cms-1  |     block_data = self.get_module_data(block_key, course_key)
cms-1  |   File "/openedx/edx-platform/xmodule/modulestore/split_mongo/caching_descriptor_system.py", line 154, in get_module_data
cms-1  |     raise ItemNotFoundError(block_key)
cms-1  | xmodule.modulestore.exceptions.ItemNotFoundError: BlockKey(type='vertical', id='f69a018879e5421f93fc631e8edd15da')
cms-1  | 2024-05-22 23:47:11,094 INFO 327 [xmodule.modulestore.django] [user 6] [ip 172.18.0.1] django.py:220 - Sent item_deleted signal to <function handle_item_deleted at 0x7f831eca1e50> with kwargs {'usage_key': BlockUsageLocator(CourseLocator('SampleTaxonomyOrg2', 'STC1', '2023_1', 'draft-branch', None), 'vertical', 'f69a018879e5421f93fc631e8edd15da'), 'user_id': 6}. Response was: BlockKey(type='vertical', id='f69a018879e5421f93fc631e8edd15da')
cms-1  | 2024-05-22 23:47:11,200 INFO 327 [celery_utils.logged_task] [user 6] [ip 172.18.0.1] logged_task.py:25 - Task openedx.core.djangoapps.content.search.tasks.delete_xblock_index_doc[5f07654a-aeda-4b2d-b8f2-efd41ae30445] submitted with arguments ('block-v1:SampleTaxonomyOrg2+STC1+2023_1+type@vertical+block@f69a018879e5421f93fc631e8edd15da',), {}
cms-1  | 2024-05-22 23:47:11,214 ERROR 327 [edx_event_bus_redis.internal.producer] [user 6] [ip 172.18.0.1] producer.py:51 - Error delivering message to Redis event bus. error=Error -2 connecting to edx.devstack.redis:6379. Name or service not known. full_topic='dev-course-authoring-xblock-lifecycle' event_key=None signal=<OpenEdxPublicSignal: org.openedx.content_authoring.xblock.deleted.v1> initial_topic='course-authoring-xblock-lifecycle' event_key_field='xblock_info.usage_key' event_data={'xblock_info': XBlockData(usage_key=BlockUsageLocator(CourseLocator('SampleTaxonomyOrg2', 'STC1', '2023_1', None, None), 'vertical', 'f69a018879e5421f93fc631e8edd15da'), block_type='vertical', version=None)} event_metadata=EventsMetadata(event_type='org.openedx.content_authoring.xblock.deleted.v1', id=UUID('9b992d54-1895-11ef-9c09-0242ac120009'), minorversion=0, source='openedx/cms/web', sourcehost='eab1bef4bb21', time=datetime.datetime(2024, 5, 22, 23, 47, 11, 147475, tzinfo=datetime.timezone.utc), sourcelib=(9, 9, 2))

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pomegranited I encountered the same errors in my logs as well, however the deleted blocks do not show up in the search.

Copy link
Member

@yusuf-musleh yusuf-musleh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Looks good to me @bradenmacdonald

  • I tested this: I made sure the the index is properly updating when creating/updating/deleteing, when running locally with celery
  • I read through the code
  • I checked for accessibility issues
  • Includes documentation

@bradenmacdonald
Copy link
Contributor Author

Hmm, not sure what those errors are about, but it does seem they're unrelated to this issue, so we can investigate them separately as needed. Thanks for the reviews!

@bradenmacdonald bradenmacdonald merged commit 801680e into openedx:open-release/redwood.master May 23, 2024
78 checks passed
@bradenmacdonald bradenmacdonald deleted the braden/backport-fixes branch May 23, 2024 16:51
@openedx-webhooks
Copy link

@bradenmacdonald 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
open-source-contribution PR author is not from Axim or 2U
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants