Commit 810b2c3d authored by serg@serg.mylan's avatar serg@serg.mylan

remove the rest of isam/merge references

fix a race condition in TC_LOG_BINLOG::unlog
parent 2b8ff694
......@@ -24,7 +24,7 @@ pkginclude_HEADERS = my_dbug.h m_string.h my_sys.h my_list.h my_xml.h \
sslopt-vars.h sslopt-case.h sql_common.h keycache.h \
mysql_time.h $(BUILT_SOURCES)
noinst_HEADERS = config-win.h config-os2.h config-netware.h \
nisam.h heap.h merge.h my_bitmap.h\
heap.h my_bitmap.h\
myisam.h myisampack.h myisammrg.h ft_global.h\
mysys_err.h my_base.h help_start.h help_end.h \
my_nosys.h my_alarm.h queues.h rijndael.h sha1.h \
......
......@@ -351,7 +351,6 @@ inline double ulonglong2double(ulonglong value)
#define DO_NOT_REMOVE_THREAD_WRAPPERS
#define thread_safe_increment(V,L) InterlockedIncrement((long*) &(V))
#define thread_safe_decrement(V,L) InterlockedDecrement((long*) &(V))
#define thread_safe_dec_and_test(V, L) thread_safe_decrement(V,L)
/* The following is only used for statistics, so it should be good enough */
#ifdef __NT__ /* This should also work on Win98 but .. */
#define thread_safe_add(V,C,L) InterlockedExchangeAdd((long*) &(V),(C))
......
......@@ -678,7 +678,6 @@ extern pthread_t shutdown_th, main_th, signal_th;
#ifdef HAVE_ATOMIC_ADD
#define thread_safe_increment(V,L) atomic_inc((atomic_t*) &V)
#define thread_safe_decrement(V,L) atomic_dec((atomic_t*) &V)
#define thread_safe_dec_and_test(V, L) atomic_dec_and_test((atomic_t*) &V)
#define thread_safe_add(V,C,L) atomic_add((C),(atomic_t*) &V)
#define thread_safe_sub(V,C,L) atomic_sub((C),(atomic_t*) &V)
#else
......@@ -689,22 +688,6 @@ extern pthread_t shutdown_th, main_th, signal_th;
#define thread_safe_add(V,C,L) (pthread_mutex_lock((L)), (V)+=(C), pthread_mutex_unlock((L)))
#define thread_safe_sub(V,C,L) \
(pthread_mutex_lock((L)), (V)-=(C), pthread_mutex_unlock((L)))
#ifdef __cplusplus
static inline bool thread_safe_dec_and_test(ulong &V, pthread_mutex_t *L)
{
ulong res;
pthread_mutex_lock(L);
res=--V;
pthread_mutex_unlock(L);
return res==0;
}
#else
/*
what should we do ? define it as static ?
a regular function somewhere in mysys/ ?
for now it's only used in c++ code, so there's no need to bother
*/
#endif
#endif /* HAVE_ATOMIC_ADD */
#ifdef SAFE_STATISTICS
#define statistic_increment(V,L) thread_safe_increment((V),(L))
......
......@@ -54,10 +54,9 @@ extern int NEAR my_errno; /* Last error in mysys */
#define MY_FAE 8 /* Fatal if any error */
#define MY_WME 16 /* Write message on error */
#define MY_WAIT_IF_FULL 32 /* Wait and try again if disk full error */
#define MY_RAID 64 /* Support for RAID (not the "Johnson&Johnson"-s one ;) */
#define MY_FULL_IO 512 /* For my_read - loop intil I/O
is complete
*/
#define MY_IGNORE_BADFD 32 /* my_sync: ignore 'bad descriptor' errors */
#define MY_RAID 64 /* Support for RAID */
#define MY_FULL_IO 512 /* For my_read - loop intil I/O is complete */
#define MY_DONT_CHECK_FILESIZE 128 /* Option to init_io_cache() */
#define MY_LINK_WARNING 32 /* my_redel() gives warning if links */
#define MY_COPYTIME 64 /* my_redel() copys time */
......@@ -72,7 +71,7 @@ extern int NEAR my_errno; /* Last error in mysys */
#define MY_FREE_ON_ERROR 128 /* my_realloc() ; Free old ptr on error */
#define MY_HOLD_ON_ERROR 256 /* my_realloc() ; Return old ptr on error */
#define MY_THREADSAFE 128 /* pread/pwrite: Don't allow interrupts */
#define MY_DONT_OVERWRITE_FILE 1024 /* my_copy; Don't overwrite file */
#define MY_DONT_OVERWRITE_FILE 1024 /* my_copy: Don't overwrite file */
#define MY_CHECK_ERROR 1 /* Params to my_end; Check open-close */
#define MY_GIVE_INFO 2 /* Give time info about process*/
......
......@@ -24,7 +24,6 @@
#undef HAVE_PSTACK /* No stacktrace */
#undef HAVE_DLOPEN /* No udf functions */
#undef HAVE_OPENSSL
#undef HAVE_ISAM
#undef HAVE_SMEM /* No shared memory */
#undef HAVE_NDBCLUSTER_DB /* No NDB cluster */
......
......@@ -3,12 +3,10 @@ CREATE TABLE t1 (
gesuchnr int(11) DEFAULT '0' NOT NULL,
benutzer_id int(11) DEFAULT '0' NOT NULL,
PRIMARY KEY (gesuchnr,benutzer_id)
) engine=ISAM;
);
replace into t1 (gesuchnr,benutzer_id) values (2,1);
replace into t1 (gesuchnr,benutzer_id) values (1,1);
replace into t1 (gesuchnr,benutzer_id) values (1,1);
alter table t1 engine=myisam;
replace into t1 (gesuchnr,benutzer_id) values (1,1);
alter table t1 engine=heap;
replace into t1 (gesuchnr,benutzer_id) values (1,1);
drop table t1;
......
-- source include/have_isam.inc
#
# Test of REPLACE with ISAM and MyISAM and HEAP
# Test of REPLACE with MyISAM and HEAP
#
--disable_warnings
......@@ -12,13 +10,11 @@ CREATE TABLE t1 (
gesuchnr int(11) DEFAULT '0' NOT NULL,
benutzer_id int(11) DEFAULT '0' NOT NULL,
PRIMARY KEY (gesuchnr,benutzer_id)
) engine=ISAM;
);
replace into t1 (gesuchnr,benutzer_id) values (2,1);
replace into t1 (gesuchnr,benutzer_id) values (1,1);
replace into t1 (gesuchnr,benutzer_id) values (1,1);
alter table t1 engine=myisam;
replace into t1 (gesuchnr,benutzer_id) values (1,1);
alter table t1 engine=heap;
replace into t1 (gesuchnr,benutzer_id) values (1,1);
drop table t1;
......
......@@ -31,6 +31,7 @@ xa end 'testa','testb';
connect (con1,localhost,,,);
connection con1;
# gtrid [ , bqual [ , formatID ] ]
xa start 0x7465737462, 0x2030405060, 0xb;
insert t1 values (40);
xa end 'testb',' 0@P`',11;
......
......@@ -27,7 +27,14 @@
my_flags Flags (now only MY_WME is supported)
NOTE
If file system supports its, only file data is synced, not inode date
If file system supports its, only file data is synced, not inode data.
MY_IGNORE_BADFD is useful when fd is "volatile" - not protected by a
mutex. In this case by the time of fsync(), fd may be already closed by
another thread, or even reassigned to a different file. With this flag -
MY_IGNORE_BADFD - such a situation will not be considered an error.
(which is correct behaviour, if we know that the other thread synced the
file before closing)
RETURN
0 ok
......@@ -55,10 +62,15 @@ int my_sync(File fd, myf my_flags)
if (res)
{
if (!(my_errno= errno))
int er= errno;
if (!(my_errno= er))
my_errno= -1; /* Unknown error */
if (my_flags & MY_WME)
if (my_flags & MY_IGNORE_BADFD &&
(er == EBADF || er == EINVAL || er == EROFS))
res= 0;
else if (my_flags & MY_WME)
my_error(EE_SYNC, MYF(ME_BELL+ME_WAITTANG), my_filename(fd), my_errno);
}
DBUG_RETURN(res);
} /* my_read */
} /* my_sync */
......@@ -25,10 +25,6 @@
#include "ha_heap.h"
#include "ha_myisam.h"
#include "ha_myisammrg.h"
#ifdef HAVE_ISAM
#include "ha_isam.h"
#include "ha_isammrg.h"
#endif
#ifdef HAVE_BERKELEY_DB
#include "ha_berkeley.h"
#endif
......
......@@ -1531,18 +1531,20 @@ bool MYSQL_LOG::write(THD *thd,enum enum_server_command command,
return 0;
}
inline bool sync_binlog(IO_CACHE *cache)
bool MYSQL_LOG::flush_and_sync()
{
if (sync_binlog_period == ++sync_binlog_counter && sync_binlog_period)
int err=0, fd=log_file.file;
safe_mutex_assert_owner(&LOCK_log);
if (flush_io_cache(&log_file))
return 1;
if (++sync_binlog_counter >= sync_binlog_period && sync_binlog_period)
{
sync_binlog_counter= 0;
return my_sync(cache->file, MYF(MY_WME));
err=my_sync(fd, MYF(MY_WME));
}
return 0;
return err;
}
/*
Write an event to the binary log
*/
......@@ -1684,8 +1686,10 @@ bool MYSQL_LOG::write(Log_event *event_info)
if (file == &log_file) // we are writing to the real log (disk)
{
if (flush_io_cache(file) || sync_binlog(file))
if (flush_and_sync())
goto err;
signal_update();
rotate_and_purge(RP_LOCK_LOG_IS_ALREADY_LOCKED);
}
error=0;
......@@ -1698,15 +1702,9 @@ err:
my_error(ER_ERROR_ON_WRITE, MYF(0), name, errno);
write_error=1;
}
if (file == &log_file)
{
signal_update();
rotate_and_purge(RP_LOCK_LOG_IS_ALREADY_LOCKED);
}
}
pthread_mutex_unlock(&LOCK_log);
DBUG_RETURN(error);
}
......@@ -1813,7 +1811,7 @@ bool MYSQL_LOG::write(THD *thd, IO_CACHE *cache, Log_event *commit_event)
if (commit_event->write(&log_file))
goto err;
DBUG_skip_commit:
if (flush_io_cache(&log_file) || sync_binlog(&log_file))
if (flush_and_sync())
goto err;
DBUG_EXECUTE_IF("half_binlogged_transaction", abort(););
if (cache->error) // Error on read
......@@ -1983,22 +1981,22 @@ bool MYSQL_LOG::write(THD *thd,const char *query, uint query_length,
SYNOPSIS
wait_for_update()
thd Thread variable
master_or_slave If 0, the caller is the Binlog_dump thread from master;
is_slave If 0, the caller is the Binlog_dump thread from master;
if 1, the caller is the SQL thread from the slave. This
influences only thd->proc_info.
NOTES
One must have a lock on LOCK_log before calling this function.
This lock will be freed before return! That's required by
This lock will be released before return! That's required by
THD::enter_cond() (see NOTES in sql_class.h).
*/
void MYSQL_LOG::wait_for_update(THD* thd, bool master_or_slave)
void MYSQL_LOG::wait_for_update(THD* thd, bool is_slave)
{
const char *old_msg;
DBUG_ENTER("wait_for_update");
old_msg= thd->enter_cond(&update_cond, &LOCK_log,
master_or_slave ?
is_slave ?
"Has read all relay log; waiting for the slave I/O "
"thread to update it" :
"Has sent all binlog to slave; waiting for binlog "
......@@ -2051,7 +2049,12 @@ void MYSQL_LOG::close(uint exiting)
my_pwrite(log_file.file, &flags, 1, offset, MYF(0));
}
if (my_close(log_file.file,MYF(0)) < 0 && ! write_error)
if (my_sync(log_file.file,MYF(MY_WME)) && ! write_error)
{
write_error=1;
sql_print_error(ER(ER_ERROR_ON_WRITE), name, errno);
}
if (my_close(log_file.file,MYF(MY_WME)) && ! write_error)
{
write_error=1;
sql_print_error(ER(ER_ERROR_ON_WRITE), name, errno);
......@@ -2945,8 +2948,10 @@ int TC_LOG_BINLOG::log(THD *thd, my_xid xid)
void TC_LOG_BINLOG::unlog(ulong cookie, my_xid xid)
{
if (thread_safe_dec_and_test(prepared_xids, &LOCK_prep_xids))
pthread_mutex_lock(&LOCK_prep_xids);
if (--prepared_xids == 0)
pthread_cond_signal(&COND_prep_xids);
pthread_mutex_unlock(&LOCK_prep_xids);
rotate_and_purge(0); // as ::write() did not rotate
}
......
......@@ -1126,10 +1126,6 @@ extern MY_BITMAP temp_pool;
extern String my_empty_string;
extern const String my_null_string;
extern SHOW_VAR init_vars[],status_vars[], internal_vars[];
extern SHOW_COMP_OPTION have_isam;
extern SHOW_COMP_OPTION have_innodb;
extern SHOW_COMP_OPTION have_berkeley_db;
extern SHOW_COMP_OPTION have_ndbcluster;
extern struct system_variables global_system_variables;
extern struct system_variables max_system_variables;
extern struct system_status_var global_status_var;
......@@ -1150,12 +1146,13 @@ extern struct my_option my_long_options[];
extern SHOW_COMP_OPTION have_isam, have_innodb, have_berkeley_db;
extern SHOW_COMP_OPTION have_example_db, have_archive_db, have_csv_db;
extern SHOW_COMP_OPTION have_federated_db;
extern SHOW_COMP_OPTION have_blackhole_db;
extern SHOW_COMP_OPTION have_ndbcluster;
extern SHOW_COMP_OPTION have_raid, have_openssl, have_symlink;
extern SHOW_COMP_OPTION have_query_cache, have_berkeley_db, have_innodb;
extern SHOW_COMP_OPTION have_query_cache;
extern SHOW_COMP_OPTION have_geometry, have_rtree_keys;
extern SHOW_COMP_OPTION have_crypt;
extern SHOW_COMP_OPTION have_compress;
extern SHOW_COMP_OPTION have_blackhole_db;
#ifndef __WIN__
extern pthread_t signal_thread;
......
......@@ -30,9 +30,6 @@
#include "ha_innodb.h"
#endif
#include "ha_myisam.h"
#ifdef HAVE_ISAM
#include "ha_isam.h"
#endif
#ifdef HAVE_NDBCLUSTER_DB
#include "ha_ndbcluster.h"
#endif
......@@ -47,11 +44,6 @@
#else
#define OPT_BDB_DEFAULT 0
#endif
#ifdef HAVE_ISAM_DB
#define OPT_ISAM_DEFAULT 1
#else
#define OPT_ISAM_DEFAULT 0
#endif
#ifdef HAVE_NDBCLUSTER_DB
#define OPT_NDBCLUSTER_DEFAULT 0
#if defined(NOT_ENOUGH_TESTED) \
......@@ -64,7 +56,6 @@
#define OPT_NDBCLUSTER_DEFAULT 0
#endif
#include <nisam.h>
#include <thr_alarm.h>
#include <ft_global.h>
#include <errmsg.h>
......@@ -4342,7 +4333,7 @@ Disable with --skip-bdb (will save memory).",
"Don't try to recover Berkeley DB tables on start.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0},
{"bdb-no-sync", OPT_BDB_NOSYNC,
"Disable synchronously flushing logs. This option is deprecated, use --skip-sync-bdb-logs or sync-bdb-logs=0 instead",
"This option is deprecated, use --skip-sync-bdb-logs instead",
// (gptr*) &opt_sync_bdb_logs, (gptr*) &opt_sync_bdb_logs, 0, GET_BOOL,
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"bdb-shared-data", OPT_BDB_SHARED,
......@@ -4551,9 +4542,8 @@ Disable with --skip-innodb-doublewrite.", (gptr*) &innobase_use_doublewrite,
(gptr*) &global_system_variables.innodb_support_xa,
0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0},
#endif /* End HAVE_INNOBASE_DB */
{"isam", OPT_ISAM, "Enable ISAM (if this version of MySQL supports it). \
Disable with --skip-isam.",
(gptr*) &opt_isam, (gptr*) &opt_isam, 0, GET_BOOL, NO_ARG, OPT_ISAM_DEFAULT, 0, 0,
{"isam", OPT_ISAM, "Obsolete. ISAM storage engine is no longer supported.",
(gptr*) &opt_isam, (gptr*) &opt_isam, 0, GET_BOOL, NO_ARG, 0, 0, 0,
0, 0, 0},
{"language", 'L',
"Client error messages in given language. May be given as a full path.",
......@@ -5469,36 +5459,35 @@ The minimum value for this variable is 4096.",
1, 0},
#ifdef HAVE_BERKELEY_DB
{"sync-bdb-logs", OPT_BDB_SYNC,
"Synchronously flush logs. Enabled by default",
"Synchronously flush Berkeley DB logs. Enabled by default",
(gptr*) &opt_sync_bdb_logs, (gptr*) &opt_sync_bdb_logs, 0, GET_BOOL,
NO_ARG, 1, 0, 0, 0, 0, 0},
#endif /* HAVE_BERKELEY_DB */
{"sync-binlog", OPT_SYNC_BINLOG,
"Sync the binlog to disk after every #th event. \
#=0 (the default) does no sync. Syncing slows MySQL down",
(gptr*) &sync_binlog_period,
(gptr*) &sync_binlog_period, 0, GET_ULONG, REQUIRED_ARG, 0, 0, ~0L, 0, 1,
0},
"Synchronously flush binary log to disk after every #th event. "
"Use 0 (default) to disable synchronous flushing.",
(gptr*) &sync_binlog_period, (gptr*) &sync_binlog_period, 0, GET_ULONG,
REQUIRED_ARG, 1, 0, ~0L, 0, 1, 0},
{"sync-frm", OPT_SYNC_FRM, "Sync .frm to disk on create. Enabled by default.",
(gptr*) &opt_sync_frm, (gptr*) &opt_sync_frm, 0, GET_BOOL, NO_ARG, 1, 0,
0, 0, 0, 0},
#ifdef DOES_NOTHING_YET
{"sync-replication", OPT_SYNC_REPLICATION,
"Enable synchronous replication",
"Enable synchronous replication.",
(gptr*) &global_system_variables.sync_replication,
(gptr*) &global_system_variables.sync_replication,
0, GET_ULONG, REQUIRED_ARG, 0, 0, 1, 0, 1, 0},
{"sync-replication-slave-id", OPT_SYNC_REPLICATION_SLAVE_ID,
"Synchronous replication is wished for this slave",
"Synchronous replication is wished for this slave.",
(gptr*) &global_system_variables.sync_replication_slave_id,
(gptr*) &global_system_variables.sync_replication_slave_id,
0, GET_ULONG, REQUIRED_ARG, 0, 0, ~0L, 0, 1, 0},
{"sync-replication-timeout", OPT_SYNC_REPLICATION_TIMEOUT,
"Synchronous replication timeout",
"Synchronous replication timeout.",
(gptr*) &global_system_variables.sync_replication_timeout,
(gptr*) &global_system_variables.sync_replication_timeout,
0, GET_ULONG, REQUIRED_ARG, 10, 0, ~0L, 0, 1, 0},
#endif
{"sync-frm", OPT_SYNC_FRM, "Sync .frm to disk on create. Enabled by default",
(gptr*) &opt_sync_frm, (gptr*) &opt_sync_frm, 0, GET_BOOL, NO_ARG, 1, 0,
0, 0, 0, 0},
{"table_cache", OPT_TABLE_CACHE,
"The number of open tables for all threads.", (gptr*) &table_cache_size,
(gptr*) &table_cache_size, 0, GET_ULONG, REQUIRED_ARG, 64, 1, 512*1024L,
......@@ -5962,11 +5951,7 @@ static void mysql_init_variables(void)
#else
have_innodb=SHOW_OPTION_NO;
#endif
#ifdef HAVE_ISAM
have_isam=SHOW_OPTION_YES;
#else
have_isam=SHOW_OPTION_NO;
#endif
#ifdef HAVE_EXAMPLE_DB
have_example_db= SHOW_OPTION_YES;
#else
......@@ -6375,9 +6360,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
opt_error_log= 0; // Force logs to stdout
break;
case (int) OPT_FLUSH:
#ifdef HAVE_ISAM
nisam_flush=1;
#endif
myisam_flush=1;
flush_time=0; // No auto flush
break;
......@@ -6482,14 +6464,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
have_berkeley_db= SHOW_OPTION_YES;
else
have_berkeley_db= SHOW_OPTION_DISABLED;
#endif
break;
case OPT_ISAM:
#ifdef HAVE_ISAM
if (opt_isam)
have_isam= SHOW_OPTION_YES;
else
have_isam= SHOW_OPTION_DISABLED;
#endif
break;
case OPT_NDBCLUSTER:
......
......@@ -42,7 +42,6 @@
#include "mysql_priv.h"
#include <m_ctype.h>
#include <nisam.h>
#include "sql_select.h"
#ifndef EXTRA_DEBUG
......
......@@ -954,9 +954,11 @@ struct show_var_st init_vars[]= {
{"sql_warnings", (char*) &sys_sql_warnings, SHOW_BOOL},
#ifdef HAVE_REPLICATION
{sys_sync_binlog_period.name,(char*) &sys_sync_binlog_period, SHOW_SYS},
#ifdef DOES_NOTHING_YET
{sys_sync_replication.name, (char*) &sys_sync_replication, SHOW_SYS},
{sys_sync_replication_slave_id.name, (char*) &sys_sync_replication_slave_id,SHOW_SYS},
{sys_sync_replication_timeout.name, (char*) &sys_sync_replication_timeout,SHOW_SYS},
#endif
#endif
{sys_sync_frm.name, (char*) &sys_sync_frm, SHOW_SYS},
#ifdef HAVE_TZNAME
......@@ -2495,14 +2497,6 @@ bool sys_var_sync_binlog_period::update(THD *thd, set_var *var)
{
pthread_mutex_t *lock_log= mysql_bin_log.get_log_lock();
sync_binlog_period= (ulong) var->save_result.ulonglong_value;
/*
Must reset the counter otherwise it may already be beyond the new period
and so the new period will not be taken into account. Need mutex otherwise
might be cancelled by a simultanate ++ in MYSQL_LOG::write().
*/
pthread_mutex_lock(lock_log);
sync_binlog_counter= 0;
pthread_mutex_unlock(lock_log);
return 0;
}
#endif /* HAVE_REPLICATION */
......
......@@ -25,7 +25,6 @@
#include <m_ctype.h>
#include <my_dir.h>
#include <hash.h>
#include <nisam.h>
#ifdef __WIN__
#include <io.h>
#endif
......
......@@ -327,6 +327,7 @@ public:
bool is_active(const char* log_file_name);
int update_log_index(LOG_INFO* linfo, bool need_update_threads);
void rotate_and_purge(uint flags);
bool flush_and_sync();
int purge_logs(const char *to_log, bool included,
bool need_mutex, bool need_update_threads,
ulonglong *decrease_log_space);
......@@ -1287,14 +1288,14 @@ public:
void awake(THD::killed_state state_to_set);
/*
For enter_cond() / exit_cond() to work the mutex must be got before
enter_cond() (in 4.1 an assertion will soon ensure this); this mutex is
then released by exit_cond(). Use must be:
lock mutex; enter_cond(); your code; exit_cond().
enter_cond(); this mutex is then released by exit_cond().
Usage must be: lock mutex; enter_cond(); your code; exit_cond().
*/
inline const char* enter_cond(pthread_cond_t *cond, pthread_mutex_t* mutex,
const char* msg)
{
const char* old_msg = proc_info;
safe_mutex_assert_owner(mutex);
mysys_var->current_mutex = mutex;
mysys_var->current_cond = cond;
proc_info = msg;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment