Bug #51447 performance schema evil twin files
Submitted: 24 Feb 2010 7:08 Modified: 17 Mar 2010 16:34
Reporter: Marc ALFF Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Performance Schema Severity:S2 (Serious)
Version:mysql-5.5.99 (Celosia) OS:Any
Assigned to: Marc ALFF CPU Architecture:Any

[24 Feb 2010 7:08] Marc ALFF
Description:
In the performance schema file io instrumentation, a relative file name and an absolute file name pointing to the same file are considered different.

This causes file instrumentation leaks when both access pattern are used.

First detected while running sql-bench: file leak causes missed events.

How to repeat:
In the following test, see that the instrumentation causes duplicates and leaks for test/ghost.MYI

===

create table test.ghost (a int, b int);
alter table test.ghost add index index_a(a);
alter table test.ghost add index index_b(b);
insert into test.ghost values (1, 3);
insert into test.ghost values (2, 4);
select * from test.ghost;

select * from performance_schema.FILE_INSTANCES
  where file_name like "%ghost%";

drop table test.ghost;

select * from performance_schema.FILE_INSTANCES
  where file_name like "%ghost%";

select event_name, source, operation, object_name from performance_schema.EVENTS_WAITS_HISTORY_LONG
  where object_type='FILE' and object_name like "%ghost.MYI";

=======

create table test.ghost (a int, b int);
alter table test.ghost add index index_a(a);
alter table test.ghost add index index_b(b);
insert into test.ghost values (1, 3);
insert into test.ghost values (2, 4);
select * from test.ghost;
a       b
1       3
2       4
select * from performance_schema.FILE_INSTANCES
where file_name like "%ghost%";
FILE_NAME       EVENT_NAME      OPEN_COUNT
/home/malff/BZR_TREE/mysql-next-mr/mysql-test/var/mysqld.1/data/test/ghost.MYI  wait/io/file/myisam/kfile       1
./test/ghost.MYD        wait/io/file/myisam/dfile       3
./test/ghost.MYI        wait/io/file/myisam/kfile       2
./test/ghost.frm        wait/io/file/sql/FRM    2
drop table test.ghost;
select * from performance_schema.FILE_INSTANCES
where file_name like "%ghost%";
FILE_NAME       EVENT_NAME      OPEN_COUNT
/home/malff/BZR_TREE/mysql-next-mr/mysql-test/var/mysqld.1/data/test/ghost.MYI  wait/io/file/myisam/kfile       0
select event_name, source, operation, object_name from performance_schema.EVENTS_WAITS_HISTORY_LONG
where object_type='FILE' and object_name like "%ghost.MYI";
event_name      source  operation       object_name
wait/io/file/myisam/kfile       mi_create.c:644 create  /home/malff/BZR_TREE/mysql-next-mr/mysql-test/var/mysqld.1/data/test/ghost.MYI
wait/io/file/myisam/kfile       mi_open.c:936   write   /home/malff/BZR_TREE/mysql-next-mr/mysql-test/var/mysqld.1/data/test/ghost.MYI
wait/io/file/myisam/kfile       mi_open.c:1047  write   /home/malff/BZR_TREE/mysql-next-mr/mysql-test/var/mysqld.1/data/test/ghost.MYI
wait/io/file/myisam/kfile       mi_create.c:713 tell    /home/malff/BZR_TREE/mysql-next-mr/mysql-test/var/mysqld.1/data/test/ghost.MYI
wait/io/file/myisam/kfile       mi_open.c:1217  write   /home/malff/BZR_TREE/mysql-next-mr/mysql-test/var/mysqld.1/data/test/ghost.MYI
wait/io/file/myisam/kfile       mi_open.c:1217  write   /home/malff/BZR_TREE/mysql-next-mr/mysql-test/var/mysqld.1/data/test/ghost.MYI
wait/io/file/myisam/kfile       mi_open.c:1217  write   /home/malff/BZR_TREE/mysql-next-mr/mysql-test/var/mysqld.1/data/test/ghost.MYI
wait/io/file/myisam/kfile       mi_create.c:810 tell    /home/malff/BZR_TREE/mysql-next-mr/mysql-test/var/mysqld.1/data/test/ghost.MYI
wait/io/file/myisam/kfile       mi_create.c:820 chsize  /home/malff/BZR_TREE/mysql-next-mr/mysql-test/var/mysqld.1/data/test/ghost.MYI
wait/io/file/myisam/kfile       mi_create.c:836 close   /home/malff/BZR_TREE/mysql-next-mr/mysql-test/var/mysqld.1/data/test/ghost.MYI
wait/io/file/myisam/kfile       mi_open.c:125   open    /home/malff/BZR_TREE/mysql-next-mr/mysql-test/var/mysqld.1/data/test/ghost.MYI
wait/io/file/myisam/kfile       mi_open.c:137   read    /home/malff/BZR_TREE/mysql-next-mr/mysql-test/var/mysqld.1/data/test/ghost.MYI
wait/io/file/myisam/kfile       mi_open.c:188   seek    /home/malff/BZR_TREE/mysql-next-mr/mysql-test/var/mysqld.1/data/test/ghost.MYI
wait/io/file/myisam/kfile       mi_open.c:198   read    /home/malff/BZR_TREE/mysql-next-mr/mysql-test/var/mysqld.1/data/test/ghost.MYI
wait/io/file/myisam/kfile       mi_close.c:82   close   /home/malff/BZR_TREE/mysql-next-mr/mysql-test/var/mysqld.1/data/test/ghost.MYI
wait/io/file/myisam/kfile       mi_rename.c:50  rename  ./test/ghost.MYI
wait/io/file/myisam/kfile       mi_open.c:125   open    /home/malff/BZR_TREE/mysql-next-mr/mysql-test/var/mysqld.1/data/test/ghost.MYI
wait/io/file/myisam/kfile       mi_open.c:137   read    /home/malff/BZR_TREE/mysql-next-mr/mysql-test/var/mysqld.1/data/test/ghost.MYI
wait/io/file/myisam/kfile       mi_open.c:188   seek    /home/malff/BZR_TREE/mysql-next-mr/mysql-test/var/mysqld.1/data/test/ghost.MYI
wait/io/file/myisam/kfile       mi_open.c:198   read    /home/malff/BZR_TREE/mysql-next-mr/mysql-test/var/mysqld.1/data/test/ghost.MYI
wait/io/file/myisam/kfile       mi_close.c:82   close   /home/malff/BZR_TREE/mysql-next-mr/mysql-test/var/mysqld.1/data/test/ghost.MYI
wait/io/file/myisam/kfile       mi_rename.c:50  rename  ./test/ghost.MYI
wait/io/file/myisam/kfile       mi_open.c:125   open    /home/malff/BZR_TREE/mysql-next-mr/mysql-test/var/mysqld.1/data/test/ghost.MYI
wait/io/file/myisam/kfile       mi_open.c:137   read    /home/malff/BZR_TREE/mysql-next-mr/mysql-test/var/mysqld.1/data/test/ghost.MYI
wait/io/file/myisam/kfile       mi_open.c:188   seek    /home/malff/BZR_TREE/mysql-next-mr/mysql-test/var/mysqld.1/data/test/ghost.MYI
wait/io/file/myisam/kfile       mi_open.c:198   read    /home/malff/BZR_TREE/mysql-next-mr/mysql-test/var/mysqld.1/data/test/ghost.MYI
wait/io/file/myisam/kfile       mi_locking.c:548        write   /home/malff/BZR_TREE/mysql-next-mr/mysql-test/var/mysqld.1/data/test/ghost.MYI
wait/io/file/myisam/kfile       mi_open.c:934   write   /home/malff/BZR_TREE/mysql-next-mr/mysql-test/var/mysqld.1/data/test/ghost.MYI
wait/io/file/myisam/kfile       mi_open.c:934   write   /home/malff/BZR_TREE/mysql-next-mr/mysql-test/var/mysqld.1/data/test/ghost.MYI
wait/io/file/myisam/kfile       mi_locking.c:577        write   /home/malff/BZR_TREE/mysql-next-mr/mysql-test/var/mysqld.1/data/test/ghost.MYI
wait/io/file/myisam/kfile       mi_close.c:82   close   /home/malff/BZR_TREE/mysql-next-mr/mysql-test/var/mysqld.1/data/test/ghost.MYI
wait/io/file/myisam/kfile       mi_delete_table.c:61    delete  ./test/ghost.MYI

Suggested fix:
Normalize file names to resolve aliases.
[25 Feb 2010 17:46] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/101516

2988 Marc Alff	2010-02-25
      Bug#51447 performance schema evil twin files
      
      Before this fix, the performance schema file instrumentation would treat:
      - a relative path to a file
      - an absolute path to the same file
      as two different files.
      
      This would lead to:
      - separate aggregation counters
      - file leaks when a file is removed.
      
      With this fix, a relative and absolute path are resolved to the same file instrument.
[26 Feb 2010 17:43] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/101703

3114 Marc Alff	2010-02-26
      Bug#51447 performance schema evil twin files
      
      Before this fix, the performance schema file instrumentation would treat:
      - a relative path to a file
      - an absolute path to the same file
      as two different files.
      
      This would lead to:
      - separate aggregation counters
      - file leaks when a file is removed.
      
      With this fix, a relative and absolute path are resolved to the same file instrument.
[1 Mar 2010 17:05] Marc ALFF
Patch queued in:
- mysql-next-mr-bugfixing
- mysql-6.0-codebase-bugfixing
[1 Mar 2010 17:08] Marc ALFF
While the code itself is ok, the test fails when used with MTR_MEM=1,
which mounts a file system on shared memory.

Changing back to in progress, to find a better solution that also works
with MTR_MEM=1
[5 Mar 2010 1:14] Marc ALFF
See related
Bug#51741 Unit test pfs-t failing in mysql-next-mr-bugfixing
[6 Mar 2010 10:29] Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20100306102742-yw9zzgw9ac5r65m5) (version source revid:bar@mysql.com-20100305074327-h09o5lw290s04lcf) (merge vers: 6.0.14-alpha) (pib:16)
[6 Mar 2010 10:31] Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100306102638-qna09hbjb5gm940h) (version source revid:alik@sun.com-20100304153932-9hajxhhyanqbckmu) (pib:16)
[6 Mar 2010 10:53] Bugs System
Pushed into 5.5.3-m3 (revid:alik@sun.com-20100306103849-hha31z2enhh7jwt3) (version source revid:alik@sun.com-20100304153932-9hajxhhyanqbckmu) (merge vers: 5.5.99-m3) (pib:16)
[10 Mar 2010 13:38] Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20100310133305-0jdlngbtrkoqzckh) (version source revid:alik@sun.com-20100310132404-uqarl0o0vlra2kjx) (merge vers: 6.0.14-alpha) (pib:16)
[10 Mar 2010 13:38] Bugs System
Pushed into 5.5.3-m3 (revid:alik@sun.com-20100310132634-zpyjzn346sgrm59u) (version source revid:alik@sun.com-20100310132634-zpyjzn346sgrm59u) (merge vers: 5.5.3-m3) (pib:16)
[10 Mar 2010 13:39] Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100310132718-l0tegumhbg8umgjd) (version source revid:alik@sun.com-20100310132252-kpi29r22kjtl493x) (pib:16)
[17 Mar 2010 11:11] Marc ALFF
perfshema.misc fails with MTR_MEM
See bug#52134
[17 Mar 2010 11:14] Marc ALFF
The original bug reported in Bug#51447 has been fixed, in 5.5.3 and 6.0.
Setting this report to documenting to reflect the status of this fix.

A related bug still exists for another use case, which will be fixed with bug#52134
[17 Mar 2010 16:34] Paul DuBois
Does not appear in any released version. No changelog entry needed.