As database technology evolves and business scenarios become more diverse, flexibility and scalability have become core capabilities of modern distributed database systems. To meet the demand for efficient and flexible feature extensions, OceanBase Database has introduced a plugin mechanism, offering a modular and low-intrusion approach for feature expansion. With this mechanism, users can dynamically load, unload, and update feature modules without modifying the core code, enabling efficient customization and expansion of the database system.
Notice
The plugin mechanism in OceanBase Database is currently an experimental feature and is not recommended for use in production environments. Its functionality and stability are still being refined. At this stage, the plugin mechanism primarily supports the following scenarios:
- Tokenizer plugins: Extend the full-text search capabilities of the database and allow users to customize tokenization logic.
- Feature validation: Users can experience the plugin mechanism through this experimental feature and provide valuable feedback for future feature expansions.
Advantages of the Plugin Mechanism
Simplified Expansion
The plugin mechanism of OceanBase Database allows you to easily add new feature modules to OceanBase Database without modifying the core code. This modular design makes it easier and more intuitive to expand functionality.
Efficient Updates
The plugin mechanism supports rapid iteration and updates, allowing users to promptly obtain and apply the latest feature improvements and fixes. This quick response capability ensures the system remains in optimal condition, meeting evolving business needs.
Customizable Features
The plugin mechanism allows users to customize specific features based on their business requirements, enhancing the system's flexibility and adaptability. Users can selectively load or unload plugins to ensure only the necessary feature modules are running.
Community and Ecosystem Support
Through the plugin mechanism, OceanBase Database users can share and publish custom plugins, fostering community interaction and collaboration, and enriching the plugin ecosystem. This not only enhances the diversity of OceanBase Database's features but also drives the growth of the entire community.
Plugin mechanism
OceanBase Database plugins are components that extend database functionality in the form of dynamic link libraries. You can add the following features without modifying the OceanBase Database:
- Customized features, such as special tokenization algorithms.
- Third-party ecosystem compatibility, such as support for specific data formats.
- Commercially available expansion modules.
Plugin system architecture
The plugin system of OceanBase Database is designed to allow developers to quickly expand its capabilities.
The relevant modules are as follows:
Plugin library itself: includes external tables and tokenizers.
Plugin Interfaces: specifies the version numbers of each plugin interface.
Note
Each plugin interface has its own version number.
Plugin API: the interfaces provided by OceanBase Database to the plugin library for accessing OceanBase Database capabilities.
OceanBase Database defines the interfaces that each plugin must implement. Each type of plugin has its own specific interfaces (Plugin Interfaces), such as for external tables and tokenizers. The plugin library implements these interfaces, and OceanBase Database can call the plugin implementations when loading the plugin library. When a plugin needs to use OceanBase Database capabilities, such as accessing data or logging, it can call the Plugin API (Plugin API). The implementation of the Plugin API is within OceanBase Database, referred to as Plugin API Implementation.
This allows plugin developers to work without needing to understand the source code of OceanBase Database. They only need to rely on the plugin development library provided by OceanBase Database. Additionally, each type of plugin has sample code available for reference, such as sample code for tokenizer plugins.
Internally, OceanBase Database includes the Plugin Interface Adaptor module to convert plugin interfaces and ensure compatibility with its existing feature definitions.
When a user installs a plugin, the plugin object is maintained internally by the Plugin Manager. OceanBase Database also uses the Plugin Manager module to locate plugins when they are needed.
Compatibility
Since plugins are independent of OceanBase Database, compatibility between different versions of plugins and OceanBase Database needs to be considered. OceanBase Database strives to maintain compatibility with older versions of plugins to ensure that plugin operations do not cause serious runtime issues (such as system crashes) due to interface problems.
OceanBase Database uses two types of version numbers to ensure compatibility: plugin interface (Plugin Interfaces) version numbers and plugin API (Plugin API) version numbers.
Each plugin interface has its own version number. When a plugin is compiled, it must specify which version of the interface it implements. When the plugin library is installed in the database, OceanBase Database checks the version number. Additionally, to minimize the need for recompilation, plugin interfaces can only be added, not removed. When OceanBase Database calls a plugin interface, it also handles compatibility with older versions of the code, typically done by the Plugin Adaptor. For example, the first version of the tokenizer plugin interface is 0.1.0. After adding the check_if_charset_supported interface, the new version number is 0.2.0. When writing the plugin library, you can use the version number to determine whether to implement the new check_if_charset_supported interface.
Another type of version number designed by OceanBase Database is the plugin API version number. This version number prevents situations where a plugin library needs to access a newer API, but the running OceanBase Database version is outdated and cannot provide that API. An error is thrown during installation in such cases. Like plugin interface version numbers, plugin API version numbers are incremented each time new content is added.
It's worth noting that there are multiple plugin interface version numbers, each corresponding to a specific type of interface, such as the tokenizer plugin interface and the external table plugin interface. However, there is only one global plugin API version number. Even if a new API is added specifically for the tokenizer plugin, the global plugin API version number still needs to be incremented.