Skip to content
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: risk of OOM #40400

Closed
buchuitoudegou opened this issue Jan 9, 2023 · 3 comments · Fixed by #40443
Closed

lightning: risk of OOM #40400

buchuitoudegou opened this issue Jan 9, 2023 · 3 comments · Fixed by #40443
Labels
affects-5.4 This bug affects 5.4.x versions. affects-6.1 affects-6.5 component/lightning This issue is related to Lightning of TiDB. severity/moderate type/bug The issue is confirmed as a bug.

Comments

@buchuitoudegou
Copy link
Contributor

buchuitoudegou commented Jan 9, 2023

reproduce

  1. create a csv file with unclosed quote till end:
1,2,3,"xxxxx...
  1. insert 10GB random bytes into the data file
  2. import

result

9a0e5a85-6d7d-4e2f-a8d3-ed4b08fb6c8e

If user wants to import a big file with unclosed quote, lightning might possibly be OOM.

@buchuitoudegou
Copy link
Contributor Author

/component lightning
/type bug
/severity moderate

@ti-chi-bot ti-chi-bot added component/lightning This issue is related to Lightning of TiDB. type/bug The issue is confirmed as a bug. severity/moderate labels Jan 9, 2023
@buchuitoudegou
Copy link
Contributor Author

root cause:

buf = append(buf, parser.buf...)
parser.buf = nil
if err := parser.readBlock(); err != nil || len(parser.buf) == 0 {
if err == nil {
err = io.EOF
}
parser.pos += int64(len(buf))
return buf, 0, errors.Trace(err)
}
index := IndexAnyByte(parser.buf, chars)
if index >= 0 {
buf = append(buf, parser.buf[:index]...)
parser.buf = parser.buf[index:]
parser.pos += int64(len(buf))
return buf, parser.buf[0], nil
}
}
}

the parser would try to read the block continually until it finds the quotes. But if the data files have syntax error (i.e., unterminated quotes), it won't stop.

@buchuitoudegou
Copy link
Contributor Author

relevant: #39980

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-5.4 This bug affects 5.4.x versions. affects-6.1 affects-6.5 component/lightning This issue is related to Lightning of TiDB. severity/moderate type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants