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

Many empty memtables are created during MyRocks create index #12179

Open
rockeet opened this issue Dec 24, 2023 · 11 comments
Open

Many empty memtables are created during MyRocks create index #12179

rockeet opened this issue Dec 24, 2023 · 11 comments
Assignees

Comments

@rockeet
Copy link
Contributor

rockeet commented Dec 24, 2023

Expected behavior

New MemTable should not be created if there are empty memtables.

Actual behavior

Many new (empty) MemTables are created during MyRocks create index. This is a benign bug, these empty MemTables are deleted on create index finishes.

Steps to reproduce the behavior

In MyRocks, create many indexes in parallel on existing large table while heavily writing to another table.

It seems these MemTables are created in IngestExternalFiles -> FlushMemTable -> SwitchMemtable.


We found this bug by our webview inspector for DB, gray are empty MemTables:

image

These empty MemTables get deleted:

image

@pranavshenoy
Copy link

@rockeet would like to get started in contributing to rocksdb. Shall I assign this to myself?

@rockeet
Copy link
Contributor Author

rockeet commented Jan 3, 2024

@rockeet would like to get started in contributing to rocksdb. Shall I assign this to myself?

Sure, thanks for your contribution!

@pranavshenoy
Copy link

@rockeet, I was going through the code. One thing I noticed was, isEmpty() check is absent before calling SwitchMemtable() in FlushMemTable() while rest all invocations of SwitchMemtable() has the check .(

s = SwitchMemtable(cfd_stats, &context);
)

Let me know if I am going in the right direction. Thanks!

@pranavshenoy
Copy link

@rockeet Can you tell me how can I reproduce this issue?

@rockeet
Copy link
Contributor Author

rockeet commented Jan 11, 2024

@rockeet Can you tell me how can I reproduce this issue?

In MyRocks, create many indexes in parallel on existing large table while heavily writing to another table.

@rockeet
Copy link
Contributor Author

rockeet commented Jan 29, 2024

PR #12230 did not fix the issue, we applied the PR to our branch, the issue still exists:
image

The gray text is empty MemTable.

@cbi42
Copy link
Member

cbi42 commented Jan 29, 2024

PR #12230 did not fix the issue, we applied the PR to our branch, the issue still exists: image

The gray text is empty MemTable.

Are they still created in SwitchMemtable?

@pranavshenoy
Copy link

@rockeet I am trying to repro within RocksDB by writing a simple program. My intention is to check if Ingestion + write load is calling IngestExternalFiles -> FlushMemTable -> SwitchMemtable and also verify if at any time the memtable size is 0. I am having a hard time trying to reproing the issue. Am I missing something from trying to repro in RocksDB?

I am not familiar with the MyRocks setup and functionalities. It would be great if you could share me your setup or the steps that you followed.
Thanks!

@rockeet
Copy link
Contributor Author

rockeet commented Jan 30, 2024

@rockeet I am trying to repro within RocksDB by writing a simple program. My intention is to check if Ingestion + write load is calling IngestExternalFiles -> FlushMemTable -> SwitchMemtable and also verify if at any time the memtable size is 0. I am having a hard time trying to reproing the issue. Am I missing something from trying to repro in RocksDB?

I am not familiar with the MyRocks setup and functionalities. It would be great if you could share me your setup or the steps that you followed. Thanks!

Your setup missed long lived iterators scanning the db while writting db.

@pranavshenoy
Copy link

Got it. missed this part. let me try adding it.

@pranavshenoy
Copy link

pranavshenoy commented Mar 2, 2024

@rockeet
From my understanding, I thought SwitchMemtable is the only place where new Memtables are created. Since the issue is reproducible even with IsEmpty() check inside SwitchMemtable(), are there other places where Memtable can be created?

I added live iterators as well but couldn't get it to reproduce. The way I am checking is verifying if Memtable size is 0 in SwitchMemtable().. (ingesting multiple files with 1000+ keys and 10k concurrent writes and 1 iterator trying to read).

This is the sample test that I am writing. Would you recommend any changes to the test or the way I am verifying if there are empty memtables?
pranavshenoy/speedb@002c48c

PR #12230 did not fix the issue, we applied the PR to our branch, the issue still exists: image

The gray text is empty MemTable.

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 a pull request may close this issue.

3 participants