go-diskqueue icon indicating copy to clipboard operation
go-diskqueue copied to clipboard

Configurable total size limit and delete old data when exceeded

Open leonzz opened this issue 3 years ago • 5 comments

Right now new data Put() would fail if disk is out of space. It would be great to have an option to

  1. limit the total disk space consumed by diskqueue;
  2. delete old data when space limit is reached but we still have new data coming in.

leonzz avatar May 10 '21 19:05 leonzz

I can see some value in providing a "strategy" for how the queue should behave in the event of inevitable data loss (discard old or new data), but the point of this library is to durably persist data so that it can be subsequently iterated over. Running out of disk space isn't really in the scope of the functionality provided.

mreiferson avatar May 15 '21 18:05 mreiferson

Thanks @mreiferson Yes I understand it's out of the scope of the original design but with the added strategy of discarding old data, it'll enable many more use cases-)

If we have the bandwidth to implement this feature, would you consider accepting the PR and maintaining it later on? It will be guarded by a flag and won't break existing use cases.

leonzz avatar May 17 '21 17:05 leonzz

Rather than building all this kind of functionality in to the core, I think that coming up with an API for diskqueue such that the application integrating with it could observe conditions like this and act on them however they wanted seems like a better approach.

For example, right now the API we expose only allows reading, writing, purging, and very minimal introspection (Depth()). What we would need is to extend the API to expose more stats (like size on disk) and perhaps a way to purge specific segments.

mreiferson avatar May 30 '21 15:05 mreiferson

Depth() is also costly to run; getting a less expensive way to observe queue depth would be great.

iseletsk avatar Dec 03 '22 19:12 iseletsk

Thanks for the follow-ups! We've implemented a disk size limit in this fork It added new matadata (e.g. number of msg per file) to keep accurate track of depth when a file is deleted before full read. Feel free to check it out and merge to this main repo if you like-)

leonzz avatar Dec 28 '22 22:12 leonzz