Skip to content

Commit

Permalink
Merge 10.7 into 10.8
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-m committed Mar 14, 2022
2 parents 00021a9 + e67d46e commit 18bb95b
Show file tree
Hide file tree
Showing 40 changed files with 468 additions and 174 deletions.
10 changes: 9 additions & 1 deletion include/my_valgrind.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2010, 2020, MariaDB Corporation.
/* Copyright (C) 2010, 2022, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -37,6 +37,11 @@
# define MEM_GET_VBITS(a,b,len) __msan_copy_shadow(b,a,len)
# define MEM_SET_VBITS(a,b,len) __msan_copy_shadow(a,b,len)
# define REDZONE_SIZE 8
# ifdef __linux__
# define MSAN_STAT_WORKAROUND(st) MEM_MAKE_DEFINED(st, sizeof(*st))
# else
# define MSAN_STAT_WORKAROUND(st) ((void) 0)
# endif
#elif defined(HAVE_VALGRIND_MEMCHECK_H) && defined(HAVE_valgrind)
# include <valgrind/memcheck.h>
# define HAVE_MEM_CHECK
Expand All @@ -49,6 +54,7 @@
# define MEM_GET_VBITS(a,b,len) VALGRIND_GET_VBITS(a,b,len)
# define MEM_SET_VBITS(a,b,len) VALGRIND_SET_VBITS(a,b,len)
# define REDZONE_SIZE 8
# define MSAN_STAT_WORKAROUND(st) ((void) 0)
#elif defined(__SANITIZE_ADDRESS__) && (!defined(_MSC_VER) || defined (__clang__))
# include <sanitizer/asan_interface.h>
/* How to do manual poisoning:
Expand All @@ -62,6 +68,7 @@
# define MEM_CHECK_DEFINED(a,len) ((void) 0)
# define MEM_GET_VBITS(a,b,len) ((void) 0)
# define MEM_SET_VBITS(a,b,len) ((void) 0)
# define MSAN_STAT_WORKAROUND(st) ((void) 0)
# define REDZONE_SIZE 8
#else
# define MEM_UNDEFINED(a,len) ((void) 0)
Expand All @@ -73,6 +80,7 @@
# define MEM_GET_VBITS(a,b,len) ((void) 0)
# define MEM_SET_VBITS(a,b,len) ((void) 0)
# define REDZONE_SIZE 0
# define MSAN_STAT_WORKAROUND(st) ((void) 0)
#endif /* __has_feature(memory_sanitizer) */

#ifdef HAVE_valgrind
Expand Down
20 changes: 15 additions & 5 deletions mysys/my_lib.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2008, 2020, MariaDB Corporation.
Copyright (c) 2008, 2022, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -332,6 +332,13 @@ int my_fstat(File Filedes, MY_STAT *stat_area,
DBUG_PRINT("my",("fd: %d MyFlags: %lu", Filedes, MyFlags));
#ifdef _WIN32
DBUG_RETURN(my_win_fstat(Filedes, stat_area));
#elif defined HAVE_valgrind
{
int s= fstat(Filedes, stat_area);
if (!s)
MSAN_STAT_WORKAROUND(stat_area);
DBUG_RETURN(s);
}
#else
DBUG_RETURN(fstat(Filedes, (struct stat *) stat_area));
#endif
Expand All @@ -350,11 +357,14 @@ MY_STAT *my_stat(const char *path, MY_STAT *stat_area, myf my_flags)
my_flags)))
goto error;
#ifndef _WIN32
if (! stat((char *) path, (struct stat *) stat_area) )
DBUG_RETURN(stat_area);
if (!stat((char *) path, (struct stat *) stat_area))
{
MSAN_STAT_WORKAROUND(stat_area);
DBUG_RETURN(stat_area);
}
#else
if (! my_win_stat(path, stat_area) )
DBUG_RETURN(stat_area);
if (!my_win_stat(path, stat_area))
DBUG_RETURN(stat_area);
#endif
DBUG_PRINT("error",("Got errno: %d from stat", errno));
my_errno= errno;
Expand Down
7 changes: 5 additions & 2 deletions mysys/my_symlink.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Copyright (c) 2001, 2011, Oracle and/or its affiliates
Copyright (c) 2010, 2017, MariaDB
Copyright (c) 2010, 2022, MariaDB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -113,7 +113,10 @@ int my_is_symlink(const char *filename __attribute__((unused)))
{
#if defined (HAVE_LSTAT) && defined (S_ISLNK)
struct stat stat_buff;
return !lstat(filename, &stat_buff) && S_ISLNK(stat_buff.st_mode);
if (lstat(filename, &stat_buff))
return 0;
MSAN_STAT_WORKAROUND(&stat_buff);
return !!S_ISLNK(stat_buff.st_mode);
#elif defined (_WIN32)
DWORD dwAttr = GetFileAttributes(filename);
return (dwAttr != INVALID_FILE_ATTRIBUTES) &&
Expand Down
2 changes: 2 additions & 0 deletions sql/datadict.cc
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ Table_type dd_frm_type(THD *thd, char *path, LEX_CSTRING *engine_name,
if (mysql_file_fstat(file, &state, MYF(MY_WME)))
goto err;

MSAN_STAT_WORKAROUND(&state);

if (mysql_file_seek(file, 0, SEEK_SET, MYF(MY_WME)))
goto err;

Expand Down
8 changes: 4 additions & 4 deletions sql/ddl_log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2491,11 +2491,11 @@ bool ddl_log_write_entry(DDL_LOG_ENTRY *ddl_log_entry,

if (unlikely(write_ddl_log_file_entry((*active_entry)->entry_pos)))
{
sql_print_error("DDL_LOG: Failed to write entry %u",
(*active_entry)->entry_pos);
ddl_log_release_memory_entry(*active_entry);
*active_entry= 0;
error= TRUE;
sql_print_error("DDL_LOG: Failed to write entry %u",
(*active_entry)->entry_pos);
}
DBUG_RETURN(error);
}
Expand Down Expand Up @@ -2558,13 +2558,13 @@ bool ddl_log_write_execute_entry(uint first_entry,
(*active_entry)->entry_pos, first_entry));
if (write_ddl_log_file_entry((*active_entry)->entry_pos))
{
sql_print_error("DDL_LOG: Error writing execute entry %u",
(*active_entry)->entry_pos);
if (got_free_entry)
{
ddl_log_release_memory_entry(*active_entry);
*active_entry= 0;
}
sql_print_error("DDL_LOG: Error writing execute entry %u",
(*active_entry)->entry_pos);
DBUG_RETURN(TRUE);
}
(void) ddl_log_sync_no_lock();
Expand Down
3 changes: 2 additions & 1 deletion sql/discover.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2009, 2020, MariaDB Corporation.
Copyright (c) 2009, 2022, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -72,6 +72,7 @@ int readfrm(const char *name, const uchar **frmdata, size_t *len)
error= 2;
if (mysql_file_fstat(file, &state, MYF(0)))
goto err;
MSAN_STAT_WORKAROUND(&state);
read_len= (size_t)MY_MIN(FRM_MAX_SIZE, state.st_size); // safety

// Read whole frm file
Expand Down
2 changes: 2 additions & 0 deletions sql/parse_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,8 @@ sql_parse_prepare(const LEX_CSTRING *file_name, MEM_ROOT *mem_root,
DBUG_RETURN(0);
}

MSAN_STAT_WORKAROUND(&stat_info);

if (stat_info.st_size > INT_MAX-1)
{
my_error(ER_FPARSER_TOO_BIG_FILE, MYF(0), file_name->str);
Expand Down
2 changes: 1 addition & 1 deletion sql/sql_parse.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1188,7 +1188,7 @@ static enum enum_server_command fetch_command(THD *thd, char *packet)
DISPATCH_COMMAND_CLOSE_CONNECTION request of THD shutdown
(s. dispatch_command() description)
@retval
DISPATCH_COMMAND_WOULDBLOCK - need to wait for asyncronous operations
DISPATCH_COMMAND_WOULDBLOCK - need to wait for asynchronous operations
to finish. Only returned if parameter
'blocking' is false.
*/
Expand Down
2 changes: 1 addition & 1 deletion storage/innobase/buf/buf0rea.cc
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ buf_read_page_low(
/* Trx sys header is so low in the latching order that we play
safe and do not leave the i/o-completion to an asynchronous
i/o-thread. Change buffer pages must always be read with
syncronous i/o, to make sure they do not get involved in
synchronous i/o, to make sure they do not get involved in
thread deadlocks. */
sync = true;
}
Expand Down
13 changes: 9 additions & 4 deletions storage/innobase/log/log0log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,16 @@ void log_t::attach(log_file_t file, os_offset_t size)
struct stat st;
if (!fstat(log.m_file, &st))
{
MSAN_STAT_WORKAROUND(&st);
const auto st_dev= st.st_dev;
if (!stat("/dev/shm", &st) && st.st_dev == st_dev)
ptr= my_mmap(0, size_t(size),
srv_read_only_mode ? PROT_READ : PROT_READ | PROT_WRITE,
MAP_SHARED, log.m_file, 0);
if (!stat("/dev/shm", &st))
{
MSAN_STAT_WORKAROUND(&st);
if (st.st_dev == st_dev)
ptr= my_mmap(0, size_t(size), srv_read_only_mode
? PROT_READ : PROT_READ | PROT_WRITE,
MAP_SHARED, log.m_file, 0);
}
}
}
#endif /* __linux__ */
Expand Down
24 changes: 19 additions & 5 deletions storage/innobase/os/os0file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,7 @@ os_file_status_posix(

if (!ret) {
/* file exists, everything OK */

MSAN_STAT_WORKAROUND(&statinfo);
} else if (errno == ENOENT || errno == ENOTDIR || errno == ENAMETOOLONG) {
/* file does not exist */
return(true);
Expand Down Expand Up @@ -1309,7 +1309,11 @@ os_file_create_func(
char b[20 + sizeof "/sys/dev/block/" ":"
"/../queue/physical_block_size"];
int f;
if (fstat(file, &st) || st.st_size & 4095) {
if (fstat(file, &st)) {
goto skip_o_direct;
}
MSAN_STAT_WORKAROUND(&st);
if (st.st_size & 4095) {
goto skip_o_direct;
}
if (snprintf(b, sizeof b,
Expand Down Expand Up @@ -1588,8 +1592,10 @@ bool os_file_close_func(os_file_t file)
os_offset_t
os_file_get_size(os_file_t file)
{
struct stat statbuf;
return fstat(file, &statbuf) ? os_offset_t(-1) : statbuf.st_size;
struct stat statbuf;
if (fstat(file, &statbuf)) return os_offset_t(-1);
MSAN_STAT_WORKAROUND(&statbuf);
return statbuf.st_size;
}

/** Gets a file size.
Expand All @@ -1606,6 +1612,7 @@ os_file_get_size(
int ret = stat(filename, &s);

if (ret == 0) {
MSAN_STAT_WORKAROUND(&s);
file_size.m_total_size = s.st_size;
/* st_blocks is in 512 byte sized blocks */
file_size.m_alloc_size = s.st_blocks * 512;
Expand Down Expand Up @@ -1650,6 +1657,8 @@ os_file_get_status_posix(
return(DB_FAIL);
}

MSAN_STAT_WORKAROUND(statinfo);

switch (statinfo->st_mode & S_IFMT) {
case S_IFDIR:
stat_info->type = OS_FILE_TYPE_DIR;
Expand Down Expand Up @@ -2763,7 +2772,7 @@ os_file_set_eof(

#endif /* !_WIN32*/

/** Does a syncronous read or write depending upon the type specified
/** Does a synchronous read or write depending upon the type specified
In case of partial reads/writes the function tries
NUM_RETRIES_ON_PARTIAL_IO times to read/write the complete data.
@param[in] type, IO flags
Expand Down Expand Up @@ -3249,6 +3258,7 @@ os_file_set_size(
if (fstat(file, &statbuf)) {
err = errno;
} else {
MSAN_STAT_WORKAROUND(&statbuf);
os_offset_t current_size = statbuf.st_size;
if (current_size >= size) {
return true;
Expand Down Expand Up @@ -4126,7 +4136,10 @@ void fil_node_t::find_metadata(os_file_t file
#else
struct stat sbuf;
if (!statbuf && !fstat(file, &sbuf))
{
MSAN_STAT_WORKAROUND(&sbuf);
statbuf= &sbuf;
}
if (statbuf)
block_size= statbuf->st_blksize;
# ifdef UNIV_LINUX
Expand Down Expand Up @@ -4159,6 +4172,7 @@ bool fil_node_t::read_page0()
struct stat statbuf;
if (fstat(handle, &statbuf))
return false;
MSAN_STAT_WORKAROUND(&statbuf);
os_offset_t size_bytes= statbuf.st_size;
#else
os_offset_t size_bytes= os_file_get_size(handle);
Expand Down
4 changes: 2 additions & 2 deletions storage/innobase/trx/trx0purge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ TRANSACTIONAL_INLINE inline bool TrxUndoRsegsIterator::set_next()
trx_id_t last_trx_no, tail_trx_no;
{
#ifdef SUX_LOCK_GENERIC
purge_sys.rseg->latch.rd_lock();
purge_sys.rseg->latch.rd_lock(SRW_LOCK_CALL);
#else
transactional_shared_lock_guard<srw_spin_lock> rg
{purge_sys.rseg->latch};
Expand Down Expand Up @@ -636,7 +636,7 @@ TRANSACTIONAL_TARGET static void trx_purge_truncate_history()
if (rseg.space != &space)
continue;
#ifdef SUX_LOCK_GENERIC
rseg.latch.rd_lock();
rseg.latch.rd_lock(SRW_LOCK_CALL);
#else
transactional_shared_lock_guard<srw_spin_lock> g{rseg.latch};
#endif
Expand Down
1 change: 0 additions & 1 deletion storage/maria/s3_func.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ C_MODE_END
C_MODE_START
/* Dummy structures and interfaces to be used when compiling without S3 */
struct s3_info;
typedef struct s3_info S3_INFO;
struct ms3_st;
C_MODE_END
#endif /* WITH_S3_STORAGE_ENGINE */
Expand Down
3 changes: 3 additions & 0 deletions storage/myisam/mi_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ int mi_status(MI_INFO *info, register MI_ISAMINFO *x, uint flag)
x->index_file_name = share->index_file_name;
}
if ((flag & HA_STATUS_TIME) && !mysql_file_fstat(info->dfile, &state, MYF(0)))
{
MSAN_STAT_WORKAROUND(&state);
x->update_time=state.st_mtime;
}
else
x->update_time=0;
if (flag & HA_STATUS_AUTO)
Expand Down
5 changes: 5 additions & 0 deletions storage/spider/mysql-test/spider/bg/r/spider3_fixes.result
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ SELECT 1;
3.1
auto_increment
connection master_1;
SET @original_spider_auto_increment_mode = @@SESSION.spider_auto_increment_mode;
SET SESSION spider_auto_increment_mode = -1;
Warnings:
Warning 138 The option value -1 (use table value) is deprecated and will be removed in a future release
connection slave1_1;
connection master_1;
DROP TABLE IF EXISTS t1, t2;
Expand Down Expand Up @@ -190,6 +194,7 @@ LAST_INSERT_ID()
SELECT MAX(id) FROM t2;
MAX(id)
10000
SET SESSION spider_auto_increment_mode = @original_spider_auto_increment_mode;
connection slave1_1;
SELECT id FROM t1 ORDER BY id;
id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ SELECT 1;
1
auto_increment with partition
connection master_1;
SET @original_spider_auto_increment_mode = @@SESSION.spider_auto_increment_mode;
SET SESSION spider_auto_increment_mode = -1;
Warnings:
Warning 138 The option value -1 (use table value) is deprecated and will be removed in a future release
connection slave1_1;
connection master_1;
DROP TABLE IF EXISTS t1, t2;
Expand Down Expand Up @@ -188,6 +192,7 @@ LAST_INSERT_ID()
SELECT MAX(id) FROM t2;
MAX(id)
10000
SET SESSION spider_auto_increment_mode = @original_spider_auto_increment_mode;
connection slave1_1;
SELECT id FROM t1 ORDER BY id;
id
Expand Down
Loading

0 comments on commit 18bb95b

Please sign in to comment.