Skip to content

tool: Add db checkpoint command#962

Merged
itsbilal merged 1 commit intocockroachdb:masterfrom
itsbilal:add-checkpoint-cmd
Oct 19, 2020
Merged

tool: Add db checkpoint command#962
itsbilal merged 1 commit intocockroachdb:masterfrom
itsbilal:add-checkpoint-cmd

Conversation

@itsbilal
Copy link
Copy Markdown
Contributor

Adds a command to create a checkpoint of an existing pebble directory,
using the db.Checkpoint method. This needs to be exposed to the command
line for use in some of Cockroach's roachtests.

Also makes a change in Checkpoint() to better handle empty manifests.

@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

Copy link
Copy Markdown
Collaborator

@petermattis petermattis left a comment

Choose a reason for hiding this comment

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

All the other tool commands have tests. This deserves one too.

:lgtm: otherwise.

Reviewable status: 0 of 2 files reviewed, 2 unresolved discussions (waiting on @itsbilal, @jbowens, and @petermattis)


tool/db.go, line 80 at r1 (raw file):

		Long: `
Creates a Pebble checkpoint in the specified destination directory. A checkpoint
is a point-in-time snapshot of DB state. Not safe for concurrent

I believe you'll get an error if you try to run this on an in-use store directory. That is slightly different than not safe for concurrent use, as we're providing guardrails. I'd use the language from the other db commands here.


tool/db.go, line 282 at r1 (raw file):

func (d *dbT) runCheckpoint(cmd *cobra.Command, args []string) {
	db, err := d.openDB(args[0], nonReadOnly{})

Huh? Checkpoint requires a writable DB. I understand why, but I think we can remove that restriction. Let's file an issue about that.

Copy link
Copy Markdown
Contributor Author

@itsbilal itsbilal left a comment

Choose a reason for hiding this comment

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

TFTR! Added a test.

Reviewable status: 0 of 4 files reviewed, 2 unresolved discussions (waiting on @itsbilal, @jbowens, and @petermattis)


tool/db.go, line 80 at r1 (raw file):

Previously, petermattis (Peter Mattis) wrote…

I believe you'll get an error if you try to run this on an in-use store directory. That is slightly different than not safe for concurrent use, as we're providing guardrails. I'd use the language from the other db commands here.

Done.

Copy link
Copy Markdown
Collaborator

@petermattis petermattis left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: 0 of 4 files reviewed, 3 unresolved discussions (waiting on @itsbilal and @jbowens)


checkpoint.go, line 57 at r2 (raw file):

	manifestSize := int64(0)
	if d.mu.versions.manifest != nil {
		manifestSize = d.mu.versions.manifest.Size()

Nit: might be cleaner to have Writer.Size() return 0 if the receiver is nil.


tool/testdata/db_checkpoint, line 6 at r2 (raw file):


db checkpoint
non-existant

Nit: s/existant/existent/g

Adds a command to create a checkpoint of an existing pebble directory,
using the db.Checkpoint method. This needs to be exposed to the command
line for use in some of Cockroach's roachtests.

Also makes a change in Checkpoint() to better handle empty manifests.
Copy link
Copy Markdown
Contributor Author

@itsbilal itsbilal left a comment

Choose a reason for hiding this comment

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

TFTR!

Reviewable status: 0 of 4 files reviewed, 1 unresolved discussion (waiting on @jbowens and @petermattis)


checkpoint.go, line 57 at r2 (raw file):

Previously, petermattis (Peter Mattis) wrote…

Nit: might be cleaner to have Writer.Size() return 0 if the receiver is nil.

Done.


tool/db.go, line 282 at r1 (raw file):

Previously, petermattis (Peter Mattis) wrote…

Huh? Checkpoint requires a writable DB. I understand why, but I think we can remove that restriction. Let's file an issue about that.

Done: #965


tool/testdata/db_checkpoint, line 6 at r2 (raw file):

Previously, petermattis (Peter Mattis) wrote…

Nit: s/existant/existent/g

Done.

Copy link
Copy Markdown
Collaborator

@petermattis petermattis left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 4 files reviewed, all discussions resolved (waiting on @jbowens)

@itsbilal itsbilal merged commit 3ff2442 into cockroachdb:master Oct 19, 2020
@itsbilal itsbilal deleted the add-checkpoint-cmd branch October 19, 2020 14:29
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