Implements flush and flush_all #21

Closed
wants to merge 3 commits into
from

Conversation

Projects
None yet
2 participants
Contributor

nova77 commented Mar 11, 2013

Apparently the fastest way to clear a leveldb instance is to close the db, delete the directory and start over.

src/queue/queue.cpp
+
+ wake_up(); // in case there's a waiter waiting
+
+ waiters_.clear();
@erikfrey

erikfrey Mar 11, 2013

Contributor

hmm, why are you clearing out the waiters? you're invalidating iterators that are sitting out in asio wait events.

@nova77

nova77 Mar 12, 2013

Contributor

Well, the idea was to get around the issue you lay below, but it seems I did not know enough about the code.

Contributor

erikfrey commented Mar 11, 2013

Hmm, unfortunately this isn't going to work as is. Queue has a few methods that the client chains together to maintain state. So, for example, a push with a large object may in fact be multiple pushes. Something like this.

while (chunk = read_chunk())
   queue_.push(chunk);

Similarly, popping has a few states:

id = queue_.pop_begin();
while (chunk = queue.pop_read(id))
   write_chunk(chunk);
queue.pop_end(id);

We need to describe behavior for what happens if a client is in the middle of pushing or popping when you call flush()

OR we need to make it illegal to flush during pushing/popping, which would be okay, I suppose

OR we need to make it that flushing can only happen completely in between pushing and popping, but this could be trickier.

Contributor

nova77 commented Mar 12, 2013

Queue has a few methods that the client chains together to maintain state

Can you make me an example of such commands chain? I had the impression that the set/get operations were considered atomic from the client prospective.

If we can figure out a way give a state to the chain, we could enforce exclusivity of the flush operation via a shared mutex.

Contributor

nova77 commented Mar 15, 2013

Closed in favour of #22.

@nova77 nova77 closed this Mar 15, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment