ipfs / go-ds-flatfs

A datastore implementation using sharded directories and flat files to store data
MIT License
46 stars 21 forks source link

Make delete idempotent #30

Closed Stebalien closed 6 years ago

Stebalien commented 6 years ago

Currently, delete on a non-existent key returns ErrNotFound. However, this isn't really all that useful. Additionally,

  1. badgerdb doesn't return an error when deleting a non-existent and making it do so will be a slight performance hit.
  2. 27 will cause deletes to succeed, sometimes, even when there was no value to be deleted (e.g., a concurrent delete and put where we resolve the put after the delete).

whyrusleeping commented 6 years ago

hrm... I was against this until you threw my weakness at me. I love making things idempotent...

kevina commented 6 years ago

I think we should fix what every in #27 that causes delete to not return the correct value. I am against returning less information than we know.

At the specification level I would say that a datastore should have an option of not returning ErrNotFound but it should be allowed to. If it does return ErrNotFound it should do so consistently.

Stebalien commented 6 years ago

Moving to: https://github.com/ipfs/go-datastore/issues/104