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

etcdutl: Fix snapshot restore memory alloc issue #17277

Merged
merged 2 commits into from
Feb 14, 2024

Conversation

ivanvc
Copy link
Member

@ivanvc ivanvc commented Jan 19, 2024

When running the snapshot command, allow receiving an initial memory map allocation for the database, avoiding future memory allocation issues.

As discussed in the fortnightly etc triage meeting, I'm continuing the work from #16055 by squashing the commits and rebasing @fatihusta's original branch with main.

Fixes #16052.

Please read https://github.com/etcd-io/etcd/blob/main/CONTRIBUTING.md#contribution-flow.

@k8s-ci-robot
Copy link

Hi @ivanvc. Thanks for your PR.

I'm waiting for a etcd-io member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@jmhbnz
Copy link
Member

jmhbnz commented Jan 19, 2024

/ok-to-test

etcdutl/etcdutl/snapshot_command.go Outdated Show resolved Hide resolved
etcdutl/etcdutl/snapshot_command.go Outdated Show resolved Hide resolved
@ivanvc ivanvc force-pushed the fixes-etcdutl-memory-allocation-issue branch 2 times, most recently from 542c737 to 11d8d88 Compare February 11, 2024 06:45
etcdutl/etcdutl/snapshot_command.go Outdated Show resolved Hide resolved
server/storage/backend/backend.go Outdated Show resolved Hide resolved
server/storage/backend/backend.go Outdated Show resolved Hide resolved
@ivanvc ivanvc force-pushed the fixes-etcdutl-memory-allocation-issue branch from 11d8d88 to 362a524 Compare February 12, 2024 21:02
@ivanvc ivanvc requested a review from ahrtr February 12, 2024 21:14
@ivanvc ivanvc force-pushed the fixes-etcdutl-memory-allocation-issue branch from 362a524 to cd9dfaf Compare February 12, 2024 21:20
@@ -151,11 +151,13 @@ type BackendConfig struct {
Hooks Hooks
}

type BackendConfigFunc func(*BackendConfig)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
type BackendConfigFunc func(*BackendConfig)
type BackendConfigOption func(*BackendConfig)

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

}
}

func NewDefaultBackend(lg *zap.Logger, path string, bcfns ...BackendConfigFunc) Backend {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
func NewDefaultBackend(lg *zap.Logger, path string, bcfns ...BackendConfigFunc) Backend {
func NewDefaultBackend(lg *zap.Logger, path string, opts ...BackendConfigOption) Backend {

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@@ -119,6 +119,7 @@ type ServerConfig struct {
CompactionBatchLimit int
CompactionSleepInterval time.Duration
QuotaBackendBytes int64
InitialMmapSize uint64
Copy link
Member

Choose a reason for hiding this comment

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

Do we still need this field?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think so, removed.

Accept a third argument for NewDefaultBackend for overrides to the
BackendConfig.
Add a new function, WithMmapSize, which modifies the backend config to
provide a custom InitiamMmapSize.

Signed-off-by: Ivan Valdes <ivan@vald.es>
@ivanvc ivanvc force-pushed the fixes-etcdutl-memory-allocation-issue branch from cd9dfaf to 4f66aa9 Compare February 13, 2024 21:32
When running the snapshot command, allow receiving an initial memory map
allocation for the database, avoiding future memory allocation issues.

Co-authored-by: Benjamin Wang <benjamin.wang@broadcom.com>
Co-authored-by: Fatih USTA <fatihusta86@gmail.com>
Signed-off-by: Ivan Valdes <ivan@vald.es>
@ivanvc ivanvc force-pushed the fixes-etcdutl-memory-allocation-issue branch from 4f66aa9 to be28833 Compare February 13, 2024 21:36
@ivanvc ivanvc requested a review from ahrtr February 13, 2024 22:33
Copy link
Member

@ahrtr ahrtr left a comment

Choose a reason for hiding this comment

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

lgtm

Nice work! thx

@ahrtr ahrtr merged commit ccc4318 into etcd-io:main Feb 14, 2024
39 checks passed
@ivanvc ivanvc deleted the fixes-etcdutl-memory-allocation-issue branch February 14, 2024 15:31
ivanvc added a commit to ivanvc/etcd that referenced this pull request May 10, 2024
Accept a third argument for NewDefaultBackend for overrides to the
BackendConfig.
Add a new function, WithMmapSize, which modifies the backend config to
provide a custom InitiamMmapSize.

Backports commit: d69adf4 / PR: etcd-io#17277

Signed-off-by: Ivan Valdes <ivan@vald.es>
ivanvc added a commit to ivanvc/etcd that referenced this pull request May 10, 2024
When running the snapshot command, allow receiving an initial memory map
allocation for the database, avoiding future memory allocation issues.

Backports commit: be28833 / PR: etcd-io#17277

Co-authored-by: Fatih USTA <fatihusta86@gmail.com>
Signed-off-by: Ivan Valdes <ivan@vald.es>
aneesh1 pushed a commit to DataDog/etcd that referenced this pull request Sep 25, 2024
When running the snapshot command, allow receiving an initial memory map
allocation for the database, avoiding future memory allocation issues.

Backports commit: be28833 / PR: etcd-io#17277

Co-authored-by: Fatih USTA <fatihusta86@gmail.com>
Signed-off-by: Ivan Valdes <ivan@vald.es>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

etcdutl snapshot restore cannot allocate memory
5 participants