#At file:///home/malff/BZR-TREE/mysql-6.0-perfschema/ based on revid:marc.alff@stripped
3165 Marc Alff 2009-06-05
Bug#44001 Usage of pin / pinbox for the lock free hash
Revised usage of LF_HASH in the performance schema code,
per discussion during code review.
modified:
mysql-test/suite/perfschema/r/start_server32_off.result
mysql-test/suite/perfschema/r/start_server32_on.result
mysql-test/suite/perfschema/r/start_server64_off.result
mysql-test/suite/perfschema/r/start_server64_on.result
storage/perfschema/pfs.cc
storage/perfschema/pfs_instr.cc
storage/perfschema/pfs_instr.h
storage/perfschema/pfs_instr_class.cc
storage/perfschema/pfs_instr_class.h
storage/perfschema/pfs_lock.h
storage/perfschema/unittest/pfs_instr-t.cc
storage/perfschema/unittest/pfs_instr_class-t.cc
=== modified file 'mysql-test/suite/perfschema/r/start_server32_off.result'
--- a/mysql-test/suite/perfschema/r/start_server32_off.result 2009-05-28 21:33:45 +0000
+++ b/mysql-test/suite/perfschema/r/start_server32_off.result 2009-06-06 01:03:10 +0000
@@ -50,11 +50,11 @@ performance_schema (PFS_COND).ROW_SIZE 7
performance_schema (PFS_COND).ROW_COUNT 0
performance_schema (PFS_COND).ROW_LOST 0
performance_schema (PFS_COND).MEMORY 0
-performance_schema (PFS_THREAD).ROW_SIZE 304
+performance_schema (PFS_THREAD).ROW_SIZE 312
performance_schema (PFS_THREAD).ROW_COUNT 0
performance_schema (PFS_THREAD).ROW_LOST 0
performance_schema (PFS_THREAD).MEMORY 0
-performance_schema (PFS_FILE).ROW_SIZE 612
+performance_schema (PFS_FILE).ROW_SIZE 604
performance_schema (PFS_FILE).ROW_COUNT 0
performance_schema (PFS_FILE).ROW_LOST 0
performance_schema (PFS_FILE).MEMORY 0
=== modified file 'mysql-test/suite/perfschema/r/start_server32_on.result'
--- a/mysql-test/suite/perfschema/r/start_server32_on.result 2009-05-26 21:15:12 +0000
+++ b/mysql-test/suite/perfschema/r/start_server32_on.result 2009-06-06 01:03:10 +0000
@@ -50,14 +50,14 @@ performance_schema (PFS_COND).ROW_SIZE 7
performance_schema (PFS_COND).ROW_COUNT 1000
performance_schema (PFS_COND).ROW_LOST 0
performance_schema (PFS_COND).MEMORY 72000
-performance_schema (PFS_THREAD).ROW_SIZE 304
+performance_schema (PFS_THREAD).ROW_SIZE 312
performance_schema (PFS_THREAD).ROW_COUNT 1000
performance_schema (PFS_THREAD).ROW_LOST 0
-performance_schema (PFS_THREAD).MEMORY 304000
-performance_schema (PFS_FILE).ROW_SIZE 612
+performance_schema (PFS_THREAD).MEMORY 312000
+performance_schema (PFS_FILE).ROW_SIZE 604
performance_schema (PFS_FILE).ROW_COUNT 1000
performance_schema (PFS_FILE).ROW_LOST 0
-performance_schema (PFS_FILE).MEMORY 612000
+performance_schema (PFS_FILE).MEMORY 604000
performance_schema EVENTS_WAITS_SUMMARY_BY_THREAD_BY_NAME.ROW_SIZE 32
performance_schema EVENTS_WAITS_SUMMARY_BY_THREAD_BY_NAME.ROW_COUNT 350000
performance_schema EVENTS_WAITS_SUMMARY_BY_THREAD_BY_NAME.MEMORY 11200000
=== modified file 'mysql-test/suite/perfschema/r/start_server64_off.result'
--- a/mysql-test/suite/perfschema/r/start_server64_off.result 2009-05-28 21:33:45 +0000
+++ b/mysql-test/suite/perfschema/r/start_server64_off.result 2009-06-06 01:03:10 +0000
@@ -50,11 +50,11 @@ performance_schema (PFS_COND).ROW_SIZE 8
performance_schema (PFS_COND).ROW_COUNT 0
performance_schema (PFS_COND).ROW_LOST 0
performance_schema (PFS_COND).MEMORY 0
-performance_schema (PFS_THREAD).ROW_SIZE 488
+performance_schema (PFS_THREAD).ROW_SIZE 504
performance_schema (PFS_THREAD).ROW_COUNT 0
performance_schema (PFS_THREAD).ROW_LOST 0
performance_schema (PFS_THREAD).MEMORY 0
-performance_schema (PFS_FILE).ROW_SIZE 632
+performance_schema (PFS_FILE).ROW_SIZE 624
performance_schema (PFS_FILE).ROW_COUNT 0
performance_schema (PFS_FILE).ROW_LOST 0
performance_schema (PFS_FILE).MEMORY 0
=== modified file 'mysql-test/suite/perfschema/r/start_server64_on.result'
--- a/mysql-test/suite/perfschema/r/start_server64_on.result 2009-05-13 16:44:00 +0000
+++ b/mysql-test/suite/perfschema/r/start_server64_on.result 2009-06-06 01:03:10 +0000
@@ -50,18 +50,18 @@ performance_schema (PFS_COND).ROW_SIZE 8
performance_schema (PFS_COND).ROW_COUNT 1000
performance_schema (PFS_COND).ROW_LOST 0
performance_schema (PFS_COND).MEMORY 88000
-performance_schema (PFS_THREAD).ROW_SIZE 488
+performance_schema (PFS_THREAD).ROW_SIZE 504
performance_schema (PFS_THREAD).ROW_COUNT 1000
performance_schema (PFS_THREAD).ROW_LOST 0
-performance_schema (PFS_THREAD).MEMORY 488000
-performance_schema (PFS_FILE).ROW_SIZE 632
+performance_schema (PFS_THREAD).MEMORY 504000
+performance_schema (PFS_FILE).ROW_SIZE 624
performance_schema (PFS_FILE).ROW_COUNT 1000
performance_schema (PFS_FILE).ROW_LOST 0
-performance_schema (PFS_FILE).MEMORY 632000
+performance_schema (PFS_FILE).MEMORY 624000
performance_schema EVENTS_WAITS_SUMMARY_BY_THREAD_BY_NAME.ROW_SIZE 32
performance_schema EVENTS_WAITS_SUMMARY_BY_THREAD_BY_NAME.ROW_COUNT 350000
performance_schema EVENTS_WAITS_SUMMARY_BY_THREAD_BY_NAME.MEMORY 11200000
-performance_schema PERFORMANCE_SCHEMA.MEMORY 15243600
+performance_schema PERFORMANCE_SCHEMA.MEMORY 15251600
performance_schema PERFORMANCE_SCHEMA.LOST 0
select count(*) from performance_schema.PERFORMANCE_TIMERS;
count(*)
=== modified file 'storage/perfschema/pfs.cc'
--- a/storage/perfschema/pfs.cc 2009-05-29 01:48:47 +0000
+++ b/storage/perfschema/pfs.cc 2009-06-06 01:03:10 +0000
@@ -966,12 +966,7 @@ static void create_file_v1(PSI_file_key
if (likely(index < MAX_FILE))
{
uint len= strlen(name);
- pfs= find_or_create_file(klass, name, len);
- if (likely(pfs))
- {
- pfs->m_bound= true;
- pfs->m_file_descriptor= file;
- }
+ pfs= find_or_create_file(pfs_thread, klass, name, len);
file_instrumentation[index]= pfs;
}
else
@@ -1294,7 +1289,7 @@ get_thread_file_name_locker_v1(PSI_file_
return NULL;
}
len= strlen(name);
- pfs_file= find_or_create_file(klass, name, len);
+ pfs_file= find_or_create_file(pfs_thread, klass, name, len);
if (unlikely(pfs_file == NULL))
return NULL;
@@ -1844,11 +1839,7 @@ static void end_file_open_wait_and_bind_
if (likely(index >= 0))
{
if (likely(index < MAX_FILE))
- {
- pfs_file->m_bound= true;
- pfs_file->m_file_descriptor= file;
file_instrumentation[index]= pfs_file;
- }
else
file_lost++;
}
@@ -1931,12 +1922,9 @@ static void end_file_wait_v1(PSI_file_lo
if ((wait->m_operation == OPERATION_TYPE_FILECLOSE) ||
(wait->m_operation == OPERATION_TYPE_FILESTREAMCLOSE))
- {
- PFS_file *pfs_file= pfs_locker->m_target.m_file;
- DBUG_ASSERT(pfs_file != NULL);
- pfs_file->m_bound= false;
- release_file(pfs_file);
- }
+ release_file(pfs_locker->m_target.m_file);
+ else if (wait->m_operation == OPERATION_TYPE_FILEDELETE)
+ destroy_file(wait->m_thread, pfs_locker->m_target.m_file);
wait->m_thread->m_wait_locker_count--;
}
=== modified file 'storage/perfschema/pfs_instr.cc'
--- a/storage/perfschema/pfs_instr.cc 2009-05-29 01:48:47 +0000
+++ b/storage/perfschema/pfs_instr.cc 2009-06-06 01:03:10 +0000
@@ -62,8 +62,8 @@ static PFS_single_stat_chain *thread_ins
static PFS_events_waits *thread_history_array= NULL;
-static LF_HASH filename_hash;
-static bool filename_hash_inited= false;
+LF_HASH filename_hash;
+bool filename_hash_inited= false;
int init_instruments(const PFS_global_param *param)
{
@@ -491,6 +491,8 @@ PFS_thread* create_thread(PFS_thread_cla
{
reset_single_stat_link(& pfs->m_instr_class_wait_stats[i]);
}
+ pfs->m_filename_hash_pins= NULL;
+ pfs->m_table_share_hash_pins= NULL;
pfs->m_lock.dirty_to_allocated();
return pfs;
}
@@ -513,39 +515,53 @@ PFS_thread *sanitize_thread(PFS_thread *
void destroy_thread(PFS_thread *pfs)
{
DBUG_ASSERT(pfs != NULL);
+ if (pfs->m_filename_hash_pins)
+ {
+ lf_hash_put_pins(pfs->m_filename_hash_pins);
+ pfs->m_filename_hash_pins= NULL;
+ }
+ if (pfs->m_table_share_hash_pins)
+ {
+ lf_hash_put_pins(pfs->m_table_share_hash_pins);
+ pfs->m_table_share_hash_pins= NULL;
+ }
pfs->m_lock.allocated_to_free();
}
PFS_file*
-find_or_create_file(PFS_file_class *klass, const char *filename, uint len)
+find_or_create_file(PFS_thread *thread, PFS_file_class *klass,
+ const char *filename, uint len)
{
int pass;
PFS_file *pfs;
if (! filename_hash_inited)
{
- /*
- The filename hash could be initialized late, giving up on file io
- instrumentation that may happen during the mysys initialization.
- */
+ /* File instrumentation can be turned off. */
file_lost++;
return NULL;
}
+ if (unlikely(thread->m_filename_hash_pins == NULL))
+ {
+ thread->m_filename_hash_pins= lf_hash_get_pins(& filename_hash);
+ DBUG_ASSERT(thread->m_filename_hash_pins);
+ }
+
if (len >= sizeof(pfs->m_filename))
len= sizeof(pfs->m_filename)-1;
- LF_PINS *pins;
PFS_file **entry;
- pins= lf_hash_get_pins(& filename_hash);
- DBUG_ASSERT(pins != NULL);
+ uint retry_count= 0;
+ const uint retry_max= 3;
+search:
entry= reinterpret_cast<PFS_file**>
- (lf_hash_search(& filename_hash, pins, filename, len));
- lf_hash_put_pins(pins);
+ (lf_hash_search(& filename_hash, thread->m_filename_hash_pins, filename, len));
if (entry && (entry != MY_ERRPTR))
{
pfs= *entry;
pfs->m_file_stat.m_open_count++;
+ lf_hash_search_unpin(thread->m_filename_hash_pins);
return pfs;
}
@@ -573,20 +589,31 @@ find_or_create_file(PFS_file_class *klas
pfs->m_wait_stat.m_control_flag= & flag_events_waits_summary_by_instance;
pfs->m_wait_stat.m_parent= & klass->m_wait_stat;
reset_single_stat_link(& pfs->m_wait_stat);
- pfs->m_bound= false;
- pfs->m_file_descriptor= 0;
int res;
- pins= lf_hash_get_pins(& filename_hash);
- DBUG_ASSERT(pins != NULL);
- res= lf_hash_insert(& filename_hash, pins, & pfs);
- lf_hash_put_pins(pins);
+ res= lf_hash_insert(& filename_hash, thread->m_filename_hash_pins, & pfs);
+ if (likely(res == 0))
+ {
+ pfs->m_lock.dirty_to_allocated();
+ return pfs;
+ }
+
+ pfs->m_lock.dirty_to_free();
+
if (res > 0)
{
- // TODO: resolve duplicate
+ /* Duplicate insert by another thread */
+ if (++retry_count > retry_max)
+ {
+ file_lost++;
+ return NULL;
+ }
+ goto search;
}
- pfs->m_lock.dirty_to_allocated();
- return pfs;
+
+ /* OOM in lf_hash_insert */
+ file_lost++;
+ return NULL;
}
}
}
@@ -602,6 +629,16 @@ void release_file(PFS_file *pfs)
pfs->m_file_stat.m_open_count--;
}
+void destroy_file(PFS_thread *thread, PFS_file *pfs)
+{
+ DBUG_ASSERT(thread != NULL);
+ DBUG_ASSERT(thread->m_filename_hash_pins != NULL);
+ DBUG_ASSERT(pfs != NULL);
+ lf_hash_delete(& filename_hash, thread->m_filename_hash_pins,
+ pfs->m_filename, pfs->m_filename_length);
+ pfs->m_lock.allocated_to_free();
+}
+
PFS_table* create_table(PFS_table_share *share, const void *identity)
{
int pass;
=== modified file 'storage/perfschema/pfs_instr.h'
--- a/storage/perfschema/pfs_instr.h 2009-05-29 01:48:47 +0000
+++ b/storage/perfschema/pfs_instr.h 2009-06-06 01:03:10 +0000
@@ -114,10 +114,6 @@ struct PFS_file : public PFS_instr
PFS_file_class *m_class;
/** File usage statistics. */
PFS_file_stat m_file_stat;
- /** True if this instrumented file is bound to a file descriptor. */
- bool m_bound;
- /** File descriptor bound to this instrumented file, if bound */
- File m_file_descriptor;
};
/**
@@ -146,6 +142,10 @@ struct PFS_thread
{
/** Internal lock. */
pfs_lock m_lock;
+ /** Pins for filename_hash. */
+ LF_PINS *m_filename_hash_pins;
+ /** Pins for table_share_hash. */
+ LF_PINS *m_table_share_hash_pins;
/** Event ID counter */
ulonglong m_event_id;
/** Thread instrumentation flag. */
@@ -302,12 +302,14 @@ void destroy_thread(PFS_thread *pfs);
/**
Find or create instrumentation for a file instance by file name.
+ @param thread the executing instrumented thread
@param klass the file class
@param filename the file name
@param len the length in bytes of filename
@return a file instance, or NULL
*/
-PFS_file* find_or_create_file(PFS_file_class *klass, const char *filename, uint len);
+PFS_file* find_or_create_file(PFS_thread *thread, PFS_file_class *klass,
+ const char *filename, uint len);
/**
Release instrumentation for a file instance.
@@ -316,6 +318,13 @@ PFS_file* find_or_create_file(PFS_file_c
void release_file(PFS_file *pfs);
/**
+ Destroy instrumentation for a file instance.
+ @param thread the executing thread instrumentation
+ @param pfs the file to destroy
+*/
+void destroy_file(PFS_thread *thread, PFS_file *pfs);
+
+/**
Create instrumentation for a table instance.
@param share the table share
@param identity the table address
@@ -415,6 +424,12 @@ void reset_events_waits_by_instance();
*/
void reset_per_thread_wait_stat();
+/** Hash table for instrumented files. */
+extern LF_HASH filename_hash;
+
+/** True if filename_hash is initialized. */
+extern bool filename_hash_inited;
+
/**
@}
*/
=== modified file 'storage/perfschema/pfs_instr_class.cc'
--- a/storage/perfschema/pfs_instr_class.cc 2009-05-29 01:48:47 +0000
+++ b/storage/perfschema/pfs_instr_class.cc 2009-06-06 01:03:10 +0000
@@ -21,6 +21,7 @@
#include "my_global.h"
#include "my_sys.h"
#include "pfs_instr_class.h"
+#include "pfs_instr.h"
#include "pfs_global.h"
#include "pfs_events_waits.h"
#include "mysql/psi/mysql_thread.h"
@@ -110,8 +111,8 @@ PFS_instr_class global_table_class=
{ & flag_events_waits_current, NULL, 0, 0, 0, 0} /* wait stat chain */
};
-static LF_HASH table_share_hash;
-static bool table_share_hash_inited= false;
+LF_HASH table_share_hash;
+bool table_share_hash_inited= false;
static volatile int32 file_class_dirty_count= 0;
static volatile int32 file_class_allocated_count= 0;
@@ -621,8 +622,11 @@ PFS_file_class *sanitize_file_class(PFS_
return NULL;
}
-PFS_table_share* find_or_create_table_share(const char *schema_name, uint schema_name_length,
- const char *table_name, uint table_name_length)
+PFS_table_share* find_or_create_table_share(PFS_thread *thread,
+ const char *schema_name,
+ uint schema_name_length,
+ const char *table_name,
+ uint table_name_length)
{
/* See comments in register_mutex_class */
int pass;
@@ -631,10 +635,17 @@ PFS_table_share* find_or_create_table_sh
if (! table_share_hash_inited)
{
+ /* Table instrumentation can be turned off. */
table_share_lost++;
return NULL;
}
+ if (unlikely(thread->m_table_share_hash_pins == NULL))
+ {
+ thread->m_table_share_hash_pins= lf_hash_get_pins(& table_share_hash);
+ DBUG_ASSERT(thread->m_table_share_hash_pins);
+ }
+
DBUG_ASSERT(schema_name_length <= NAME_LEN);
DBUG_ASSERT(table_name_length <= NAME_LEN);
@@ -648,16 +659,17 @@ PFS_table_share* find_or_create_table_sh
ptr[0]= 0; ptr++;
key.m_key_length= ptr - & key.m_hash_key[0];
- LF_PINS *pins;
PFS_table_share **entry;
- pins= lf_hash_get_pins(& table_share_hash);
- DBUG_ASSERT(pins != NULL);
+ uint retry_count= 0;
+ const uint retry_max= 3;
+search:
entry= reinterpret_cast<PFS_table_share**>
- (lf_hash_search(& table_share_hash, pins, & key.m_hash_key[0], key.m_key_length));
- lf_hash_put_pins(pins);
+ (lf_hash_search(& table_share_hash, thread->m_table_share_hash_pins,
+ & key.m_hash_key[0], key.m_key_length));
if (entry && (entry != MY_ERRPTR))
{
pfs= *entry;
+ lf_hash_search_unpin(thread->m_table_share_hash_pins);
return pfs;
}
@@ -690,15 +702,26 @@ PFS_table_share* find_or_create_table_sh
pfs->m_aggregated= false;
int res;
- pins= lf_hash_get_pins(& table_share_hash);
- DBUG_ASSERT(pins != NULL);
- res= lf_hash_insert(& table_share_hash, pins, & pfs);
- lf_hash_put_pins(pins);
+ res= lf_hash_insert(& table_share_hash,
+ thread->m_table_share_hash_pins, & pfs);
+ if (likely(res == 0))
+ {
+ pfs->m_lock.dirty_to_allocated();
+ return pfs;
+ }
+
+ pfs->m_lock.dirty_to_free();
+
if (res > 0)
{
- // TODO: resolve duplicate
+ /* Duplicate insert by another thread */
+ if (++retry_count > retry_max)
+ {
+ table_share_lost++;
+ return NULL;
+ }
+ goto search;
}
- pfs->m_lock.dirty_to_allocated();
return pfs;
}
}
=== modified file 'storage/perfschema/pfs_instr_class.h'
--- a/storage/perfschema/pfs_instr_class.h 2009-05-29 01:48:47 +0000
+++ b/storage/perfschema/pfs_instr_class.h 2009-06-06 01:03:10 +0000
@@ -60,6 +60,8 @@ typedef unsigned int PFS_thread_key;
/** Key, naming a file instrument. */
typedef unsigned int PFS_file_key;
+struct PFS_thread;
+
/**
Information for all instrumentation.
*/
@@ -332,13 +334,15 @@ PFS_file_class *sanitize_file_class(PFS_
/**
Find or create a table instance by name.
+ @param thread the executing instrumented thread
@param schema_name the table schema name
@param schema_name_length the table schema name length
@param table_name the table name
@param table_name_length the table name length
@return a table instance, or NULL
*/
-PFS_table_share *find_or_create_table_share(const char *schema_name,
+PFS_table_share *find_or_create_table_share(PFS_thread *thread,
+ const char *schema_name,
uint schema_name_length,
const char *table_name,
uint table_name_length);
@@ -383,6 +387,12 @@ extern PFS_table_share *table_share_arra
*/
void reset_instrument_class_waits();
+/** Hash table for instrumented tables. */
+extern LF_HASH table_share_hash;
+
+/** True if table_share_hash is initialized. */
+extern bool table_share_hash_inited;
+
/**
@}
*/
=== modified file 'storage/perfschema/pfs_lock.h'
--- a/storage/perfschema/pfs_lock.h 2009-05-19 14:50:00 +0000
+++ b/storage/perfschema/pfs_lock.h 2009-06-06 01:03:10 +0000
@@ -74,6 +74,11 @@ struct pfs_lock
*/
void dirty_to_allocated();
/**
+ Execute a dirty to free transition.
+ This transition should be executed by the writer that owns the record.
+ */
+ void dirty_to_free();
+ /**
Execute an allocated to recycle transition.
This transition should be executed by the writer that owns the record.
The record content should be unchanged, as readers are still allowed to read
@@ -162,6 +167,13 @@ inline void pfs_lock::dirty_to_allocated
my_atomic_store32(& m_state, PFS_LOCK_ALLOCATED);
}
+inline void pfs_lock::dirty_to_free()
+{
+ DBUG_ASSERT(m_state == PFS_LOCK_DIRTY);
+ m_version++;
+ my_atomic_store32(& m_state, PFS_LOCK_FREE);
+}
+
inline void pfs_lock::allocated_to_recycle()
{
DBUG_ASSERT(m_state == PFS_LOCK_ALLOCATED);
=== modified file 'storage/perfschema/unittest/pfs_instr-t.cc'
--- a/storage/perfschema/unittest/pfs_instr-t.cc 2009-05-29 01:48:47 +0000
+++ b/storage/perfschema/unittest/pfs_instr-t.cc 2009-06-06 01:03:10 +0000
@@ -110,19 +110,22 @@ void test_no_instances()
ok(thread == NULL, "no thread");
ok(thread_lost == 2, "lost 2");
- file= find_or_create_file(& dummy_file_class, "dummy", 5);
+ PFS_thread fake_thread;
+ fake_thread.m_filename_hash_pins= NULL;
+
+ file= find_or_create_file(& fake_thread, & dummy_file_class, "dummy", 5);
ok(file == NULL, "no file");
ok(file_lost == 1, "lost 1");
- file= find_or_create_file(& dummy_file_class, "dummy", 5);
+ file= find_or_create_file(& fake_thread, & dummy_file_class, "dummy", 5);
ok(file == NULL, "no file");
ok(file_lost == 2, "lost 2");
init_file_hash();
- file= find_or_create_file(& dummy_file_class, "dummy", 5);
+ file= find_or_create_file(& fake_thread, & dummy_file_class, "dummy", 5);
ok(file == NULL, "no file");
ok(file_lost == 3, "lost 3");
- file= find_or_create_file(& dummy_file_class, "dummy", 5);
+ file= find_or_create_file(& fake_thread, & dummy_file_class, "dummy", 5);
ok(file == NULL, "no file");
ok(file_lost == 4, "lost 4");
@@ -130,7 +133,7 @@ void test_no_instances()
int size= sizeof(long_file_name);
memset(long_file_name, 'X', size);
- file= find_or_create_file(& dummy_file_class, long_file_name, size);
+ file= find_or_create_file(& fake_thread, & dummy_file_class, long_file_name, size);
ok(file == NULL, "no file");
ok(file_lost == 5, "lost 5");
@@ -247,36 +250,39 @@ void test_with_instances()
ok(thread_2 != NULL, "thread");
ok(thread_lost == 1, "no new loss");
- file_1= find_or_create_file(& dummy_file_class, "dummy", 5);
+ PFS_thread fake_thread;
+ fake_thread.m_filename_hash_pins= NULL;
+
+ file_1= find_or_create_file(& fake_thread, & dummy_file_class, "dummy", 5);
ok(file_1 == NULL, "no file");
ok(file_lost == 1, "lost 1");
- file_1= find_or_create_file(& dummy_file_class, "dummy", 5);
+ file_1= find_or_create_file(& fake_thread, & dummy_file_class, "dummy", 5);
ok(file_1 == NULL, "no file");
ok(file_lost == 2, "lost 2");
init_file_hash();
file_lost= 0;
- file_1= find_or_create_file(& dummy_file_class, "dummy_A", 7);
+ file_1= find_or_create_file(& fake_thread, & dummy_file_class, "dummy_A", 7);
ok(file_1 != NULL, "file");
ok(file_1->m_file_stat.m_open_count == 1, "open count 1");
ok(file_lost == 0, "not lost");
- file_2= find_or_create_file(& dummy_file_class, "dummy_A", 7);
+ file_2= find_or_create_file(& fake_thread, & dummy_file_class, "dummy_A", 7);
ok(file_1 == file_2, "same file");
ok(file_1->m_file_stat.m_open_count == 2, "open count 2");
ok(file_lost == 0, "not lost");
release_file(file_2);
ok(file_1->m_file_stat.m_open_count == 1, "open count 1");
- file_2= find_or_create_file(& dummy_file_class, "dummy_B", 7);
+ file_2= find_or_create_file(& fake_thread, & dummy_file_class, "dummy_B", 7);
ok(file_2 != NULL, "file");
ok(file_lost == 0, "not lost");
- file_2= find_or_create_file(& dummy_file_class, "dummy_C", 7);
+ file_2= find_or_create_file(& fake_thread, & dummy_file_class, "dummy_C", 7);
ok(file_2 == NULL, "no file");
ok(file_lost == 1, "lost");
release_file(file_1);
/* the file still exists, not destroyed */
ok(file_1->m_file_stat.m_open_count == 0, "open count 0");
- file_2= find_or_create_file(& dummy_file_class, "dummy_D", 7);
+ file_2= find_or_create_file(& fake_thread, & dummy_file_class, "dummy_D", 7);
ok(file_2 == NULL, "no file");
ok(file_lost == 2, "lost");
=== modified file 'storage/perfschema/unittest/pfs_instr_class-t.cc'
--- a/storage/perfschema/unittest/pfs_instr_class-t.cc 2009-05-29 01:48:47 +0000
+++ b/storage/perfschema/unittest/pfs_instr_class-t.cc 2009-06-06 01:03:10 +0000
@@ -15,6 +15,7 @@
#include <mysql_priv.h>
#include <pfs_instr_class.h>
+#include <pfs_instr.h>
#include <pfs_global.h>
#include <tap.h>
@@ -75,11 +76,14 @@ void test_no_registration()
file_key= register_file_class("FOO", 3, 0);
ok(file_key == 0, "no file registered");
- table= find_or_create_table_share("foo_db", 6, "foo_table", 9);
+ PFS_thread fake_thread;
+ fake_thread.m_table_share_hash_pins= NULL;
+
+ table= find_or_create_table_share(& fake_thread, "foo_db", 6, "foo_table", 9);
ok(table == NULL, "not created");
- table= find_or_create_table_share("bar_db", 6, "bar_table", 9);
+ table= find_or_create_table_share(& fake_thread, "bar_db", 6, "bar_table", 9);
ok(table == NULL, "not created");
- table= find_or_create_table_share("foo_db", 6, "foo_table", 9);
+ table= find_or_create_table_share(& fake_thread, "foo_db", 6, "foo_table", 9);
ok(table == NULL, "not created");
mutex= find_mutex_class(0);
@@ -343,8 +347,11 @@ void test_table_registration()
PFS_table_share *table_share;
PFS_table_share *table_share_2;
+ PFS_thread fake_thread;
+ fake_thread.m_table_share_hash_pins= NULL;
+
table_share_lost= 0;
- table_share= find_or_create_table_share("db1", 3, "t1", 2);
+ table_share= find_or_create_table_share(& fake_thread, "db1", 3, "t1", 2);
ok(table_share == NULL, "not created");
ok(table_share_lost == 1, "lost the table");
@@ -352,37 +359,37 @@ void test_table_registration()
init_table_share(5);
init_table_share_hash();
- table_share= find_or_create_table_share("db1", 3, "t1", 2);
+ table_share= find_or_create_table_share(& fake_thread, "db1", 3, "t1", 2);
ok(table_share != NULL, "created db1.t1");
ok(table_share_lost == 0, "not lost");
- table_share_2= find_or_create_table_share("db1", 3, "t1", 2);
+ table_share_2= find_or_create_table_share(& fake_thread, "db1", 3, "t1", 2);
ok(table_share_2 != NULL, "found db1.t1");
ok(table_share_lost == 0, "not lost");
ok(table_share == table_share_2, "same table");
- table_share_2= find_or_create_table_share("db1", 3, "t2", 2);
+ table_share_2= find_or_create_table_share(& fake_thread, "db1", 3, "t2", 2);
ok(table_share_2 != NULL, "created db1.t2");
ok(table_share_lost == 0, "not lost");
- table_share_2= find_or_create_table_share("db2", 3, "t1", 2);
+ table_share_2= find_or_create_table_share(& fake_thread, "db2", 3, "t1", 2);
ok(table_share_2 != NULL, "created db2.t1");
ok(table_share_lost == 0, "not lost");
- table_share_2= find_or_create_table_share("db2", 3, "t2", 2);
+ table_share_2= find_or_create_table_share(& fake_thread, "db2", 3, "t2", 2);
ok(table_share_2 != NULL, "created db2.t2");
ok(table_share_lost == 0, "not lost");
- table_share_2= find_or_create_table_share("db3", 3, "t3", 2);
+ table_share_2= find_or_create_table_share(& fake_thread, "db3", 3, "t3", 2);
ok(table_share_2 != NULL, "created db3.t3");
ok(table_share_lost == 0, "not lost");
- table_share_2= find_or_create_table_share("db4", 3, "t4", 2);
+ table_share_2= find_or_create_table_share(& fake_thread, "db4", 3, "t4", 2);
ok(table_share_2 == NULL, "lost db4.t4");
ok(table_share_lost == 1, "lost");
table_share_lost= 0;
- table_share_2= find_or_create_table_share("db1", 3, "t2", 2);
+ table_share_2= find_or_create_table_share(& fake_thread, "db1", 3, "t2", 2);
ok(table_share_2 != NULL, "found db1.t2");
ok(table_share_lost == 0, "not lost");
ok(strncmp(table_share_2->m_schema_name, "db1", 3) == 0 , "schema db1");