CAS server: BatchReadBlobs returns incorrect response for duplicate digest
If a BatchReadBlobs
request is sent to the CAS server with the same (available) digest listed multiple times in the request, the response will include the digest multiple times as well, however, only the first response will contain real data, the data field in the additional responses with the same digest will be empty.
This can easily be reproduced with the test suite by adding [b'abc', b'abc']
to bloblists_to_request
in test_cas_batch_read_blobs()
in tests/cas/test_services.py
.
I suspect this was introduced in commit b2af8888. The result of bulk_read_blobs()
is a dictionary with the digest hash as key and an open file as value. As it's a dictionary, there is only one entry per digest. batch_read_blobs()
in cas/instance.py
calls read()
on the same open file multiple times if the same digest has been specified multiple times in the request. The first read()
will correctly read the file. All further read()
calls will result in an empty string as the file cursor is already at the end of the file.
For additional context, this was initially filed as a buildbox-casd bug: BuildGrid/buildbox/buildbox-casd#41 (closed)