-
Notifications
You must be signed in to change notification settings - Fork 5.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lightning: Memory Leak on Large Source Files #39331
Labels
affects-5.2
This bug affects 5.2.x versions.
affects-5.3
This bug affects 5.3.x versions.
affects-5.4
This bug affects 5.4.x versions.
affects-6.0
affects-6.1
affects-6.2
affects-6.3
affects-6.4
component/lightning
This issue is related to Lightning of TiDB.
severity/major
type/bug
The issue is confirmed as a bug.
Comments
/component lightning |
ti-chi-bot
added
the
component/lightning
This issue is related to Lightning of TiDB.
label
Nov 23, 2022
/severity major |
ti-chi-bot
added
severity/major
may-affects-4.0
This bug maybe affects 4.0.x versions.
may-affects-5.0
This bug maybe affects 5.0.x versions.
may-affects-5.1
This bug maybe affects 5.1.x versions.
may-affects-5.2
This bug maybe affects 5.2.x versions.
may-affects-5.3
This bug maybe affects 5.3.x versions.
may-affects-5.4
This bug maybe affects 5.4.x versions.
may-affects-6.0
may-affects-6.1
may-affects-6.2
may-affects-6.3
may-affects-6.4
labels
Nov 23, 2022
I've got the memory leak point. It's in here: tidb/br/pkg/lightning/backend/kv/session.go Line 102 in 8fc4535
When the kvMemBuf tries to allocate buffer, it only checks the first byte buffer's capacity in the available byte buffer pool. If the capacity is less than the allocating size, it'll create a new byte buffer, which will allocate a new pieces of memory using manual.New() .Since all the byte buffers are recycled by putting back into the available byte buffer pool, this means, each time an allocation with a size bigger than the first byte buffer's capacity, a new byte buffer will be generated with extra memory allocated, and those memory will not be freed until the chunk restore is finished. However, when strict-mode is set to false, the large file is treated as a single chunk. The chunk restore process cannot finish in a short period of time, and the byte buffers are accumulating more and more, resulting in memory leak and potential OOM.
|
dsdashun
removed
may-affects-4.0
This bug maybe affects 4.0.x versions.
may-affects-5.1
This bug maybe affects 5.1.x versions.
may-affects-5.2
This bug maybe affects 5.2.x versions.
may-affects-5.3
This bug maybe affects 5.3.x versions.
may-affects-5.4
This bug maybe affects 5.4.x versions.
may-affects-5.0
This bug maybe affects 5.0.x versions.
may-affects-6.0
may-affects-6.1
may-affects-6.2
may-affects-6.3
labels
Nov 28, 2022
dsdashun
added
affects-5.2
This bug affects 5.2.x versions.
affects-5.3
This bug affects 5.3.x versions.
affects-5.4
This bug affects 5.4.x versions.
affects-6.0
affects-6.1
affects-6.2
affects-6.3
affects-6.4
and removed
may-affects-6.4
labels
Nov 28, 2022
ti-chi-bot
pushed a commit
that referenced
this issue
Nov 28, 2022
This was referenced Nov 28, 2022
ti-chi-bot
added a commit
that referenced
this issue
Dec 5, 2022
ti-chi-bot
added a commit
that referenced
this issue
Jan 18, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
affects-5.2
This bug affects 5.2.x versions.
affects-5.3
This bug affects 5.3.x versions.
affects-5.4
This bug affects 5.4.x versions.
affects-6.0
affects-6.1
affects-6.2
affects-6.3
affects-6.4
component/lightning
This issue is related to Lightning of TiDB.
severity/major
type/bug
The issue is confirmed as a bug.
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
2. What did you expect to see? (Required)
The memory usage should be stable, even if the source data is large, because Lightning is streaming-processing the data.
3. What did you see instead (Required)
The memory of Lightning process is increasing continuously. I suspect there might be memory leaks.
4. What is your TiDB version? (Required)
latest version
The text was updated successfully, but these errors were encountered: