reverbrain / elliptics

Distributed storage for medium and large objects with streaming support
http://reverbrain.com/elliptics
GNU Lesser General Public License v3.0
496 stars 85 forks source link

Do not handle lookup by cache if it does not have the key #698

Closed shaitan closed 8 years ago

shaitan commented 8 years ago

Cache handles lookups by sending another lookups directly to the backend, but it is unnecessary when cache does not have the key.

shaitan commented 8 years ago

It shouldn't break anything.

bioothod commented 8 years ago

Why is it unnecessary? Lookup command is about returning data from disk, it is perfectly valid not to have given key in the cache, but have it on disk.

This pull request breaks every installation which has cache enabled, since every lookup will fail if there is no data in the cache, for example after node restart.

shaitan commented 8 years ago

I mean that "sending another lookup directly to the backend, when cache does not have the key, is unnecessary". So in this case cache should return -ENOTSUP to make outside logic (dnet_process_cmd_with_backend_raw) calls backend's handler for original request.

shaitan commented 8 years ago

Maybe it is better to:

bioothod commented 8 years ago

Returning -ENOTSUP is an abuse of the error code, other levels can not determine whether cache is enabled or it doesn't have data. I think that returning -ENOENT and handling it properly by routing request to the backend is the way to go.

shaitan commented 8 years ago

I've replaced ENOTSUP by ENOENT in this code and have added routing request to the backend when cache lookup is failed with -ENOENT.