mariadb/storage/myisam
Venkata Sidagam 4ff100e69d Bug #13955256: KEYCACHE CRASHES, CORRUPTIONS/HANGS WITH,
FULLTEXT INDEX AND CONCURRENT DML.

Problem Statement:
------------------
1) Create a table with FT index.
2) Enable concurrent inserts.
3) In multiple threads do below operations repeatedly
   a) truncate table
   b) insert into table ....
   c) select ... match .. against .. non-boolean/boolean mode

After some time we could observe two different assert core dumps

Analysis:
--------
1)assert core dump at key_read_cache():
Two select threads operating in-parallel on same key 
root block.
1st select thread block->status is set to BLOCK_ERROR 
because the my_pread() in read_block() is returning '0'. 
Truncate table made the index file size as 1024 and pread 
was asked to get the block of count bytes(1024 bytes) 
from offset of 1024 which it cannot read since its 
"end of file" and retuning '0' setting 
"my_errno= HA_ERR_FILE_TOO_SHORT" and the key_file_length, 
key_root[0] is same i.e. 1024. Since block status has BLOCK_ERROR 
the 1st select thread enter into the free_block() and will 
be under wait on conditional mutex by making status as 
BLOCK_REASSIGNED and goes for wait_on_readers(). Other select 
thread will also work on the same block and sees the status as 
BLOCK_ERROR and enters into free_block(), checks for BLOCK_REASSIGNED 
and asserting the server.

2)assert core dump at key_write_cache():
One select thread and One insert thread.
Select thread gets the unlocks the 'keycache->cache_lock', 
which allows other threads to continue and gets the pread() 
return value as'0'(please see the explanation above) and 
tries to get the lock on 'keycache->cache_lock' and waits 
there for the lock.
Insert thread requests for the block, block will be assigned 
from the hash list and makes the page_status as 
'PAGE_WAIT_TO_BE_READ' and goes for the read_block(), waits 
in the queue since there are some other threads performing 
reads on the same block.
Select thread which was waiting for the 'keycache->cache_lock' 
mutex in the read_block() will continue after getting the my_pread() 
value as '0' and sets the block status as BLOCK_ERROR and goes to 
the free_block() and go to the wait_for_readers().
Now the insert thread will awake and continues. and checks 
block->status as not BLOCK_READ and it asserts.  

Fix:
---
In the full text code, multiple readers of index file is not guarded. 
Hence added below below code in _ft2_search() and walk_and_match().

to lock the key_root I have used below code in _ft2_search()
 if (info->s->concurrent_insert)
    mysql_rwlock_rdlock(&share->key_root_lock[0]);

and to unlock 
 if (info->s->concurrent_insert)
   mysql_rwlock_unlock(&share->key_root_lock[0]);
2012-05-16 16:14:27 +05:30
..
ftbench Merge 2010-12-29 00:47:05 +01:00
.cvsignore
ChangeLog
CMakeLists.txt Updated/added copyright headers 2011-06-30 17:37:13 +02:00
ft_boolean_search.c Bug #13955256: KEYCACHE CRASHES, CORRUPTIONS/HANGS WITH, 2012-05-16 16:14:27 +05:30
ft_eval.c
ft_eval.h
ft_nlq_search.c Bug #13955256: KEYCACHE CRASHES, CORRUPTIONS/HANGS WITH, 2012-05-16 16:14:27 +05:30
ft_parser.c Updated/added copyright headers 2011-06-30 17:37:13 +02:00
ft_static.c
ft_stem.c
ft_stopwords.c Updated/added copyright headers 2011-07-03 17:47:37 +02:00
ft_test1.c
ft_test1.h
ft_update.c
ftdefs.h Updated/added copyright headers 2011-06-30 17:37:13 +02:00
fulltext.h Updated/added copyright headers 2011-06-30 17:37:13 +02:00
ha_myisam.cc BUG#11757032 - 49030: OPTIMIZE TABLE BREAKS MYISAM TABLE WHEN 2011-10-20 15:03:22 +04:00
ha_myisam.h Updated/added copyright headers 2011-07-03 17:47:37 +02:00
make-ccc
Makefile.am
mi_cache.c
mi_changed.c
mi_check.c Updated/added copyright headers 2012-02-15 17:21:38 +01:00
mi_checksum.c
mi_close.c Updated/added copyright headers 2012-02-15 17:21:38 +01:00
mi_create.c Updated/added copyright headers 2011-07-03 17:47:37 +02:00
mi_dbug.c Updated/added copyright headers 2011-06-30 17:37:13 +02:00
mi_delete.c Updated/added copyright headers 2011-06-30 17:37:13 +02:00
mi_delete_all.c Updated/added copyright headers 2012-02-15 17:21:38 +01:00
mi_delete_table.c Updated/added copyright headers 2011-06-30 17:37:13 +02:00
mi_dynrec.c Updated/added copyright headers 2011-06-30 17:37:13 +02:00
mi_extra.c Updated/added copyright headers 2011-06-30 17:37:13 +02:00
mi_info.c
mi_key.c
mi_keycache.c
mi_locking.c Updated/added copyright headers 2011-06-30 17:37:13 +02:00
mi_log.c
mi_open.c Updated/added copyright headers 2011-06-30 17:37:13 +02:00
mi_packrec.c Updated/added copyright headers 2012-02-15 17:21:38 +01:00
mi_page.c Updated/added copyright headers 2011-06-30 17:37:13 +02:00
mi_panic.c
mi_preload.c Updated/added copyright headers 2012-02-15 17:21:38 +01:00
mi_range.c Updated/added copyright headers 2011-07-03 20:08:47 +02:00
mi_rename.c
mi_rfirst.c
mi_rkey.c
mi_rlast.c
mi_rnext.c Updated/added copyright headers 2011-06-30 17:37:13 +02:00
mi_rnext_same.c
mi_rprev.c
mi_rrnd.c
mi_rsame.c
mi_rsamepos.c
mi_scan.c
mi_search.c Updated/added copyright headers 2011-06-30 17:37:13 +02:00
mi_static.c Updated/added copyright headers 2011-06-30 17:37:13 +02:00
mi_statrec.c
mi_test1.c Updated/added copyright headers 2011-07-03 17:47:37 +02:00
mi_test2.c Updated/added copyright headers 2011-06-30 17:37:13 +02:00
mi_test3.c
mi_test_all.res
mi_test_all.sh Merge 2010-12-29 00:47:05 +01:00
mi_unique.c Updated/added copyright headers 2011-06-30 17:37:13 +02:00
mi_update.c Updated/added copyright headers 2011-07-03 17:47:37 +02:00
mi_write.c BUG#11761180 - 53646: MYISAMPACK CORRUPTS TABLES WITH 2011-09-16 15:30:31 +04:00
myisam_ftdump.c Updated/added copyright headers 2011-06-30 17:37:13 +02:00
myisamchk.c Updated/added copyright headers 2011-06-30 17:37:13 +02:00
myisamdef.h Updated/added copyright headers 2011-07-03 17:47:37 +02:00
myisamlog.c Updated/added copyright headers 2011-06-30 17:37:13 +02:00
myisampack.c Updated/added copyright headers 2011-06-30 17:37:13 +02:00
NEWS
plug.in
rt_index.c Merge 2010-12-29 00:47:05 +01:00
rt_index.h
rt_key.c
rt_key.h
rt_mbr.c
rt_mbr.h
rt_split.c Updated/added copyright headers 2011-06-30 17:37:13 +02:00
rt_test.c
sort.c Updated/added copyright headers 2011-06-30 17:37:13 +02:00
sp_defs.h
sp_key.c
sp_test.c Updated/added copyright headers 2011-07-03 17:47:37 +02:00
test_pack
TODO