summaryrefslogtreecommitdiff
path: root/sql/log_event.cc
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2020-01-29 13:50:26 +0100
committerSergei Golubchik <serg@mariadb.org>2020-03-10 19:24:22 +0100
commit7c58e97bf6f80a251046c5b3e7bce826fe058bd6 (patch)
tree7d32d26b320cf83296ee0ede2ea164ad116c4de8 /sql/log_event.cc
parent2ac3121af2767186c489054db5d4871d04b8eef4 (diff)
downloadmariadb-git-7c58e97bf6f80a251046c5b3e7bce826fe058bd6.tar.gz
perfschema memory related instrumentation changes
Diffstat (limited to 'sql/log_event.cc')
-rw-r--r--sql/log_event.cc61
1 files changed, 35 insertions, 26 deletions
diff --git a/sql/log_event.cc b/sql/log_event.cc
index 4c1c18fffff..7ee38a007d1 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -56,6 +56,10 @@
#define my_b_write_string(A, B) my_b_write((A), (uchar*)(B), (uint) (sizeof(B) - 1))
+PSI_memory_key key_memory_log_event;
+PSI_memory_key key_memory_Incident_log_event_message;
+PSI_memory_key key_memory_Rows_query_log_event_rows_query;
+
/**
BINLOG_CHECKSUM variable.
*/
@@ -410,7 +414,7 @@ query_event_uncompress(const Format_description_log_event *description_event,
}
else
{
- new_dst = (char *)my_malloc(alloc_size, MYF(MY_WME));
+ new_dst = (char *)my_malloc(PSI_INSTRUMENT_ME, alloc_size, MYF(MY_WME));
if (!new_dst)
return 1;
@@ -532,7 +536,7 @@ row_log_event_uncompress(const Format_description_log_event *description_event,
}
else
{
- new_dst = (char *)my_malloc(alloc_size, MYF(MY_WME));
+ new_dst = (char *)my_malloc(PSI_INSTRUMENT_ME, alloc_size, MYF(MY_WME));
if (!new_dst)
return 1;
@@ -873,7 +877,7 @@ int Log_event::read_log_event(IO_CACHE* file, String* packet,
*/
sz += MY_AES_BLOCK_SIZE;
#endif
- char *newpkt= (char*)my_malloc(sz, MYF(MY_WME));
+ char *newpkt= (char*)my_malloc(PSI_INSTRUMENT_ME, sz, MYF(MY_WME));
if (!newpkt)
DBUG_RETURN(LOG_READ_MEM);
memcpy(newpkt, packet->ptr(), ev_offset);
@@ -1665,7 +1669,8 @@ Query_log_event::Query_log_event(const char* buf, uint event_len,
*/
#if !defined(MYSQL_CLIENT) && defined(HAVE_QUERY_CACHE)
- if (!(start= data_buf = (Log_event::Byte*) my_malloc(catalog_len + 1
+ if (!(start= data_buf = (Log_event::Byte*) my_malloc(PSI_INSTRUMENT_ME,
+ catalog_len + 1
+ time_zone_len + 1
+ user.length + 1
+ host.length + 1
@@ -1676,7 +1681,8 @@ Query_log_event::Query_log_event(const char* buf, uint event_len,
+ QUERY_CACHE_FLAGS_SIZE,
MYF(MY_WME))))
#else
- if (!(start= data_buf = (Log_event::Byte*) my_malloc(catalog_len + 1
+ if (!(start= data_buf = (Log_event::Byte*) my_malloc(PSI_INSTRUMENT_ME,
+ catalog_len + 1
+ time_zone_len + 1
+ user.length + 1
+ host.length + 1
@@ -1783,8 +1789,8 @@ Query_compressed_log_event::Query_compressed_log_event(const char *buf,
}
/* Reserve one byte for '\0' */
- query_buf = (Log_event::Byte*)my_malloc(ALIGN_SIZE(un_len + 1),
- MYF(MY_WME));
+ query_buf = (Log_event::Byte*)my_malloc(PSI_INSTRUMENT_ME,
+ ALIGN_SIZE(un_len + 1), MYF(MY_WME));
if(query_buf &&
!binlog_buf_uncompress(query, (char *)query_buf, q_len, &un_len))
{
@@ -2033,7 +2039,8 @@ Format_description_log_event(uint8 binlog_ver, const char* server_ver)
common_header_len= LOG_EVENT_HEADER_LEN;
number_of_event_types= LOG_EVENT_TYPES;
/* we'll catch my_malloc() error in is_valid() */
- post_header_len=(uint8*) my_malloc(number_of_event_types*sizeof(uint8)
+ post_header_len=(uint8*) my_malloc(PSI_INSTRUMENT_ME,
+ number_of_event_types*sizeof(uint8)
+ BINLOG_CHECKSUM_ALG_DESC_LEN,
MYF(0));
/*
@@ -2159,8 +2166,8 @@ Format_description_log_event(uint8 binlog_ver, const char* server_ver)
make the slave detect less corruptions).
*/
number_of_event_types= FORMAT_DESCRIPTION_EVENT - 1;
- post_header_len=(uint8*) my_malloc(number_of_event_types*sizeof(uint8),
- MYF(0));
+ post_header_len=(uint8*) my_malloc(PSI_INSTRUMENT_ME,
+ number_of_event_types*sizeof(uint8), MYF(0));
if (post_header_len)
{
post_header_len[START_EVENT_V3-1]= START_V3_HEADER_LEN;
@@ -2228,7 +2235,8 @@ Format_description_log_event(const char* buf,
common_header_len, number_of_event_types));
/* If alloc fails, we'll detect it in is_valid() */
- post_header_len= (uint8*) my_memdup((uchar*)buf+ST_COMMON_HEADER_LEN_OFFSET+1,
+ post_header_len= (uint8*) my_memdup(PSI_INSTRUMENT_ME,
+ buf+ST_COMMON_HEADER_LEN_OFFSET+1,
number_of_event_types*
sizeof(*post_header_len),
MYF(0));
@@ -2517,7 +2525,7 @@ Rotate_log_event::Rotate_log_event(const char* buf, uint event_len,
ident_len= (uint)(event_len - (LOG_EVENT_MINIMAL_HEADER_LEN + post_header_len));
ident_offset= post_header_len;
set_if_smaller(ident_len,FN_REFLEN-1);
- new_log_ident= my_strndup(buf + ident_offset, (uint) ident_len, MYF(MY_WME));
+ new_log_ident= my_strndup(PSI_INSTRUMENT_ME, buf + ident_offset, (uint) ident_len, MYF(MY_WME));
DBUG_PRINT("debug", ("new_log_ident: '%s'", new_log_ident));
DBUG_VOID_RETURN;
}
@@ -2544,7 +2552,7 @@ Binlog_checkpoint_log_event::Binlog_checkpoint_log_event(
binlog_file_len= uint4korr(buf);
if (event_len - (header_size + post_header_len) < binlog_file_len)
return;
- binlog_file_name= my_strndup(buf + post_header_len, binlog_file_len,
+ binlog_file_name= my_strndup(PSI_INSTRUMENT_ME, buf + post_header_len, binlog_file_len,
MYF(MY_WME));
return;
}
@@ -2603,8 +2611,8 @@ Gtid_list_log_event::Gtid_list_log_event(const char *buf, uint event_len,
gl_flags= val & ((uint32)0xf << 28);
buf+= 4;
if (event_len - (header_size + post_header_len) < count*element_size ||
- (!(list= (rpl_gtid *)my_malloc(count*sizeof(*list) + (count == 0),
- MYF(MY_WME)))))
+ (!(list= (rpl_gtid *)my_malloc(PSI_INSTRUMENT_ME,
+ count*sizeof(*list) + (count == 0), MYF(MY_WME)))))
return;
for (i= 0; i < count; ++i)
@@ -2621,7 +2629,8 @@ Gtid_list_log_event::Gtid_list_log_event(const char *buf, uint event_len,
if ((gl_flags & FLAG_IGN_GTIDS))
{
uint32 i;
- if (!(sub_id_list= (uint64 *)my_malloc(count*sizeof(uint64), MYF(MY_WME))))
+ if (!(sub_id_list= (uint64 *)my_malloc(PSI_INSTRUMENT_ME,
+ count*sizeof(uint64), MYF(MY_WME))))
{
my_free(list);
list= NULL;
@@ -2678,8 +2687,8 @@ Gtid_list_log_event::peek(const char *event_start, size_t event_len,
if (event_len < (uint32)fdev->common_header_len + GTID_LIST_HEADER_LEN +
16 * count)
return true;
- if (!(gtid_list= (rpl_gtid *)my_malloc(sizeof(rpl_gtid)*count + (count == 0),
- MYF(MY_WME))))
+ if (!(gtid_list= (rpl_gtid *)my_malloc(PSI_INSTRUMENT_ME,
+ sizeof(rpl_gtid)*count + (count == 0), MYF(MY_WME))))
return true;
*out_gtid_list= gtid_list;
*out_list_len= count;
@@ -2886,7 +2895,7 @@ Create_file_log_event::Create_file_log_event(const char* buf, uint len,
uint header_len= description_event->common_header_len;
uint8 load_header_len= description_event->post_header_len[LOAD_EVENT-1];
uint8 create_file_header_len= description_event->post_header_len[CREATE_FILE_EVENT-1];
- if (!(event_buf= (char*) my_memdup(buf, len, MYF(MY_WME))) ||
+ if (!(event_buf= (char*) my_memdup(PSI_INSTRUMENT_ME, buf, len, MYF(MY_WME))) ||
copy_log_event(event_buf,len,
(((uchar)buf[EVENT_TYPE_OFFSET] == LOAD_EVENT) ?
load_header_len + header_len :
@@ -3188,7 +3197,7 @@ Rows_log_event::Rows_log_event(const char *buf, uint event_len,
/* Just store/use the first tag of this type, skip others */
if (likely(!m_extra_row_data))
{
- m_extra_row_data= (uchar*) my_malloc(infoLen,
+ m_extra_row_data= (uchar*) my_malloc(PSI_INSTRUMENT_ME, infoLen,
MYF(MY_WME));
if (likely(m_extra_row_data != NULL))
{
@@ -3277,7 +3286,7 @@ Rows_log_event::Rows_log_event(const char *buf, uint event_len,
DBUG_PRINT("info",("m_table_id: %llu m_flags: %d m_width: %lu data_size: %lu",
m_table_id, m_flags, m_width, (ulong) data_size));
- m_rows_buf= (uchar*) my_malloc(data_size, MYF(MY_WME));
+ m_rows_buf= (uchar*) my_malloc(PSI_INSTRUMENT_ME, data_size, MYF(MY_WME));
if (likely((bool)m_rows_buf))
{
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
@@ -3300,7 +3309,7 @@ void Rows_log_event::uncompress_buf()
if (!un_len)
return;
- uchar *new_buf= (uchar*) my_malloc(ALIGN_SIZE(un_len), MYF(MY_WME));
+ uchar *new_buf= (uchar*) my_malloc(PSI_INSTRUMENT_ME, ALIGN_SIZE(un_len), MYF(MY_WME));
if (new_buf)
{
if(!binlog_buf_uncompress((char *)m_rows_buf, (char *)new_buf,
@@ -3535,7 +3544,7 @@ Table_map_log_event::Table_map_log_event(const char *buf, uint event_len,
m_colcnt, (long) (ptr_colcnt-(const uchar*)vpart)));
/* Allocate mem for all fields in one go. If fails, caught in is_valid() */
- m_memory= (uchar*) my_multi_malloc(MYF(MY_WME),
+ m_memory= (uchar*) my_multi_malloc(PSI_INSTRUMENT_ME, MYF(MY_WME),
&m_dbnam, (uint) m_dblen + 1,
&m_tblnam, (uint) m_tbllen + 1,
&m_coltype, (uint) m_colcnt,
@@ -3554,7 +3563,7 @@ Table_map_log_event::Table_map_log_event(const char *buf, uint event_len,
if (m_field_metadata_size <= (m_colcnt * 2))
{
uint num_null_bytes= (m_colcnt + 7) / 8;
- m_meta_memory= (uchar *)my_multi_malloc(MYF(MY_WME),
+ m_meta_memory= (uchar *)my_multi_malloc(PSI_INSTRUMENT_ME, MYF(MY_WME),
&m_null_bits, num_null_bytes,
&m_field_metadata, m_field_metadata_size,
NULL);
@@ -3578,7 +3587,7 @@ Table_map_log_event::Table_map_log_event(const char *buf, uint event_len,
{
m_optional_metadata_len= event_len - bytes_read;
m_optional_metadata=
- static_cast<unsigned char*>(my_malloc(m_optional_metadata_len, MYF(MY_WME)));
+ static_cast<unsigned char*>(my_malloc(PSI_INSTRUMENT_ME, m_optional_metadata_len, MYF(MY_WME)));
memcpy(m_optional_metadata, ptr_after_colcnt, m_optional_metadata_len);
}
}
@@ -3958,7 +3967,7 @@ Incident_log_event::Incident_log_event(const char *buf, uint event_len,
m_incident= INCIDENT_NONE;
DBUG_VOID_RETURN;
}
- if (!(m_message.str= (char*) my_malloc(len+1, MYF(MY_WME))))
+ if (!(m_message.str= (char*) my_malloc(key_memory_log_event, len+1, MYF(MY_WME))))
{
/* Mark this event invalid */
m_incident= INCIDENT_NONE;