Commit f1aae861 authored by Sergei Golubchik's avatar Sergei Golubchik

5.6.30

parent 220e70fa
/*****************************************************************************
Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
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 the Free Software
......@@ -3216,8 +3216,6 @@ fil_create_link_file(
const char* tablename, /*!< in: tablename */
const char* filepath) /*!< in: pathname of tablespace */
{
os_file_t file;
ibool success;
dberr_t err = DB_SUCCESS;
char* link_filepath;
char* prev_filepath = fil_read_link_file(tablename);
......@@ -3236,13 +3234,24 @@ fil_create_link_file(
link_filepath = fil_make_isl_name(tablename);
file = os_file_create_simple_no_error_handling(
innodb_file_data_key, link_filepath,
OS_FILE_CREATE, OS_FILE_READ_WRITE, &success);
/** Check if the file already exists. */
FILE* file = NULL;
ibool exists;
os_file_type_t ftype;
if (!success) {
/* The following call will print an error message */
ulint error = os_file_get_last_error(true);
bool success = os_file_status(link_filepath, &exists, &ftype);
ulint error = 0;
if (success && !exists) {
file = fopen(link_filepath, "w");
if (file == NULL) {
/* This call will print its own error message */
error = os_file_get_last_error(true);
}
} else {
error = OS_FILE_ALREADY_EXISTS;
}
if (error != 0) {
ut_print_timestamp(stderr);
fputs(" InnoDB: Cannot create file ", stderr);
......@@ -3267,13 +3276,17 @@ fil_create_link_file(
return(err);
}
if (!os_file_write(link_filepath, file, filepath, 0,
strlen(filepath))) {
ulint rbytes = fwrite(filepath, 1, strlen(filepath), file);
if (rbytes != strlen(filepath)) {
os_file_get_last_error(true);
ib_logf(IB_LOG_LEVEL_ERROR,
"cannot write link file "
"%s",filepath);
err = DB_ERROR;
}
/* Close the file, we only need it at startup */
os_file_close(file);
fclose(file);
mem_free(link_filepath);
......
This diff is collapsed.
/*****************************************************************************
Copyright (c) 2007, 2015, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2007, 2016, Oracle and/or its affiliates. All Rights Reserved.
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 the Free Software
......@@ -87,6 +87,7 @@ enum fts_msg_type_t {
FTS_MSG_DEL_TABLE, /*!< Remove a table from the optimize
threads work queue */
FTS_MSG_SYNC_TABLE /*!< Sync fts cache of a table */
};
/** Compressed list of words that have been read from FTS INDEX
......@@ -2652,6 +2653,39 @@ fts_optimize_remove_table(
os_event_free(event);
}
/** Send sync fts cache for the table.
@param[in] table table to sync */
UNIV_INTERN
void
fts_optimize_request_sync_table(
dict_table_t* table)
{
fts_msg_t* msg;
table_id_t* table_id;
/* if the optimize system not yet initialized, return */
if (!fts_optimize_wq) {
return;
}
/* FTS optimizer thread is already exited */
if (fts_opt_start_shutdown) {
ib_logf(IB_LOG_LEVEL_INFO,
"Try to sync table %s after FTS optimize"
" thread exiting.", table->name);
return;
}
msg = fts_optimize_create_msg(FTS_MSG_SYNC_TABLE, NULL);
table_id = static_cast<table_id_t*>(
mem_heap_alloc(msg->heap, sizeof(table_id_t)));
*table_id = table->id;
msg->ptr = table_id;
ib_wqueue_add(fts_optimize_wq, msg, msg->heap);
}
/**********************************************************************//**
Find the slot for a particular table.
@return slot if found else NULL. */
......@@ -2932,6 +2966,25 @@ fts_optimize_need_sync(
}
#endif
/** Sync fts cache of a table
@param[in] table_id table id */
void
fts_optimize_sync_table(
table_id_t table_id)
{
dict_table_t* table = NULL;
table = dict_table_open_on_id(table_id, FALSE, DICT_TABLE_OP_NORMAL);
if (table) {
if (dict_table_has_fts_index(table) && table->fts->cache) {
fts_sync_table(table, true, false);
}
dict_table_close(table, FALSE, FALSE);
}
}
/**********************************************************************//**
Optimize all FTS tables.
@return Dummy return */
......@@ -3053,6 +3106,11 @@ fts_optimize_thread(
((fts_msg_del_t*) msg->ptr)->event);
break;
case FTS_MSG_SYNC_TABLE:
fts_optimize_sync_table(
*static_cast<table_id_t*>(msg->ptr));
break;
default:
ut_error;
}
......@@ -3079,26 +3137,7 @@ fts_optimize_thread(
ib_vector_get(tables, i));
if (slot->state != FTS_STATE_EMPTY) {
dict_table_t* table = NULL;
/*slot->table may be freed, so we try to open
table by slot->table_id.*/
table = dict_table_open_on_id(
slot->table_id, FALSE,
DICT_TABLE_OP_NORMAL);
if (table) {
if (dict_table_has_fts_index(table)) {
fts_sync_table(table);
}
if (table->fts) {
fts_free(table);
}
dict_table_close(table, FALSE, FALSE);
}
fts_optimize_sync_table(slot->table_id);
}
}
}
......
/*****************************************************************************
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, 2009 Google Inc.
Copyright (c) 2009, Percona Inc.
Copyright (c) 2012, Facebook Inc.
......@@ -3344,6 +3344,16 @@ innobase_init(
innobase_open_files = table_cache_size;
}
}
if (innobase_open_files > (long) open_files_limit) {
fprintf(stderr,
"innodb_open_files should not be greater"
" than the open_files_limit.\n");
if (innobase_open_files > (long) table_cache_size) {
innobase_open_files = table_cache_size;
}
}
srv_max_n_open_files = (ulint) innobase_open_files;
srv_innodb_status = (ibool) innobase_create_status_file;
......@@ -11363,7 +11373,7 @@ ha_innobase::optimize(
if (innodb_optimize_fulltext_only) {
if (prebuilt->table->fts && prebuilt->table->fts->cache
&& !dict_table_is_discarded(prebuilt->table)) {
fts_sync_table(prebuilt->table);
fts_sync_table(prebuilt->table, false, true);
fts_optimize_table(prebuilt->table);
}
return(HA_ADMIN_OK);
......
/*****************************************************************************
Copyright (c) 2011, 2015, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2011, 2016, Oracle and/or its affiliates. All Rights Reserved.
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 the Free Software
......@@ -724,6 +724,13 @@ fts_optimize_remove_table(
/*======================*/
dict_table_t* table); /*!< in: table to remove */
/** Send sync fts cache for the table.
@param[in] table table to sync */
UNIV_INTERN
void
fts_optimize_request_sync_table(
dict_table_t* table);
/**********************************************************************//**
Signal the optimize thread to prepare for shutdown. */
UNIV_INTERN
......@@ -826,15 +833,18 @@ fts_drop_index_split_tables(
dict_index_t* index) /*!< in: fts instance */
__attribute__((nonnull, warn_unused_result));
/****************************************************************//**
Run SYNC on the table, i.e., write out data from the cache to the
FTS auxiliary INDEX table and clear the cache at the end. */
/** Run SYNC on the table, i.e., write out data from the cache to the
FTS auxiliary INDEX table and clear the cache at the end.
@param[in,out] table fts table
@param[in] unlock_cache whether unlock cache when write node
@param[in] wait whether wait for existing sync to finish
@return DB_SUCCESS on success, error code on failure. */
UNIV_INTERN
dberr_t
fts_sync_table(
/*===========*/
dict_table_t* table) /*!< in: table */
__attribute__((nonnull));
dict_table_t* table,
bool unlock_cache,
bool wait);
/****************************************************************//**
Free the query graph but check whether dict_sys->mutex is already
......
/*****************************************************************************
Copyright (c) 2007, 2011, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2007, 2016, Oracle and/or its affiliates. All Rights Reserved.
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 the Free Software
......@@ -122,7 +122,11 @@ struct fts_sync_t {
doc_id_t max_doc_id; /*!< The doc id at which the cache was
noted as being full, we use this to
set the upper_limit field */
ib_time_t start_time; /*!< SYNC start time */
ib_time_t start_time; /*!< SYNC start time */
bool in_progress; /*!< flag whether sync is in progress.*/
bool unlock_cache; /*!< flag whether unlock cache when
write fts node */
os_event_t event; /*!< sync finish event */
};
/** The cache for the FTS system. It is a memory-based inverted index
......@@ -165,7 +169,6 @@ struct fts_cache_t {
objects, they are recreated after
a SYNC is completed */
ib_alloc_t* self_heap; /*!< This heap is the heap out of
which an instance of the cache itself
was created. Objects created using
......@@ -212,6 +215,7 @@ struct fts_node_t {
ulint ilist_size_alloc;
/*!< Allocated size of ilist in
bytes */
bool synced; /*!< flag whether the node is synced */
};
/** A tokenizer word. Contains information about one word. */
......
/*****************************************************************************
Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, Google Inc.
Portions of this file contain modifications contributed and copyrighted by
......@@ -449,28 +449,7 @@ amount to decrement. */
# define os_atomic_decrement_uint64(ptr, amount) \
os_atomic_decrement(ptr, amount)
# if defined(HAVE_IB_GCC_ATOMIC_TEST_AND_SET)
/** Do an atomic test-and-set.
@param[in,out] ptr Memory location to set to non-zero
@return the previous value */
inline
lock_word_t
os_atomic_test_and_set(volatile lock_word_t* ptr)
{
return(__atomic_test_and_set(ptr, __ATOMIC_ACQUIRE));
}
/** Do an atomic clear.
@param[in,out] ptr Memory location to set to zero */
inline
void
os_atomic_clear(volatile lock_word_t* ptr)
{
__atomic_clear(ptr, __ATOMIC_RELEASE);
}
# elif defined(IB_STRONG_MEMORY_MODEL)
# if defined(IB_STRONG_MEMORY_MODEL)
/** Do an atomic test and set.
@param[in,out] ptr Memory location to set to non-zero
......@@ -499,6 +478,27 @@ os_atomic_clear(volatile lock_word_t* ptr)
return(__sync_lock_test_and_set(ptr, 0));
}
# elif defined(HAVE_IB_GCC_ATOMIC_TEST_AND_SET)
/** Do an atomic test-and-set.
@param[in,out] ptr Memory location to set to non-zero
@return the previous value */
inline
lock_word_t
os_atomic_test_and_set(volatile lock_word_t* ptr)
{
return(__atomic_test_and_set(ptr, __ATOMIC_ACQUIRE));
}
/** Do an atomic clear.
@param[in,out] ptr Memory location to set to zero */
inline
void
os_atomic_clear(volatile lock_word_t* ptr)
{
__atomic_clear(ptr, __ATOMIC_RELEASE);
}
# else
# error "Unsupported platform"
......
/*****************************************************************************
Copyright (c) 2005, 2015, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2005, 2016, Oracle and/or its affiliates. All Rights Reserved.
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 the Free Software
......@@ -1986,7 +1986,8 @@ row_merge_read_clustered_index(
if (max_doc_id && err == DB_SUCCESS) {
/* Sync fts cache for other fts indexes to keep all
fts indexes consistent in sync_doc_id. */
err = fts_sync_table(const_cast<dict_table_t*>(new_table));
err = fts_sync_table(const_cast<dict_table_t*>(new_table),
false, true);
if (err == DB_SUCCESS) {
fts_update_next_doc_id(
......
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