Project

General

Profile

Bug #7121

Updated by Tom Clegg over 8 years ago

PUT uses 2x 64 MiB buffers if the block already exists on disk. One buffer is used to read the request body, the other is used to read the on-disk data into memory in order to compare it with the first buffer. 

 Aside from wasting memory, this can cause deadlock: if there are N bufferpool slots, and N concurrent PUT requests, each request gets one slot when it starts reading the request body, then all requests deadlock waiting for a "compare" buffer to become available. 

 We could fix this by adding a Compare() method to Volume (return true if content of file on disk is equal to this buf) instead of holding one buf of client-provided data, reading the data from disk into a second buffer, and comparing them. 

 It would be even better to do the compare operation _while_ reading the request body Aside from the client. However, wasting memory, this might get complicated: we'd need to read the data from disk at full speed (even can cause deadlock: if the client connection is slow) to avoid holding the spindle lock too long there are N bufferpool slots, and shutting out other requests. I suggest we defer this aspect -- for now just fix N concurrent PUT requests, each request gets one slot when it starts reading the request body, then all requests deadlock and 2x memory use. waiting for a "compare" buffer to become available. 

Back