Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compaction fails #64

Open
csterritt opened this issue Jul 2, 2016 · 4 comments
Open

Compaction fails #64

csterritt opened this issue Jul 2, 2016 · 4 comments

Comments

@csterritt
Copy link

csterritt commented Jul 2, 2016

Hi -- really liking medea so far, in spite of the mythological allusions :-)

I'm writing some simple example code, first to create some entries, next to list some, and finally to delete some entries.

I was surprised to see that if I delete a key 'foo', then the next time I list all the keys it's there, with a value of 'undefined'. Is this expected behavior?

So I thought I'd try compacting the database after deleting a key, and got the following error:

% node delete_some_entries.js
Key 'foo' removed.
Error on medea compact: { Error: EBADF: bad file descriptor, fsync
    at Error (native) errno: -9, code: 'EBADF', syscall: 'fsync' }
Compact done.

This is using node v6.2.0 on OS X El Capitan.

Thanks!

@csterritt
Copy link
Author

Update: I thought I'd try removing the db.compact call from the code which does the deletes, and put it in its own file.

I deleted the storage directory contents, re-created the data, and ran:

% node compact_db.js
Compact done.
% node list_entries.js
Key 'foo' has val undefined (?)
Key 'bar' has val 'bar_value'
Key 'baz' has val 'baz_value'

So no error (yay!) but I still see that the key deleted ('foo') is still in the list of keys. Is this expected behavior?

Thanks!

@kevinswiber
Copy link
Member

Hey, @csterritt! Having no error and a value of undefined is the equivalent of a "Not Found." You can see how medeadown handles it here: https://github.com/medea/medeadown/blob/master/medeadown.js#L122

@csterritt
Copy link
Author

Hey @kevinswiber thanks for the reply!

I guess I assumed that database compaction would remove a key with no value. Nope?

@rijnhard
Copy link

I'd also like to know the answer to this.
Compactions should remove deleted keys (the equivalent of an AOF rewrite)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants