-
Notifications
You must be signed in to change notification settings - Fork 200
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
[Bug] Docsum file upload handling fails with concurrent http request with same file name #1279
Comments
With multiple parallel requests, Python HTTP module calls code here, from multiple threads, in parallel: Meaning that those threads overwrite and remove each other's temporary file. That code has also other security / reliability bugs:
There are few ways to fix that:
Also, are (HTTP server component) limits set on how large and how many files can be upload in parallel? I.e. could the (potential) attacker just send e.g. 1000x 1GB files to evict all OPEA services from a node[1], or OOM the node[2], because service exhausted [1] in case |
#1286 should fix this. |
Looking at the changes, yes, but I'll let @vrantala to verify that for real. Fix seems rather non-optimal. Easiest change should be just using |
I don't get your point. This issue is about the concurrency issue when uploading multiple files with the same file names. If you still use the file name to differentiate, won't it just repeat the bug? Would be great if you can open your own PR and do the test and the benchmark to prove what you say the "optimal" approach! |
Ah, sorry that was brainfart, I thought that either But I think temporary file handling should be moved to And temporary file handling could be using [1] UploadFile: https://github.com/encode/starlette/blob/master/starlette/datastructures.py#L409 |
@Spycsh I did some testing with I don't have time to test it properly / with full DocSum functionality though, so it would be great if you could check it! |
@eero-t , thanks for suggestions and explanation, will revisit the your patch at a later point when my schedule allows! |
Tested the fix in #1286. PR fixed this issue. |
Priority
P2-High
OS type
Ubuntu
Hardware type
Xeon-SPR
Installation method
Deploy method
Running nodes
Single Node
What's the version?
opea/docsum:latest sha256:42115ddbf5199060c94f66d654e9e2f128406e94b8dc0a3b3929bae93d4ba829
opea/llm-docsum-tgi:latest sha256:06c8095ccd0ca48de6588ee3bfbddb233d1e9e8cf4c4aeaa60e10eca4571fea4
Description
When sending http-request
Making request to /v1/docsum with files {'type': (None, 'text'), 'messages': (None, ''), 'files': ('pubmed_10.txt', <_io.BufferedReader name='/home/testrunner/users.vrantala/opea_benchmarking/data/pubmed_10.txt'>, 'text/plain'), 'max_tokens': (None, '1024'), 'language': (None, 'en'), 'stream': (None, 'true')}
to docsum service endpoint with Locust test-bench.
It starts giving "POST /v1/docsum HTTP/1.1" 500 Internal Server Error.
Reproduce steps
Send concurrent http-requests with same filename to the docsum service endpoint.
Http-request info:
Making request to /v1/docsum with files {'type': (None, 'text'), 'messages': (None, ''), 'files': ('pubmed_10.txt', <_io.BufferedReader name='/home/testrunner/users.vrantala/opea_benchmarking/data/pubmed_10.txt'>, 'text/plain'), 'max_tokens': (None, '1024'), 'language': (None, 'en'), 'stream': (None, 'true')}
Raw log
The text was updated successfully, but these errors were encountered: