24#ifndef RESOURCEGROUPS_RESOURCE_GROUP_MGR_H_
25#define RESOURCEGROUPS_RESOURCE_GROUP_MGR_H_
56template <
class Key,
class Value>
164 nullptr,
thread_id, pfs_thread_attr) != 0;
319 assert(ticket !=
nullptr);
393 "SIGNAL restore_finished";
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:251
void release_lock(MDL_ticket *ticket)
Release lock with explicit duration.
Definition: mdl.cc:4269
A granted metadata lock.
Definition: mdl.h:986
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
MDL_context mdl_context
Definition: sql_class.h:966
resourcegroups::Resource_group_ctx * resource_group_ctx()
Get resource group context.
Definition: sql_class.h:4029
mysql_mutex_t LOCK_thd_data
Protects THD data accessed from other threads.
Definition: sql_class.h:1237
std::unordered_map, but with my_malloc and collation-aware comparison.
Definition: map_helpers.h:219
Definition: resource_group.h:49
This is a singleton class that provides various functionalities related to Resource group management,...
Definition: resource_group_mgr.h:70
static Resource_group_mgr * m_instance
Pointer to singleton instance of the Resource_group_mgr class.
Definition: resource_group_mgr.h:402
my_h_service m_h_res_grp_svc
Definition: resource_group_mgr.h:412
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.
Definition: resource_group_mgr.h:380
void deinit()
Definition: resource_group_mgr.cc:274
void set_unsupport_reason(const std::string &reason)
Set reason for resource group not being supported.
Definition: resource_group_mgr.h:107
void remove_resource_group(const std::string &name)
Remove the resource group from the map identified by it's name.
Definition: resource_group_mgr.cc:492
Resource_group_mgr(const Resource_group_mgr &)=delete
~Resource_group_mgr()=default
bool init()
Initialize the Resource group manager.
Definition: resource_group_mgr.cc:313
bool thread_priority_available()
Check if a thread priority setting can be done.
Definition: resource_group_mgr.h:288
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.
Definition: resource_group_mgr.h:428
const char * resource_group_type_str(const Type &type)
String corresponding to the type of resource group.
Definition: resource_group_mgr.h:331
Resource_group * deserialize_resource_group(const dd::Resource_group *res_grp)
Deserialize a DD resource group object into an in-memory Resource group object.
Definition: resource_group_mgr.cc:216
const mysql_service_pfs_resource_group_v3_t * m_resource_group_svc
Definition: resource_group_mgr.h:410
Resource_group_mgr()
Definition: resource_group_mgr.h:457
my_h_service m_h_notification_svc
Definition: resource_group_mgr.h:413
uint32_t m_num_vcpus
Value indicating the number of vcpus in the system.
Definition: resource_group_mgr.h:455
void operator=(const Resource_group_mgr &)=delete
bool disable_pfs_notification()
Definition: resource_group_mgr.cc:526
Resource_group * sys_default_resource_group()
Return the SYS_default resource group instance.
Definition: resource_group_mgr.h:246
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.
Definition: resource_group_mgr.cc:536
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.
Definition: resource_group_mgr.cc:254
void disable_resource_group()
Disable and deinitialize the resource group if it was initialized before.
Definition: resource_group_mgr.h:132
Resource_group * usr_default_resource_group()
Return the USR_default resource group instance.
Definition: resource_group_mgr.h:256
void release_shared_mdl_for_resource_group(THD *thd, MDL_ticket *ticket)
Release the shared MDL lock held on a resource group.
Definition: resource_group_mgr.h:318
mysql_rwlock_t m_map_rwlock
Lock protecting the resource group map.
Definition: resource_group_mgr.h:433
bool is_resource_group_default(const Resource_group *res_grp)
Check if a given Resource group is either SYS_default or USR_default.
Definition: resource_group_mgr.h:277
const char * usr_default_resource_group_name()
Definition: resource_group_mgr.h:267
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.
Definition: resource_group_mgr.cc:501
bool add_resource_group(std::unique_ptr< Resource_group > resource_group_ptr)
Add the resource group to the Resource group map.
Definition: resource_group_mgr.cc:480
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_r...
Definition: resource_group_mgr.cc:422
bool m_thread_priority_available
Boolean value indicating whether setting of thread priority is allowed.
Definition: resource_group_mgr.h:438
bool m_resource_group_support
Bool value indicating support for resource group.
Definition: resource_group_mgr.h:443
static Resource_group_mgr * instance()
Singleton method to return an instance of this class.
Definition: resource_group_mgr.cc:99
Resource_group * m_usr_default_resource_group
Pointer to USR_default and SYS_default resource groups.
Definition: resource_group_mgr.h:420
const char * unsupport_reason()
Reason for resource group not being supported.
Definition: resource_group_mgr.h:99
bool resource_group_support()
Check if support for Resource group exists at runtime.
Definition: resource_group_mgr.h:90
const mysql_service_pfs_notification_v3_t * m_notify_svc
Definition: resource_group_mgr.h:411
static void destroy_instance()
Destroy the singleton instance.
Definition: resource_group_mgr.cc:455
const char * sys_default_resource_group_name()
Get names of SYS_default and USR_default resource groups.
Definition: resource_group_mgr.h:264
uint32_t num_vcpus()
Number of VCPUs present in the system.
Definition: resource_group_mgr.h:341
const mysql_service_registry_t * m_registry_svc
Handles to the PFS registry, Resource Group and Notification services.
Definition: resource_group_mgr.h:409
int m_notify_handle
Definition: resource_group_mgr.h:414
Resource_group * get_resource_group(const std::string &resource_group_name)
Get the in-memory Resource group object corresponding to a resource group name.
Definition: resource_group_mgr.cc:463
bool get_thread_attributes(PSI_thread_attrs *pfs_thread_attr, ulonglong thread_id)
Get the thread attributes identified by PSI thread ID.
Definition: resource_group_mgr.h:160
Resource_group * m_sys_default_resource_group
Definition: resource_group_mgr.h:421
bool post_init()
Post initialization sequence during mysqld startup.
Definition: resource_group_mgr.cc:289
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.
Definition: resource_group_mgr.h:234
std::string m_unsupport_reason
String indicating reason for resource group not being supported.
Definition: resource_group_mgr.h:448
Class that represents an abstraction of the Resource Group.
Definition: resource_group.h:44
#define mysql_mutex_lock(M)
Definition: mysql_mutex.h:50
#define mysql_mutex_unlock(M)
Definition: mysql_mutex.h:57
struct my_h_service_imp * my_h_service
A handle type for acquired Service.
Definition: registry.h:33
Error logging, slow query logging, general query logging: If it's server-internal,...
#define LogErr(severity, ecode,...)
Definition: log_builtins.h:856
enum_mdl_duration
Duration of metadata lock.
Definition: mdl.h:334
#define DBUG_EXECUTE_IF(keyword, a1)
Definition: my_dbug.h:171
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:56
@ INFORMATION_LEVEL
Definition: my_loglevel.h:45
static my_thread_id thread_id
Definition: my_thr_init.cc:63
Instrumentation helpers for rwlock.
The version of the current data dictionary table definitions.
Definition: dictionary_client.h:43
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:76
Definition: dd_resource_group.h:29
Type
Definition: resource_group_basic_types.h:33
const char * SYS_DEFAULT_RESOURCE_GROUP_NAME
Definition: resource_group_mgr.cc:68
const char * USR_DEFAULT_RESOURCE_GROUP_NAME
Definition: resource_group_mgr.cc:69
std::conditional_t< !std::is_array< T >::value, std::unique_ptr< T, detail::Deleter< T > >, std::conditional_t< detail::is_unbounded_array_v< T >, std::unique_ptr< T, detail::Array_deleter< std::remove_extent_t< T > > >, void > > unique_ptr
The following is a common type that is returned by all the ut::make_unique (non-aligned) specializati...
Definition: ut0new.h:2440
Instrumentation helpers for mutexes.
Performance schema instrumentation interface.
required string type
Definition: replication_group_member_actions.proto:34
required bool enabled
Definition: replication_group_member_actions.proto:33
#define SERVICE_TYPE(name)
Generates the standard Service type name.
Definition: service.h:76
Declarations for the Debug Sync Facility.
case opt name
Definition: sslopt-case.h:29
#define STRING_WITH_LEN(X)
Definition: string_with_len.h:29
Definition: mysql_lex_string.h:40
Performance Schema thread type: user/foreground or system/background.
Definition: psi_thread_bits.h:470
An instrumented rwlock structure.
Definition: mysql_rwlock_bits.h:51
Resource_group * m_cur_resource_group
Definition: resource_group_basic_types.h:55
get_thread_system_attrs_by_id_v3_t get_thread_system_attrs_by_id
Definition: pfs_resource_group.h:136
set_thread_resource_group_by_id_v1_t set_thread_resource_group_by_id
Definition: pfs_resource_group.h:134