MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / keycache_dump

Function keycache_dump

mysys/mf_keycache.c:4247–4335  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4245
4246
4247static void keycache_dump(KEY_CACHE *keycache)
4248{
4249 FILE *keycache_dump_file=fopen(KEYCACHE_DUMP_FILE, "w");
4250 struct st_my_thread_var *last;
4251 struct st_my_thread_var *thread;
4252 BLOCK_LINK *block;
4253 HASH_LINK *hash_link;
4254 KEYCACHE_PAGE *page;
4255 uint i;
4256
4257 fprintf(keycache_dump_file, "thread:%u\n", thread->id);
4258
4259 i=0;
4260 thread=last=waiting_for_hash_link.last_thread;
4261 fprintf(keycache_dump_file, "queue of threads waiting for hash link\n");
4262 if (thread)
4263 do
4264 {
4265 thread=thread->next;
4266 page= (KEYCACHE_PAGE *) thread->opt_info;
4267 fprintf(keycache_dump_file,
4268 "thread:%u, (file,filepos)=(%u,%lu)\n",
4269 thread->id,(uint) page->file,(ulong) page->filepos);
4270 if (++i == MAX_QUEUE_LEN)
4271 break;
4272 }
4273 while (thread != last);
4274
4275 i=0;
4276 thread=last=waiting_for_block.last_thread;
4277 fprintf(keycache_dump_file, "queue of threads waiting for block\n");
4278 if (thread)
4279 do
4280 {
4281 thread=thread->next;
4282 hash_link= (HASH_LINK *) thread->opt_info;
4283 fprintf(keycache_dump_file,
4284 "thread:%u hash_link:%u (file,filepos)=(%u,%lu)\n",
4285 thread->id, (uint) HASH_LINK_NUMBER(hash_link),
4286 (uint) hash_link->file,(ulong) hash_link->diskpos);
4287 if (++i == MAX_QUEUE_LEN)
4288 break;
4289 }
4290 while (thread != last);
4291
4292 for (i=0 ; i< keycache->blocks_used ; i++)
4293 {
4294 int j;
4295 block= &keycache->block_root[i];
4296 hash_link= block->hash_link;
4297 fprintf(keycache_dump_file,
4298 "block:%u hash_link:%d status:%x #requests=%u waiting_for_readers:%d\n",
4299 i, (int) (hash_link ? HASH_LINK_NUMBER(hash_link) : -1),
4300 block->status, block->requests, block->condvar ? 1 : 0);
4301 for (j=0 ; j < 2; j++)
4302 {
4303 KEYCACHE_WQUEUE *wqueue=&block->wqueue[j];
4304 thread= last= wqueue->last_thread;

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected