[Informational/RFC] The removal of MongoDB as a backend choice and the future of Config #3112

Closed
opened 2019-11-11 13:42:51 +01:00 by mikeshardmind · 2 comments
mikeshardmind commented 2019-11-11 13:42:51 +01:00 (Migrated from github.com)

Why remove support for MongoDB?

Recently, we realized a larger issue with Red's config existed. It was an awkward issue in which something we assumed to be true but did not strictly ensure, created several options nobody deciding was happy about.

The options available to us were:

  • Modify the mongo driver to support the edge case.
  • Modify config to be stricter and prevent the edge case.
  • Drop Mongo and let the fact that the other drivers handled the edge case gracefully be enough.

The first option here was very quickly ruled out. We did not have anyone actively developing for Red who wanted to write a large amount of logic for this. Mongo had already been proven to be less suited to our use than originally thought when added. The various issues we've had to work around for it over time made people hesitant to put keep putting more work into it with the limited time available to the people working on Red.

The second option was considered, however, the number of users it could break was unquantifiable.
The large majority of our users use the JSON driver. There are also a large number of private or at least not publicized cogs in existence. Changing config here, especially so close to our next release could have broken any number of these cogs and users, without easy handling available as it would require cog creators changing (and migrating) their data structures.

The third option was also unpopular among people deciding on this, though ultimately is what we have gone with. (#3099) At least people who are using MongoDB have alternatives, and those alternatives will not require any knowledge to swap to beyond the ability to follow basic instructions.
(#3108)

So what does this mean for Config going forward?

Red's config module should largely be in a stable place from here forward. There are still things we would like to improve based on what we've learned from it and from how users have given feedback on how they find it to be useful and what they would like to see in it.

However, I don't think Config should be changed any further going forward.

So if Config won't be receiving further changes, how will the improvements reach users and developers?

Config2

What is Config2?

Just a separate module allowing us to keep Config as-is for people to keep using without any additional work for existing cogs. While Config2 is intended to be easy to switch to, we don't need to tear down Config to make that a reality.

The goals of Config2

  • Make certain restrictions on data stricter.
    • This actually would include the case which led to MongoDB's removal as a backend option for config.
    • A clear set of allowed data types which we enforce consistently will allow more backends, as some backends were previously excluded from consideration because they needed to deal with some levels of ambiguity.
    • This might require some additional work on the part of cog creators, and is an additional reason to leave in the existing config for being easier to use initially.
  • Make it easier to extend to other uses.
    • Removal of __getattr__ use
    • Add a clear way to extend support for specific types
  • Have a clear path to move from config to config2 if a creator wants to.
    • While it won't be a drop-in replacement, it should feel largely similar in use.
    • This would require cog creators to ensure their data is up to the new levels of strictness in advance of taking this path.
    • This is a completely optional upgrade.

Non-goals of config2

  • Remove config
    • The goal of config2 is to allow large internal changes for improvement without large breakage for cogs which can't be immediately updated.
    • I don't believe you need to cripple something people are using to get them to switch. It should be an option which stands up on its own merits.
  • Become an ORM
    • Cog creators are already empowered to require their DB of choice and an ORM as dependencies.
## Why remove support for MongoDB? Recently, we realized a larger issue with Red's config existed. It was an awkward issue in which something we assumed to be true but did not strictly ensure, created several options nobody deciding was happy about. ### The options available to us were: - Modify the mongo driver to support the edge case. - Modify config to be stricter and prevent the edge case. - Drop Mongo and let the fact that the other drivers handled the edge case gracefully be enough. The first option here was very quickly ruled out. We did not have anyone actively developing for Red who wanted to write a large amount of logic for this. Mongo had already been proven to be less suited to our use than originally thought when added. The various issues we've had to work around for it over time made people hesitant to put keep putting more work into it with the limited time available to the people working on Red. The second option was considered, however, the number of users it could break was unquantifiable. The large majority of our users use the JSON driver. There are also a large number of private or at least not publicized cogs in existence. Changing config here, especially so close to our next release could have broken any number of these cogs and users, without easy handling available as it would require cog creators changing (and migrating) their data structures. The third option was also unpopular among people deciding on this, though ultimately is what we have gone with. (#3099) At least people who are using MongoDB have alternatives, and those alternatives will not require any knowledge to swap to beyond the ability to follow basic instructions. (#3108) ## So what does this mean for Config going forward? Red's config module should largely be in a stable place from here forward. There are still things we would like to improve based on what we've learned from it and from how users have given feedback on how they find it to be useful and what they would like to see in it. However, I don't think Config should be changed any further going forward. ## So if Config won't be receiving further changes, how will the improvements reach users and developers? ## Config2 ### What is Config2? Just a separate module allowing us to keep Config as-is for people to keep using without any additional work for existing cogs. While Config2 is intended to be easy to switch to, we don't need to tear down Config to make that a reality. ### The goals of Config2 - Make certain restrictions on data stricter. - This actually would include the case which led to MongoDB's removal as a backend option for config. - A clear set of allowed data types which we enforce consistently will allow more backends, as some backends were previously excluded from consideration because they needed to deal with some levels of ambiguity. - This might require some additional work on the part of cog creators, and is an additional reason to leave in the existing config for being easier to use initially. - Make it easier to extend to other uses. - Removal of ``__getattr__`` use - Add a clear way to extend support for specific types - Have a clear path to move from config to config2 if a creator wants to. - While it won't be a drop-in replacement, it should feel largely similar in use. - This would require cog creators to ensure their data is up to the new levels of strictness in advance of taking this path. - This is a completely optional upgrade. ### Non-goals of config2 - Remove config - The goal of config2 is to allow large internal changes for improvement without large breakage for cogs which can't be immediately updated. - I don't believe you need to cripple something people are using to get them to switch. It should be an option which stands up on its own merits. - Become an ORM - Cog creators are already empowered to require their DB of choice and an ORM as dependencies.
mikeshardmind commented 2019-11-15 03:12:45 +01:00 (Migrated from github.com)

Below is an overview of the changes planned from config to config2 from a cog creator standpoint. Feedback is highly encouraged if something in here does not work for your use case, or if there is something you would want to see added to it.

Usability can be mostly identical. The places where it will differ.

  • You will not be able to set on partial identifiers as a sort of "fast route" for bulk settings values.

    • However, a proper bulk set interface will exist.
  • config.global_value won't work anymore. This will be moved to config.botwide to better support extendability.

  • You will be able to subclass config to add methods. The internals will be documented well enough for this to be feasible.

    • An example of this would be to add support for a method that took a message and an emoji, and returned a config group for a cog that handled reaction events.
  • Config2 will have 3 available ways to handle group access.

    • Legacy mode: attribute access will work as it currently does in config
    • GetItem mode: nested values/groups will be accessible as something such as config.botwide["value_name"]
    • Provide your own: Supporting dependency injection for config groups so that you may add your own methods for use to these.
  • Config2 should be faster for reading values

    • Config2 will include an LRU cache inbetween config and the driver. The size will be available for tuning by cog creators.*
  • Config2 may be faster for setting values as well

    • By enforcing a small bit extra on how data can be set and accessed, we will have an easier time writing optimized code handling some of this.
    • Bulk write methods might get extremely optimized on backends with support for multiple updates (Think DBs)
  • Bulk read access may receive an optimized path as well

Overall the intent is that this should be as close to a drop-in replacement as possible and assuming your data is already compatible, you should be able to use an automatic method to move over and gain features and performance by doing so.

That said, we will also be adding support for a distinction in channel types while providing a generic channel type as well for storage. Upon converting, the converter will check that your data is compatible with the new changes (there aren't many new restrictions) and if provided with a channel type, your current channel data from config will be assumed to be a specific channel type in config2 for the purpose of migrating it. (If your cog stores data about multiple channel types, you won't specify this.)

* Note that in the case of drivers that hold values in memory already, the driver may prevent an LRU cache from being created should it not be a significant improvement. This is intended as a mostly transparent feature aimed at performance first.

Below is an overview of the changes planned from config to config2 from a cog creator standpoint. Feedback is highly encouraged if something in here does not work for your use case, or if there is something you would want to see added to it. Usability *can* be mostly identical. The places where it will differ. - You will not be able to set on partial identifiers as a sort of "fast route" for bulk settings values. - However, a proper bulk set interface will exist. - `config.global_value` won't work anymore. This will be moved to `config.botwide` to better support extendability. - You will be able to subclass config to add methods. The internals will be documented well enough for this to be feasible. - An example of this would be to add support for a method that took a message and an emoji, and returned a config group for a cog that handled reaction events. - Config2 will have 3 available ways to handle group access. - Legacy mode: attribute access will work as it currently does in config - GetItem mode: nested values/groups will be accessible as something such as `config.botwide["value_name"]` - Provide your own: Supporting dependency injection for config groups so that you may add your own methods for use to these. - Config2 should be faster for reading values - Config2 will include an LRU cache inbetween config and the driver. The size will be available for tuning by cog creators.\* - Config2 may be faster for setting values as well - By enforcing a small bit extra on how data can be set and accessed, we will have an easier time writing optimized code handling some of this. - Bulk write methods might get extremely optimized on backends with support for multiple updates (Think DBs) - Bulk read access may receive an optimized path as well Overall the intent is that this should be as close to a drop-in replacement as possible and assuming your data is already compatible, you should be able to use an automatic method to move over and gain features and performance by doing so. That said, we will also be adding support for a distinction in channel types while providing a generic channel type as well for storage. Upon converting, the converter will check that your data is compatible with the new changes (there aren't many new restrictions) and if provided with a channel type, your current channel data from config will be assumed to be a specific channel type in config2 for the purpose of migrating it. (If your cog stores data about multiple channel types, you won't specify this.) \* Note that in the case of drivers that hold values in memory already, the driver may prevent an LRU cache from being created should it not be a significant improvement. This is intended as a mostly transparent feature aimed at performance first.
mikeshardmind commented 2020-02-21 07:09:56 +01:00 (Migrated from github.com)

As I'm no longer handling this, closing.

As I'm no longer handling this, closing.
Sign in to join this conversation.
No labels
Automated PR
Blocked
Blocked By: Damage Control
Blocked By: Dependency
Blocked By: Other PR
Breaking Change
Category: CI
Category: Cogs - Admin
Category: Cogs - Alias
Category: Cogs - Audio
Category: Cogs - Bank
Category: Cogs - Cleanup
Category: Cogs - CustomCommands
Category: Cogs - Dev
Category: Cogs - Downloader
Category: Cogs - Economy
Category: Cogs - Filter
Category: Cogs - General
Category: Cogs - Image
Category: Cogs - Mod
Category: Cogs - Modlog
Category: Cogs - Mutes
Category: Cogs - Permissions
Category: Cogs - Reports
Category: Cogs - Streams
Category: Cogs - Trivia
Category: Cogs - Trivia - Lists
Category: Cogs - Warnings
Category: Core - API - App Commands Package
Category: Core - API - Audio
Category: Core - API - Bank
Category: Core - API - Commands Package
Category: Core - API - Config
Category: Core - API - Other
Category: Core - API - Utils Package
Category: Core - Bot Class
Category: Core - Bot Commands
Category: Core - Command-line Interfaces
Category: Core - Downloader
Category: Core - Help
Category: Core - i18n
Category: Core - Modlog
Category: Core - Other Internals
Category: Core - RPC/ZMQ
Category: Docker
Category: Docs - Changelogs
Category: Docs - For Developers
Category: Docs - Install Guides
Category: Docs - Other
Category: Docs - User Guides
Category: Meta
Category: RPC/ZMQ methods
Category: Vendored Packages
Changelog Entry: Added
Changelog Entry: Pending
Changelog Entry: Skipped
Closed: Duplicate
Closed: External
Closed: Invalid
Closed: User Error
Closed: Won't Fix
Complex Issue
Docs-only
Feature Branch
Good First Issue
Help Wanted
High Priority
Needs Backport To stable-docs
No Activity
No Repro
QA: Bypassed
QA: Changes Requested
QA: Passed
Release Blocker
Status: Accepted
Status: Frozen
Status: In Progress
Status: Needs Discussion
Status: Needs Info
Status: Needs Triage
Status: PRs Welcome
Type: Bug
Type: Dependency Update
Type: Deprecation
Type: Enhancement
Type: Feature
Type: Informational
Type: Merge
Type: Optimisation
Type: Question
Type: Removal
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Mrcoolgamer11/Red-DiscordBot#3112
No description provided.