Skip to content

Memory leak in EventDeserializer caused by tableMapEventByTableId #62

@TengHuo

Description

@TengHuo

Hi @osheroff

There is a long ago memory leak issue in EventDeserializer caused by tableMapEventByTableId. I saw you fixed it by using a bounded map which has size limit of 10000

code here:

It can avoid the huge memory usage when there are large amount of tables in one MySQL instance, but it still could take a lot of memory if this map is almost full. We got this issue in Debezium.

memory_leak

However, according to this post: https://dba.stackexchange.com/questions/51873/replication-binary-log-parsingtableid-generation-on-delete-cascade-handling
(a better investigation post but in Chinese: http://blog.chinaunix.net/uid-26896862-id-3329896.html)

Table id is not a constant value in one MySQL instance, it will assign a new id when there is no cached table id found, or roll to a new id when the cache in MySQL server my_hash_search_using_hash_value is full. Thus, it is not necessary keeping this tableMapEventByTableId map all the time.

I have a fix for this issue by just cleaning this map regularly after receiving a MySQL binlog ROTATE event (definition here: https://dev.mysql.com/doc/internals/en/event-meanings.html)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions