Commit 2eb8cb85 authored by kent@mysql.com's avatar kent@mysql.com

Merge kboortz@bk-internal.mysql.com:/home/bk/mysql-5.0

into mysql.com:/Users/kent/mysql/bk/mysql-5.0
parents 633cd034 78f4f940
......@@ -469,6 +469,14 @@ extern "C" {
*/
void ndb_mgm_destroy_handle(NdbMgmHandle * handle);
/**
* Set a name of the handle. Name is reported in cluster log.
*
* @param handle Management handle
* @param name Name
*/
void ndb_mgm_set_name(NdbMgmHandle handle, const char *name);
/** @} *********************************************************************/
/**
* @name Functions: Connect/Disconnect Management Server
......
......@@ -40,6 +40,14 @@ public:
Ndb_cluster_connection(const char * connectstring = 0);
~Ndb_cluster_connection();
/**
* Set a name on the connection, which will be reported in cluster log
*
* @param name
*
*/
void set_name(const char *name);
/**
* Connect to a cluster management server
*
......
......@@ -102,6 +102,7 @@ struct ndb_mgm_handle {
FILE* logfile;
#endif
FILE *errstream;
char *m_name;
};
#define SET_ERROR(h, e, s) setError(h, e, __LINE__, s)
......@@ -156,6 +157,7 @@ ndb_mgm_create_handle()
h->write_timeout = 100;
h->cfg_i = -1;
h->errstream = stdout;
h->m_name = 0;
strncpy(h->last_error_desc, "No error", NDB_MGM_MAX_ERR_DESC_SIZE);
......@@ -170,6 +172,14 @@ ndb_mgm_create_handle()
DBUG_RETURN(h);
}
extern "C"
void
ndb_mgm_set_name(NdbMgmHandle handle, const char *name)
{
my_free(handle->m_name, MYF(MY_ALLOW_ZERO_PTR));
handle->m_name= my_strdup(name, MYF(MY_WME));
}
extern "C"
int
ndb_mgm_set_connectstring(NdbMgmHandle handle, const char * mgmsrv)
......@@ -216,6 +226,7 @@ ndb_mgm_destroy_handle(NdbMgmHandle * handle)
}
#endif
(*handle)->cfg.~LocalConfig();
my_free((*handle)->m_name, MYF(MY_ALLOW_ZERO_PTR));
my_free((char*)* handle,MYF(MY_ALLOW_ZERO_PTR));
* handle = 0;
DBUG_VOID_RETURN;
......@@ -1875,6 +1886,8 @@ ndb_mgm_alloc_nodeid(NdbMgmHandle handle, unsigned int version, int nodetype)
args.put("password", "mysqld");
args.put("public key", "a public key");
args.put("endian", (endian_check.c[sizeof(long)-1])?"big":"little");
if (handle->m_name)
args.put("name", handle->m_name);
const ParserRow<ParserDummy> reply[]= {
MGM_CMD("get nodeid reply", NULL, ""),
......
......@@ -35,6 +35,7 @@
#include <base64.h>
extern bool g_StopServer;
extern EventLogger g_eventLogger;
static const unsigned int MAX_READ_TIMEOUT = 1000 ;
static const unsigned int MAX_WRITE_TIMEOUT = 100 ;
......@@ -135,6 +136,7 @@ ParserRow<MgmApiSession> commands[] = {
MGM_ARG("password", String, Mandatory, "Password"),
MGM_ARG("public key", String, Mandatory, "Public key"),
MGM_ARG("endian", String, Optional, "Endianness"),
MGM_ARG("name", String, Optional, "Name of connection"),
MGM_CMD("get version", &MgmApiSession::getVersion, ""),
......@@ -411,6 +413,7 @@ MgmApiSession::get_nodeid(Parser_t::Context &,
const char * password;
const char * public_key;
const char * endian= NULL;
const char * name= NULL;
union { long l; char c[sizeof(long)]; } endian_check;
args.get("version", &version);
......@@ -421,6 +424,7 @@ MgmApiSession::get_nodeid(Parser_t::Context &,
args.get("password", &password);
args.get("public key", &public_key);
args.get("endian", &endian);
args.get("name", &name);
endian_check.l = 1;
if(endian
......@@ -489,6 +493,9 @@ MgmApiSession::get_nodeid(Parser_t::Context &,
m_output->println("");
m_allocated_resources->reserve_node(tmp);
if (name)
g_eventLogger.info("Node %d: %s", tmp, name);
return;
}
......
......@@ -252,7 +252,8 @@ Ndb_cluster_connection::wait_until_ready(int timeout,
Ndb_cluster_connection_impl::Ndb_cluster_connection_impl(const char *
connect_string)
: Ndb_cluster_connection(*this),
m_optimized_node_selection(1)
m_optimized_node_selection(1),
m_name(0)
{
DBUG_ENTER("Ndb_cluster_connection");
DBUG_PRINT("enter",("Ndb_cluster_connection this=0x%x", this));
......@@ -280,7 +281,11 @@ Ndb_cluster_connection_impl::Ndb_cluster_connection_impl(const char *
delete m_config_retriever;
m_config_retriever= 0;
}
if (m_name)
{
NdbMgmHandle h= m_config_retriever->get_mgmHandle();
ndb_mgm_set_name(h, m_name);
}
m_transporter_facade=
TransporterFacade::theFacadeInstance=
new TransporterFacade();
......@@ -324,9 +329,25 @@ Ndb_cluster_connection_impl::~Ndb_cluster_connection_impl()
ndb_print_state_mutex= NULL;
}
#endif
if (m_name)
free(m_name);
DBUG_VOID_RETURN;
}
void
Ndb_cluster_connection_impl::set_name(const char *name)
{
if (m_name)
free(m_name);
m_name= strdup(name);
if (m_config_retriever && m_name)
{
NdbMgmHandle h= m_config_retriever->get_mgmHandle();
ndb_mgm_set_name(h, m_name);
}
}
void
Ndb_cluster_connection_impl::init_nodes_vector(Uint32 nodeid,
const ndb_mgm_configuration
......@@ -478,6 +499,11 @@ Ndb_cluster_connection_impl::do_test()
delete [] nodes;
}
void Ndb_cluster_connection::set_name(const char *name)
{
m_impl.set_name(name);
}
int Ndb_cluster_connection::connect(int no_retries, int retry_delay_in_seconds,
int verbose)
{
......
......@@ -70,6 +70,7 @@ private:
Vector<Node> m_all_nodes;
void init_nodes_vector(Uint32 nodeid, const ndb_mgm_configuration &config);
void connect_thread();
void set_name(const char *name);
TransporterFacade *m_transporter_facade;
ConfigRetriever *m_config_retriever;
......@@ -77,6 +78,7 @@ private:
int (*m_connect_callback)(void);
int m_optimized_node_selection;
char *m_name;
};
#endif
......@@ -27,6 +27,8 @@ extern FilteredNdbOut debug;
static void callback(int, NdbTransaction*, void*);
extern const char * g_connect_string;
extern BaseString g_options;
bool
BackupRestore::init()
{
......@@ -36,6 +38,7 @@ BackupRestore::init()
return true;
m_cluster_connection = new Ndb_cluster_connection(g_connect_string);
m_cluster_connection->set_name(g_options.c_str());
if(m_cluster_connection->connect(12, 5, 1) != 0)
{
return false;
......
......@@ -50,7 +50,8 @@ static int _print_data = 0;
static int _print_log = 0;
static int _restore_data = 0;
static int _restore_meta = 0;
BaseString g_options("ndb_restore");
static struct my_option my_long_options[] =
{
NDB_STD_OPTS("ndb_restore"),
......@@ -249,6 +250,14 @@ main(int argc, char** argv)
exitHandler(NDBT_FAILED);
}
g_options.appfmt(" -b %d", ga_backupId);
g_options.appfmt(" -n %d", ga_nodeId);
if (_restore_meta)
g_options.appfmt(" -m");
if (_restore_data)
g_options.appfmt(" -r");
g_options.appfmt(" -p %d", ga_nParallelism);
g_connect_string = opt_connect_str;
/**
......
......@@ -366,12 +366,14 @@ int ha_archive::write_meta_file(File meta_file, ha_rows rows, bool dirty)
See ha_example.cc for a longer description.
*/
ARCHIVE_SHARE *ha_archive::get_share(const char *table_name, TABLE *table)
ARCHIVE_SHARE *ha_archive::get_share(const char *table_name,
TABLE *table, int *rc)
{
ARCHIVE_SHARE *share;
char meta_file_name[FN_REFLEN];
uint length;
char *tmp_name;
DBUG_ENTER("ha_archive::get_share");
pthread_mutex_lock(&archive_mutex);
length=(uint) strlen(table_name);
......@@ -386,7 +388,8 @@ ARCHIVE_SHARE *ha_archive::get_share(const char *table_name, TABLE *table)
NullS))
{
pthread_mutex_unlock(&archive_mutex);
return NULL;
*rc= HA_ERR_OUT_OF_MEM;
DBUG_RETURN(NULL);
}
share->use_count= 0;
......@@ -424,9 +427,14 @@ ARCHIVE_SHARE *ha_archive::get_share(const char *table_name, TABLE *table)
thr_lock_init(&share->lock);
}
share->use_count++;
DBUG_PRINT("info", ("archive table %.*s has %d open handles now",
share->table_name_length, share->table_name,
share->use_count));
if (share->crashed)
*rc= HA_ERR_CRASHED_ON_USAGE;
pthread_mutex_unlock(&archive_mutex);
return share;
DBUG_RETURN(share);
}
......@@ -437,13 +445,21 @@ ARCHIVE_SHARE *ha_archive::get_share(const char *table_name, TABLE *table)
int ha_archive::free_share(ARCHIVE_SHARE *share)
{
int rc= 0;
DBUG_ENTER("ha_archive::free_share");
DBUG_PRINT("info", ("archive table %.*s has %d open handles on entrance",
share->table_name_length, share->table_name,
share->use_count));
pthread_mutex_lock(&archive_mutex);
if (!--share->use_count)
{
hash_delete(&archive_open_tables, (byte*) share);
thr_lock_delete(&share->lock);
VOID(pthread_mutex_destroy(&share->mutex));
(void)write_meta_file(share->meta_file, share->rows_recorded, FALSE);
if (share->crashed)
(void)write_meta_file(share->meta_file, share->rows_recorded, TRUE);
else
(void)write_meta_file(share->meta_file, share->rows_recorded, FALSE);
if (gzclose(share->archive_write) == Z_ERRNO)
rc= 1;
if (my_close(share->meta_file, MYF(0)))
......@@ -452,7 +468,7 @@ int ha_archive::free_share(ARCHIVE_SHARE *share)
}
pthread_mutex_unlock(&archive_mutex);
return rc;
DBUG_RETURN(rc);
}
......@@ -479,10 +495,23 @@ const char **ha_archive::bas_ext() const
*/
int ha_archive::open(const char *name, int mode, uint open_options)
{
int rc= 0;
DBUG_ENTER("ha_archive::open");
if (!(share= get_share(name, table)))
DBUG_RETURN(HA_ERR_OUT_OF_MEM); // Not handled well by calling code!
DBUG_PRINT("info", ("archive table was opened for crash %s",
(open_options & HA_OPEN_FOR_REPAIR) ? "yes" : "no"));
share= get_share(name, table, &rc);
if (rc == HA_ERR_CRASHED_ON_USAGE && !(open_options & HA_OPEN_FOR_REPAIR))
{
free_share(share);
DBUG_RETURN(rc);
}
else if (rc == HA_ERR_OUT_OF_MEM)
{
DBUG_RETURN(rc);
}
thr_lock_data_init(&share->lock,&lock,NULL);
if ((archive= gzopen(share->data_file_name, "rb")) == NULL)
......@@ -492,10 +521,14 @@ int ha_archive::open(const char *name, int mode, uint open_options)
DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE);
}
if (open_options & HA_OPEN_FOR_REPAIR)
DBUG_PRINT("info", ("archive table was crashed %s",
rc == HA_ERR_CRASHED_ON_USAGE ? "yes" : "no"));
if (rc == HA_ERR_CRASHED_ON_USAGE && open_options & HA_OPEN_FOR_REPAIR)
{
DBUG_RETURN(0);
DBUG_RETURN(share->crashed ? HA_ERR_CRASHED_ON_USAGE : 0);
}
else
DBUG_RETURN(rc);
}
......@@ -684,6 +717,7 @@ int ha_archive::rnd_init(bool scan)
if (scan)
{
scan_rows= share->rows_recorded;
DBUG_PRINT("info", ("archive will retrieve %llu rows", scan_rows));
records= 0;
/*
......@@ -695,6 +729,7 @@ int ha_archive::rnd_init(bool scan)
pthread_mutex_lock(&share->mutex);
if (share->dirty == TRUE)
{
DBUG_PRINT("info", ("archive flushing out rows for scan"));
gzflush(share->archive_write, Z_SYNC_FLUSH);
share->dirty= FALSE;
}
......@@ -913,6 +948,7 @@ int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt)
share->rows_recorded++;
}
}
DBUG_PRINT("info", ("recovered %llu archive rows", share->rows_recorded));
my_free((char*)buf, MYF(0));
if (rc && rc != HA_ERR_END_OF_FILE)
......@@ -936,11 +972,23 @@ int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt)
}
gzflush(writer, Z_SYNC_FLUSH);
share->dirty= FALSE;
gzclose(share->archive_write);
share->archive_write= writer;
my_rename(writer_filename,share->data_file_name,MYF(0));
/*
Now we need to reopen our read descriptor since it has changed.
*/
gzclose(archive);
if ((archive= gzopen(share->data_file_name, "rb")) == NULL)
{
rc= HA_ERR_CRASHED_ON_USAGE;
goto error;
}
DBUG_RETURN(0);
error:
......
......@@ -85,7 +85,7 @@ class ha_archive: public handler
int get_row(gzFile file_to_read, byte *buf);
int read_meta_file(File meta_file, ha_rows *rows);
int write_meta_file(File meta_file, ha_rows rows, bool dirty);
ARCHIVE_SHARE *get_share(const char *table_name, TABLE *table);
ARCHIVE_SHARE *get_share(const char *table_name, TABLE *table, int *rc);
int free_share(ARCHIVE_SHARE *share);
bool auto_repair() const { return 1; } // For the moment we just do this
int read_data_header(gzFile file_to_read);
......
......@@ -4805,7 +4805,11 @@ bool ndbcluster_init()
opt_ndbcluster_connectstring));
goto ndbcluster_init_error;
}
{
char buf[128];
my_snprintf(buf, sizeof(buf), "mysqld --server-id=%d", server_id);
g_ndb_cluster_connection->set_name(buf);
}
g_ndb_cluster_connection->set_optimized_node_selection
(opt_ndb_optimized_node_selection);
......
......@@ -835,6 +835,7 @@ struct show_var_st init_vars[]= {
{sys_innodb_fast_shutdown.name,(char*) &sys_innodb_fast_shutdown, SHOW_SYS},
{"innodb_file_io_threads", (char*) &innobase_file_io_threads, SHOW_LONG },
{"innodb_file_per_table", (char*) &innobase_file_per_table, SHOW_MY_BOOL},
{sys_innodb_flush_log_at_trx_commit.name, (char*) &sys_innodb_flush_log_at_trx_commit, SHOW_SYS},
{"innodb_flush_method", (char*) &innobase_unix_file_flush_method, SHOW_CHAR_PTR},
{"innodb_force_recovery", (char*) &innobase_force_recovery, SHOW_LONG },
{"innodb_lock_wait_timeout", (char*) &innobase_lock_wait_timeout, SHOW_LONG },
......@@ -854,7 +855,6 @@ struct show_var_st init_vars[]= {
{sys_innodb_table_locks.name, (char*) &sys_innodb_table_locks, SHOW_SYS},
{sys_innodb_thread_concurrency.name, (char*) &sys_innodb_thread_concurrency, SHOW_SYS},
{sys_innodb_thread_sleep_delay.name, (char*) &sys_innodb_thread_sleep_delay, SHOW_SYS},
{sys_innodb_flush_log_at_trx_commit.name, (char*) &sys_innodb_flush_log_at_trx_commit, SHOW_SYS},
#endif
{sys_interactive_timeout.name,(char*) &sys_interactive_timeout, SHOW_SYS},
{sys_join_buffer_size.name, (char*) &sys_join_buffer_size, SHOW_SYS},
......
......@@ -322,7 +322,7 @@ then
cp -fp config.log "$MYSQL_MAXCONFLOG_DEST"
fi
make test-force || true
make -i test-force || true
# Save mysqld-max
# check if mysqld was installed in .libs/
......@@ -389,7 +389,7 @@ then
cp -fp config.log "$MYSQL_CONFLOG_DEST"
fi
make test-force || true
make -i test-force || true
%install
RBR=$RPM_BUILD_ROOT
......@@ -720,6 +720,11 @@ fi
# itself - note that they must be ordered by date (important when
# merging BK trees)
%changelog
* Fri Jan 10 2006 Joerg Bruehe <joerg@mysql.com>
- Use "-i" on "make test-force";
this is essential for later evaluation of this log file.
* Fri Dec 12 2005 Rodrigo Novo <rodrigo@mysql.com>
- Added zlib to the list of (static) libraries installed
......
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