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

leveldb: throttle manifest rebuilding #414

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

qianbin
Copy link
Contributor

@qianbin qianbin commented Jul 26, 2022

It fixes the problem like #413 .

@rjl493456442
Copy link
Contributor

rjl493456442 commented Jul 27, 2022

Hey @qianbin I was checking your fix #409 and I am wondering why it can make difference.

In your fix, it avoids recording some "Added" sstables twice. But in recovery procedure, these duplicated "Added" sstables will not affect the correctness.

// New tables.
for _, r := range r.addedTables {
	scratch := p.getScratch(r.level)
	if scratch.added == nil {
		scratch.added = make(map[int64]atRecord)
	}
	scratch.added[r.num] = r
	if scratch.deleted != nil {
		delete(scratch.deleted, r.num)
	}
}

Could you elaborate how does it fix the issue? And also theoretically we can delete the stale MANIFESTs in runtime to save storage right?

@qianbin
Copy link
Contributor Author

qianbin commented Jul 27, 2022

@rjl493456442 you're right. The manifest file is correctly written without duplicated records.

The problem is about table reference count. Here

v.fillRecord(rec)
if we pass the newly committed rec object, it will be filled with all tables of v, and later when calling setVersion, wrong vDelta is sent, which causes wrong table reference count.

And also theoretically we can delete the stale MANIFESTs in runtime to save storage right?

I think it's a good idea.

@rjl493456442
Copy link
Contributor

@qianbin Ah, right. Thanks for the explanation.

leveldb/session.go Outdated Show resolved Hide resolved
qianbin and others added 2 commits July 28, 2022 13:27
Co-authored-by: Stephen Buttolph <stephen@avalabs.org>
@qianbin
Copy link
Contributor Author

qianbin commented Jul 28, 2022

the last commit checks the limit on db open.

@StephenButtolph it's reverted to use for loop to double the limit.

@StephenButtolph
Copy link

I think there's probably still some edge cases here when the compressed manifest size is close to (but not over) s.maxManifestFileSize. Which may cause the manifest to be written frequently. Although I'm not extremely familiar with how the manifest grows.

Specifically if:

  • The compressed file is just under s.maxManifestFileSize
  • A few operations end up increasing the (now not optimally compressed) manifest file size
  • The file is then re-written, with a new file that whose size is still under s.maxManifestFileSize.
  • Repeat until eventually the compressed manifest is actually larger than s.maxManifestFileSize.

The way I'd have thought to handle this is just doubling s.maxManifestFileSize every time the file gets re-written, regardless of the new size.

@qianbin
Copy link
Contributor Author

qianbin commented Aug 1, 2022

@StephenButtolph Yes, the edge case can happen.

The way I'd have thought to handle this is just doubling s.maxManifestFileSize every time the file gets re-written, regardless of the new size.

This is a solution.

@qianbin qianbin changed the title leveldb: increase the manifest file size limit if the recreated one still over-sized leveldb: throttle manifest rebuilding Aug 1, 2022
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.

3 participants