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

Remove Old Pymongo pin #30569

Merged
merged 9 commits into from
Jun 27, 2022
Merged

Remove Old Pymongo pin #30569

merged 9 commits into from
Jun 27, 2022

Conversation

aht007
Copy link
Member

@aht007 aht007 commented Jun 10, 2022

This PR unpins Pymongo version from constraints file.
Pymongo >=3.11 would raise configuration error if replica set is empty string. Either we should pass replica set name which is already configured or pass it as None so that it serves as a standalone server.
For sandboxes, rs0 replica set is configured example but for devstack we don't have any so we are specifying it as None for devstack here in this PR.
For sandboxes a fix PR has been made which uses the already configured replica set and tested with this sandbox
For edx prod and stage we already have replica sets defined as can be seen here and being used so it wouldn't affect them.

@aht007 aht007 self-assigned this Jun 10, 2022
@aht007 aht007 marked this pull request as draft June 10, 2022 15:03
@aht007 aht007 force-pushed the aht007/PYMONGO-CONSTRAINT-INVESTIGATION branch 6 times, most recently from a303fdb to ca55b45 Compare June 15, 2022 12:36
@@ -36,9 +36,6 @@ django-oauth-toolkit<=1.3.2
# Will be updated once we update python-dateutil package
matplotlib<3.4.0

# tests failing for pymongo==3.11
Copy link
Contributor

Choose a reason for hiding this comment

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

Add new pin here to avoid any major release.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

@adzuci adzuci left a comment

Choose a reason for hiding this comment

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

I don't understand the devstack bits, but this PR looks reasonable as long as some testing has been done

@aht007 aht007 changed the title Unpin Pymongo Remove Old Pymongo pin Jun 20, 2022
@aht007 aht007 marked this pull request as ready for review June 20, 2022 12:17
@jmbowman
Copy link
Contributor

Just found a reported bug which should be fixed by this upgrade: https://discuss.openedx.org/t/mongodb-intermittent-connection-timeout-errors-in-pymongo-topology-py/7278 .

@aht007
Copy link
Member Author

aht007 commented Jun 24, 2022

@jmbowman The PR is ready and has been tested as well on sandboxes and devstack. It couldn't be merged today because of the flaky tests. They passed just now on 6th run though
I will make sure that it is ported back to the nutmeg release. Do we also need to do this for maple since I found out in conversation that it is also an issue on maple.

@aht007 aht007 merged commit 8ef261f into master Jun 27, 2022
@aht007 aht007 deleted the aht007/PYMONGO-CONSTRAINT-INVESTIGATION branch June 27, 2022 09:37
aht007 added a commit that referenced this pull request Jun 27, 2022
@edx-pipeline-bot
Copy link
Contributor

EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production.

@edx-pipeline-bot
Copy link
Contributor

EdX Release Notice: This PR has been deployed to the production environment.

@jmbowman
Copy link
Contributor

Maple is no longer supported, so I don't think any proactive effort is needed for that.

@ormsbee
Copy link
Contributor

ormsbee commented Jun 30, 2022

I was recently creating a new tutor dev instance with tutor dev quickstart and it errored out while trying to run the split_modulestore_django.0002_data_migration (which requires MongoDB access), with the trace:

  File "./manage.py", line 106, in <module>
    execute_from_command_line([sys.argv[0]] + django_args)
  File "/openedx/venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/openedx/venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/openedx/venv/lib/python3.8/site-packages/django/core/management/base.py", line 354, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/openedx/venv/lib/python3.8/site-packages/django/core/management/base.py", line 398, in execute
    output = self.handle(*args, **options)
  File "/openedx/venv/lib/python3.8/site-packages/django/core/management/base.py", line 89, in wrapped
    res = handle_func(*args, **kwargs)
  File "/openedx/venv/lib/python3.8/site-packages/django/core/management/commands/migrate.py", line 244, in handle
    post_migrate_state = executor.migrate(
  File "/openedx/venv/lib/python3.8/site-packages/django/db/migrations/executor.py", line 117, in migrate
    state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
  File "/openedx/venv/lib/python3.8/site-packages/django/db/migrations/executor.py", line 147, in _migrate_all_forwards
    state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
  File "/openedx/venv/lib/python3.8/site-packages/django/db/migrations/executor.py", line 227, in apply_migration
    state = migration.apply(state, schema_editor)
  File "/openedx/venv/lib/python3.8/site-packages/django/db/migrations/migration.py", line 123, in apply
    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
  File "/openedx/venv/lib/python3.8/site-packages/django/db/migrations/operations/special.py", line 190, in database_forwards
    self.code(from_state.apps, schema_editor)
  File "/openedx/edx-platform/common/djangoapps/split_modulestore_django/migrations/0002_data_migration.py", line 26, in forwards_func
    for course_index in split_modulestore.db_connection.find_matching_course_indexes(force_mongo=True):
  File "/openedx/venv/lib/python3.8/site-packages/pymongo/cursor.py", line 1238, in next
    if len(self.__data) or self._refresh():
  File "/openedx/venv/lib/python3.8/site-packages/pymongo/cursor.py", line 1130, in _refresh
    self.__session = self.__collection.database.client._ensure_session()
  File "/openedx/venv/lib/python3.8/site-packages/pymongo/mongo_client.py", line 1935, in _ensure_session
    return self.__start_session(True, causal_consistency=False)
  File "/openedx/venv/lib/python3.8/site-packages/pymongo/mongo_client.py", line 1883, in __start_session
    server_session = self._get_server_session()
  File "/openedx/venv/lib/python3.8/site-packages/pymongo/mongo_client.py", line 1921, in _get_server_session
    return self._topology.get_server_session()
  File "/openedx/venv/lib/python3.8/site-packages/pymongo/topology.py", line 520, in get_server_session
    session_timeout = self._check_session_support()
  File "/openedx/venv/lib/python3.8/site-packages/pymongo/topology.py", line 499, in _check_session_support
    self._select_servers_loop(
  File "/openedx/venv/lib/python3.8/site-packages/pymongo/topology.py", line 218, in _select_servers_loop
    raise ServerSelectionTimeoutError(
pymongo.errors.ServerSelectionTimeoutError: client is configured to connect to a replica set named '' but this node belongs to a set named 'None', Timeout: 30s, Topology Description: <TopologyDescription id: 62bdbaf182687350acf1aeec, topology_type: Single, servers: [<ServerDescription ('mongodb', 27017) server_type: Unknown, rtt: None, error=ConfigurationError("client is configured to connect to a replica set named '' but this node belongs to a set named 'None'")>]>

I'm not sure if it's being caused by this PR or not, because I'm not really familiar with these settings. It just seemed suspicious. Looking into it more now.

@ormsbee
Copy link
Contributor

ormsbee commented Jun 30, 2022

Yeah, adding "replicaSet": None, to mongodb_parameters in Tutor got me past this error. I'm going to make a PR to Tutor for this, but I'm not really sure about the ramifications of this. Will link when I have the PR open. FYI @regisb

ormsbee pushed a commit to ormsbee/tutor that referenced this pull request Jun 30, 2022
The pymongo dependency for edx-platform was updated (3.10.1 to 3.12.3)
in openedx/edx-platform#30569

This caused the following error when running the edx-platform database
migration split_modulestore_django.0002_data_migration  as part of
`tutor dev quickstart`:

  pymongo.errors.ServerSelectionTimeoutError: client is configured to
  connect to a replica set named '' but this node belongs to a set named
  'None', Timeout: 30s, Topology Description: <TopologyDescription id:
  62bdbaf182687350acf1aeec, topology_type: Single, servers:
  [<ServerDescription ('mongodb', 27017) server_type: Unknown, rtt:
   None, error=ConfigurationError("client is configured to connect to a
   replica set named '' but this node belongs to a set named 'None'")>]>

This commit explicitly sets replicaSet to None to indicate that it's a
standalone MongoDB instance.
@ormsbee
Copy link
Contributor

ormsbee commented Jun 30, 2022

PR made: overhangio/tutor#699

ormsbee pushed a commit to ormsbee/tutor that referenced this pull request Jun 30, 2022
The pymongo dependency for edx-platform was updated (3.10.1 to 3.12.3)
in openedx/edx-platform#30569

This caused the following error when running the edx-platform database
migration split_modulestore_django.0002_data_migration  as part of
`tutor dev quickstart`:

  pymongo.errors.ServerSelectionTimeoutError: client is configured to
  connect to a replica set named '' but this node belongs to a set named
  'None', Timeout: 30s, Topology Description: <TopologyDescription id:
  62bdbaf182687350acf1aeec, topology_type: Single, servers:
  [<ServerDescription ('mongodb', 27017) server_type: Unknown, rtt:
   None, error=ConfigurationError("client is configured to connect to a
   replica set named '' but this node belongs to a set named 'None'")>]>

This commit explicitly sets replicaSet to None to indicate that it's a
standalone MongoDB instance. I also had to remove the CONTENTSTORE entry
from auth.yml because edx-platform's devstack.py assumes it has a
non-null value (set in common.py), and devstack.py executes before
tutor's development.py can set this replicaSet value.
ormsbee pushed a commit to ormsbee/tutor that referenced this pull request Jun 30, 2022
The pymongo dependency for edx-platform was updated (3.10.1 to 3.12.3)
in openedx/edx-platform#30569

This caused the following error when running the edx-platform database
migration split_modulestore_django.0002_data_migration as part of
`tutor dev quickstart`:

  pymongo.errors.ServerSelectionTimeoutError: client is configured to
  connect to a replica set named '' but this node belongs to a set named
  'None', Timeout: 30s, Topology Description: <TopologyDescription id:
  62bdbaf182687350acf1aeec, topology_type: Single, servers:
  [<ServerDescription ('mongodb', 27017) server_type: Unknown, rtt:
   None, error=ConfigurationError("client is configured to connect to a
   replica set named '' but this node belongs to a set named 'None'")>]>

This commit explicitly sets replicaSet to None to indicate that it's a
standalone MongoDB instance. I also had to remove the CONTENTSTORE entry
from auth.yml because edx-platform's devstack.py assumes it has a
non-null value (set in common.py), and devstack.py executes before
tutor's development.py can set this replicaSet value.
ormsbee pushed a commit to ormsbee/tutor that referenced this pull request Jun 30, 2022
The pymongo dependency for edx-platform was updated (3.10.1 to 3.12.3)
in openedx/edx-platform#30569

This caused the following error when running the edx-platform database
migration split_modulestore_django.0002_data_migration as part of
`tutor dev quickstart`:

  pymongo.errors.ServerSelectionTimeoutError: client is configured to
  connect to a replica set named '' but this node belongs to a set named
  'None', Timeout: 30s, Topology Description: <TopologyDescription id:
  62bdbaf182687350acf1aeec, topology_type: Single, servers:
  [<ServerDescription ('mongodb', 27017) server_type: Unknown, rtt:
   None, error=ConfigurationError("client is configured to connect to a
   replica set named '' but this node belongs to a set named 'None'")>]>

This commit explicitly sets replicaSet to None to indicate that it's a
standalone MongoDB instance. I also had to remove the CONTENTSTORE entry
from auth.yml because edx-platform's devstack.py assumes it has a
non-null value (set in common.py), and devstack.py executes before
tutor's development.py can set this replicaSet value.
@aht007
Copy link
Member Author

aht007 commented Jul 1, 2022

@ormsbee

"replicaSet": None

Yeah this PR would cause issue with split_modulestore_django.0002_data_migration when trying to connect to mongodb if replicaSet is mentioned as empty string. If we don't have any setup for tutor then we are good to go with mentioning it as None. For devstack we didn't have any and hence I mentioned it as None in this PR, for sandboxes we had rs0 replica set configured and hence we are using that and we also have replica sets setup for stage and prod instances.

aht007 added a commit that referenced this pull request Jul 1, 2022
ormsbee pushed a commit to ormsbee/tutor that referenced this pull request Jul 5, 2022
The pymongo dependency for edx-platform was updated (3.10.1 to 3.12.3)
in openedx/edx-platform#30569

This caused the following error when running the edx-platform database
migration split_modulestore_django.0002_data_migration as part of
`tutor dev quickstart`:

  pymongo.errors.ServerSelectionTimeoutError: client is configured to
  connect to a replica set named '' but this node belongs to a set named
  'None', Timeout: 30s, Topology Description: <TopologyDescription id:
  62bdbaf182687350acf1aeec, topology_type: Single, servers:
  [<ServerDescription ('mongodb', 27017) server_type: Unknown, rtt:
   None, error=ConfigurationError("client is configured to connect to a
   replica set named '' but this node belongs to a set named 'None'")>]>

This commit explicitly sets replicaSet to None to indicate that it's a
standalone MongoDB instance. I also had to remove the CONTENTSTORE entry
from auth.yml because edx-platform's devstack.py assumes it has a
non-null value (set in common.py), and devstack.py executes before
tutor's development.py can set this replicaSet value.
regisb pushed a commit to overhangio/tutor that referenced this pull request Jul 5, 2022
The pymongo dependency for edx-platform was updated (3.10.1 to 3.12.3)
in openedx/edx-platform#30569

This caused the following error when running the edx-platform database
migration split_modulestore_django.0002_data_migration as part of
`tutor dev quickstart`:

  pymongo.errors.ServerSelectionTimeoutError: client is configured to
  connect to a replica set named '' but this node belongs to a set named
  'None', Timeout: 30s, Topology Description: <TopologyDescription id:
  62bdbaf182687350acf1aeec, topology_type: Single, servers:
  [<ServerDescription ('mongodb', 27017) server_type: Unknown, rtt:
   None, error=ConfigurationError("client is configured to connect to a
   replica set named '' but this node belongs to a set named 'None'")>]>

This commit explicitly sets replicaSet to None to indicate that it's a
standalone MongoDB instance. I also had to remove the CONTENTSTORE entry
from auth.yml because edx-platform's devstack.py assumes it has a
non-null value (set in common.py), and devstack.py executes before
tutor's development.py can set this replicaSet value.
BbrSofiane pushed a commit to Dicey-Tech/tutor that referenced this pull request Aug 21, 2022
The pymongo dependency for edx-platform was updated (3.10.1 to 3.12.3)
in openedx/edx-platform#30569

This caused the following error when running the edx-platform database
migration split_modulestore_django.0002_data_migration as part of
`tutor dev quickstart`:

  pymongo.errors.ServerSelectionTimeoutError: client is configured to
  connect to a replica set named '' but this node belongs to a set named
  'None', Timeout: 30s, Topology Description: <TopologyDescription id:
  62bdbaf182687350acf1aeec, topology_type: Single, servers:
  [<ServerDescription ('mongodb', 27017) server_type: Unknown, rtt:
   None, error=ConfigurationError("client is configured to connect to a
   replica set named '' but this node belongs to a set named 'None'")>]>

This commit explicitly sets replicaSet to None to indicate that it's a
standalone MongoDB instance. I also had to remove the CONTENTSTORE entry
from auth.yml because edx-platform's devstack.py assumes it has a
non-null value (set in common.py), and devstack.py executes before
tutor's development.py can set this replicaSet value.
BbrSofiane pushed a commit to Dicey-Tech/tutor that referenced this pull request Aug 21, 2022
The pymongo dependency for edx-platform was updated (3.10.1 to 3.12.3)
in openedx/edx-platform#30569

This caused the following error when running the edx-platform database
migration split_modulestore_django.0002_data_migration as part of
`tutor dev quickstart`:

  pymongo.errors.ServerSelectionTimeoutError: client is configured to
  connect to a replica set named '' but this node belongs to a set named
  'None', Timeout: 30s, Topology Description: <TopologyDescription id:
  62bdbaf182687350acf1aeec, topology_type: Single, servers:
  [<ServerDescription ('mongodb', 27017) server_type: Unknown, rtt:
   None, error=ConfigurationError("client is configured to connect to a
   replica set named '' but this node belongs to a set named 'None'")>]>

This commit explicitly sets replicaSet to None to indicate that it's a
standalone MongoDB instance. I also had to remove the CONTENTSTORE entry
from auth.yml because edx-platform's devstack.py assumes it has a
non-null value (set in common.py), and devstack.py executes before
tutor's development.py can set this replicaSet value.
regisb pushed a commit to overhangio/tutor that referenced this pull request Aug 29, 2022
- [Bugfix] Fix MongoDB replica set connection error resulting from edx-platform's pymongo (3.10.1 -> 3.12.3) upgrade ([edx-platform#30569](openedx/edx-platform#30569)). (by @ormsbee)
- [Feature] Upgrade all applications to open-release/nutmeg.2.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants