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

chore: Adding a mpsc intrusive queue based on Vyukov's design #562

Merged
merged 1 commit into from
Dec 16, 2022

Conversation

romange
Copy link
Collaborator

@romange romange commented Dec 15, 2022

No description provided.

@romange romange requested a review from dranikpg December 15, 2022 19:32
@romange romange marked this pull request as ready for review December 15, 2022 21:44
@romange romange force-pushed the FastLoad branch 5 times, most recently from 82b0f82 to 7c11926 Compare December 16, 2022 14:50
…cts.

1. Add a mpsc intrusive queue based on Vyukov's design.
2. Use it as a object pool when we pull from the queue to reuse the existing object
   and push into it in order to return the object back to the pool.

Signed-off-by: Roman Gershman <[email protected]>
@romange
Copy link
Collaborator Author

romange commented Dec 16, 2022

@dranikpg ptal. Now it's much smaller.

Comment on lines 1646 to +1652
RdbLoader::~RdbLoader() {
while (true) {
Item* item = item_queue_.Pop();
if (item == nullptr)
break;
delete item;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I just thought that you can get a memory leak here but found an even more serious issue:

  • The loader parses items and fills the shard set up to maximum with tasks
  • An error occurs and stop_early_ is set, the loader returns
  • The receiving fiber (for example FullSyncFb in replica) reports the error and exits, destructor runs
  • You shard set has still pending tasks and they are executed, but the loader is already deleted

The solution would be removing the fast path inside Load() so that it waits for the shard set

What is more, its impossible to stop pending tasks on cancellation currently, so even after cleaning the db they'll continue inserting

But this is likely out of scope for this PR

Copy link
Contributor

Choose a reason for hiding this comment

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

This scenario should be catchable with pytests on test_crash_master, probably with higher load

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You are right. Write it down somewhere.

@romange romange merged commit adc89c7 into main Dec 16, 2022
@romange romange deleted the FastLoad branch December 16, 2022 17:36
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

Successfully merging this pull request may close these issues.

2 participants