Skip to content

Conversation

Wondertan
Copy link
Member

Adds a Sync method which ensures all pending writes are processed. It blocks until the operation completes or fails.
Also, the method gets used in DeleteTo, ensuring deletion always operates on the latest state.

This is technically a hack for until #241 and #263 come

@Wondertan Wondertan self-assigned this May 12, 2025
@Wondertan Wondertan force-pushed the store/flush branch 3 times, most recently from 2ef0f04 to af22edd Compare May 12, 2025 00:53
Copy link
Member

@renaynay renaynay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fine w this, chan chan :)

// and Store is not stopping(headers == nil)
if s.pending.Len() < s.Params.WriteBatchSize && headers != nil {
continue
return
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah okay so you want to leave not large enough un-flushed batch in waiting and exit flush loop so that we aren't writing anything to disk for the Sync call, I see.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is why the method is not called Flush but Sync, which initially I called in Flush, but then realized that akcshually its not Flush

// (2) Batching header writes
func (s *Store[H]) flushLoop() {
defer close(s.writesDn)
ctx := context.Background()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

side note - we never cancel this ctx if we exit, should we put a cancellation in defer ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can and even should if any internal calls spins up a backrground routine waiting on context, but as its not happening anywhere yet, it fine to keep as is

@Wondertan Wondertan merged commit 9fce763 into pruning May 13, 2025
2 checks passed
@Wondertan Wondertan deleted the store/flush branch May 13, 2025 00:02
Wondertan added a commit that referenced this pull request May 28, 2025
Adds a Sync method which ensures all pending writes are processed. It
blocks until the operation completes or fails.
Also, the method gets used in `DeleteTo`, ensuring deletion always
operates on the latest state.

This is technically a hack for until #241 and #263 come
Wondertan added a commit that referenced this pull request May 29, 2025
Adds a Sync method which ensures all pending writes are processed. It
blocks until the operation completes or fails.
Also, the method gets used in `DeleteTo`, ensuring deletion always
operates on the latest state.

This is technically a hack for until #241 and #263 come
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants