![]() |
MySQL 8.0.43
Source Code Documentation
|
This is a singleton class that provides various functionalities related to Resource group management, more importantly the managing and the mapping of resource group names to the corresponding in-memory resource group object. More...
#include <resource_group_mgr.h>
Public Member Functions | |
| bool | resource_group_support () |
| Check if support for Resource group exists at runtime. More... | |
| const char * | unsupport_reason () |
| Reason for resource group not being supported. More... | |
| void | set_unsupport_reason (const std::string &reason) |
| Set reason for resource group not being supported. More... | |
| bool | init () |
| Initialize the Resource group manager. More... | |
| bool | post_init () |
| Post initialization sequence during mysqld startup. More... | |
| void | disable_resource_group () |
| Disable and deinitialize the resource group if it was initialized before. More... | |
| Resource_group * | get_resource_group (const std::string &resource_group_name) |
| Get the in-memory Resource group object corresponding to a resource group name. More... | |
| bool | get_thread_attributes (PSI_thread_attrs *pfs_thread_attr, ulonglong thread_id) |
| Get the thread attributes identified by PSI thread ID. More... | |
| bool | add_resource_group (std::unique_ptr< Resource_group > resource_group_ptr) |
| Add the resource group to the Resource group map. More... | |
| void | remove_resource_group (const std::string &name) |
| Remove the resource group from the map identified by it's name. More... | |
| Resource_group * | create_and_add_in_resource_group_hash (const LEX_CSTRING &name, Type type, bool enabled, std::unique_ptr< std::vector< Range > > cpus, int thr_priority) |
| Create an in-memory resource group identified by its attributes and add it to the resource group map. More... | |
| bool | move_resource_group (Resource_group *from_res_grp, Resource_group *to_res_grp) |
| Move the Resource group of the current thread identified by from_res_group to the Resource group to_res_grp. More... | |
| Resource_group * | deserialize_resource_group (const dd::Resource_group *res_grp) |
| Deserialize a DD resource group object into an in-memory Resource group object. More... | |
| void | set_res_grp_in_pfs (const char *name, int length, ulonglong thread_id) |
| Set Resource group name in the PFS table performance_schema.threads for the PFS thread id. More... | |
| Resource_group * | sys_default_resource_group () |
| Return the SYS_default resource group instance. More... | |
| Resource_group * | usr_default_resource_group () |
| Return the USR_default resource group instance. More... | |
| const char * | sys_default_resource_group_name () |
| Get names of SYS_default and USR_default resource groups. More... | |
| const char * | usr_default_resource_group_name () |
| bool | is_resource_group_default (const Resource_group *res_grp) |
| Check if a given Resource group is either SYS_default or USR_default. More... | |
| bool | thread_priority_available () |
| Check if a thread priority setting can be done. More... | |
| bool | acquire_shared_mdl_for_resource_group (THD *thd, const char *res_grp_name, enum_mdl_duration lock_duration, MDL_ticket **ticket, bool acquire_lock) |
| Acquire an shared MDL lock on resource group name. More... | |
| void | release_shared_mdl_for_resource_group (THD *thd, MDL_ticket *ticket) |
| Release the shared MDL lock held on a resource group. More... | |
| const char * | resource_group_type_str (const Type &type) |
| String corresponding to the type of resource group. More... | |
| uint32_t | num_vcpus () |
| Number of VCPUs present in the system. More... | |
| void | deinit () |
| bool | disable_pfs_notification () |
| bool | switch_resource_group_if_needed (THD *thd, resourcegroups::Resource_group **src_res_grp, resourcegroups::Resource_group **dest_res_grp, MDL_ticket **ticket, MDL_ticket **cur_ticket) |
| Switch Resource Group if it is requested by environment. More... | |
| void | restore_original_resource_group (THD *thd, resourcegroups::Resource_group *src_res_grp, resourcegroups::Resource_group *dest_res_grp) |
| Restore original resource group if resource group switching was performed before. More... | |
Static Public Member Functions | |
| static Resource_group_mgr * | instance () |
| Singleton method to return an instance of this class. More... | |
| static void | destroy_instance () |
| Destroy the singleton instance. More... | |
Private Member Functions | |
| Resource_group_mgr () | |
| ~Resource_group_mgr ()=default | |
| Resource_group_mgr (const Resource_group_mgr &)=delete | |
| void | operator= (const Resource_group_mgr &)=delete |
Private Attributes | |
| const mysql_service_registry_t * | m_registry_svc |
| Handles to the PFS registry, Resource Group and Notification services. More... | |
| const mysql_service_pfs_resource_group_v3_t * | m_resource_group_svc |
| const mysql_service_pfs_notification_v3_t * | m_notify_svc |
| my_h_service | m_h_res_grp_svc |
| my_h_service | m_h_notification_svc |
| int | m_notify_handle |
| Resource_group * | m_usr_default_resource_group |
| Pointer to USR_default and SYS_default resource groups. More... | |
| Resource_group * | m_sys_default_resource_group |
| collation_unordered_map< std::string, std::unique_ptr< Resource_group > > * | m_resource_group_hash |
| Map mapping resource group name with it's corresponding in-memory Resource_group object. More... | |
| mysql_rwlock_t | m_map_rwlock |
| Lock protecting the resource group map. More... | |
| bool | m_thread_priority_available |
| Boolean value indicating whether setting of thread priority is allowed. More... | |
| bool | m_resource_group_support |
| Bool value indicating support for resource group. More... | |
| std::string | m_unsupport_reason |
| String indicating reason for resource group not being supported. More... | |
| uint32_t | m_num_vcpus |
| Value indicating the number of vcpus in the system. More... | |
Static Private Attributes | |
| static Resource_group_mgr * | m_instance = nullptr |
| Pointer to singleton instance of the Resource_group_mgr class. More... | |
This is a singleton class that provides various functionalities related to Resource group management, more importantly the managing and the mapping of resource group names to the corresponding in-memory resource group object.
|
inlineprivate |
|
privatedefault |
|
privatedelete |
| bool resourcegroups::Resource_group_mgr::acquire_shared_mdl_for_resource_group | ( | THD * | thd, |
| const char * | res_grp_name, | ||
| enum_mdl_duration | lock_duration, | ||
| MDL_ticket ** | ticket, | ||
| bool | acquire_lock | ||
| ) |
Acquire an shared MDL lock on resource group name.
| thd | Pointer to THD context. | |
| res_grp_name | Resource group name. | |
| lock_duration | Duration of lock. | |
| [out] | ticket | reference to ticket object. |
| acquire_lock | true if one needs to wait on lock else false. |
| bool resourcegroups::Resource_group_mgr::add_resource_group | ( | std::unique_ptr< Resource_group > | resource_group_ptr | ) |
Add the resource group to the Resource group map.
| resource_group_ptr | pointer to in-memory Resource_group. |
| Resource_group * resourcegroups::Resource_group_mgr::create_and_add_in_resource_group_hash | ( | const LEX_CSTRING & | name, |
| Type | type, | ||
| bool | enabled, | ||
| std::unique_ptr< std::vector< Range > > | cpus, | ||
| int | thr_priority | ||
| ) |
Create an in-memory resource group identified by its attributes and add it to the resource group map.
| name | Name of resource group. |
| type | Type of resource group. |
| enabled | Is resource group enabled? |
| cpus | Pointer to list of Range objects representing CPU IDS. |
| thr_priority | Thread priority. |
| void resourcegroups::Resource_group_mgr::deinit | ( | ) |
| Resource_group * resourcegroups::Resource_group_mgr::deserialize_resource_group | ( | const dd::Resource_group * | res_grp | ) |
Deserialize a DD resource group object into an in-memory Resource group object.
| res_grp | Pointer to DD Resource_group object. |
|
static |
Destroy the singleton instance.
| bool resourcegroups::Resource_group_mgr::disable_pfs_notification | ( | ) |
|
inline |
Disable and deinitialize the resource group if it was initialized before.
| Resource_group * resourcegroups::Resource_group_mgr::get_resource_group | ( | const std::string & | resource_group_name | ) |
Get the in-memory Resource group object corresponding to a resource group name.
| resource_group_name | Name of the resource group. |
|
inline |
Get the thread attributes identified by PSI thread ID.
| [out] | pfs_thread_attr | Pointer to thread attribute object which shall be populated if the call is successful. |
| thread_id | PFS thread identifier representing a thread of mysqld. |
| bool resourcegroups::Resource_group_mgr::init | ( | ) |
Initialize the Resource group manager.
Must be called before instance() can be used.
|
static |
Singleton method to return an instance of this class.
|
inline |
Check if a given Resource group is either SYS_default or USR_default.
| bool resourcegroups::Resource_group_mgr::move_resource_group | ( | Resource_group * | from_res_grp, |
| Resource_group * | to_res_grp | ||
| ) |
Move the Resource group of the current thread identified by from_res_group to the Resource group to_res_grp.
| from_res_grp | Pointer to current Resource_group of the thread. |
| to_res_grp | Pointer to the destination Resource group which the thread will be switched to. |
|
inline |
Number of VCPUs present in the system.
|
privatedelete |
| bool resourcegroups::Resource_group_mgr::post_init | ( | ) |
Post initialization sequence during mysqld startup.
|
inline |
Release the shared MDL lock held on a resource group.
| thd | THD context. |
| ticket | Pointer to lock ticket object. |
| void resourcegroups::Resource_group_mgr::remove_resource_group | ( | const std::string & | name | ) |
Remove the resource group from the map identified by it's name.
| name | of the resource group. |
|
inline |
Check if support for Resource group exists at runtime.
|
inline |
String corresponding to the type of resource group.
| type | Type of resource group. |
|
inline |
Restore original resource group if resource group switching was performed before.
| thd | Thread context. | |
| [out] | src_res_grp | resource group to that switching was performed |
| [out] | dest_res_grp | original resource group to that switching is performed |
|
inline |
Set Resource group name in the PFS table performance_schema.threads for the PFS thread id.
| name | Pointer to name of resource group. |
| length | length of the resource group name. |
| thread_id | PFS thread id of the thread, |
|
inline |
Set reason for resource group not being supported.
| reason | string representing reason for resource group unsupported. |
| bool resourcegroups::Resource_group_mgr::switch_resource_group_if_needed | ( | THD * | thd, |
| resourcegroups::Resource_group ** | src_res_grp, | ||
| resourcegroups::Resource_group ** | dest_res_grp, | ||
| MDL_ticket ** | ticket, | ||
| MDL_ticket ** | cur_ticket | ||
| ) |
Switch Resource Group if it is requested by environment.
| thd | THD context. | |
| [out] | src_res_grp | Original resource group from that switching is performed |
| [out] | dest_res_grp | Destination resource group to that switching is performed |
| [out] | ticket | Pointer to MDL ticket object. |
| [out] | cur_ticket | Pointer to current resource group MDL ticket object. |
|
inline |
Return the SYS_default resource group instance.
|
inline |
Get names of SYS_default and USR_default resource groups.
Called by thread_create_callback only.
|
inline |
Check if a thread priority setting can be done.
|
inline |
Reason for resource group not being supported.
|
inline |
Return the USR_default resource group instance.
|
inline |
|
private |
|
private |
|
staticprivate |
Pointer to singleton instance of the Resource_group_mgr class.
|
private |
Lock protecting the resource group map.
|
private |
|
private |
|
private |
Value indicating the number of vcpus in the system.
This is initialized during startup so that we do not call the platform API every time which is expensive.
|
private |
Handles to the PFS registry, Resource Group and Notification services.
|
private |
Map mapping resource group name with it's corresponding in-memory Resource_group object.
|
private |
Bool value indicating support for resource group.
|
private |
|
private |
|
private |
Boolean value indicating whether setting of thread priority is allowed.
|
private |
String indicating reason for resource group not being supported.
|
private |
Pointer to USR_default and SYS_default resource groups.
Owernship of these pointers is resource group hash.