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

Backup improvements. #2263

Merged
merged 1 commit into from
Nov 21, 2016
Merged

Backup improvements. #2263

merged 1 commit into from
Nov 21, 2016

Conversation

alainjobart
Copy link
Contributor

@alainjobart alainjobart commented Nov 16, 2016

Supports new features:

  • backup files can now go through transforms. Can be used to encrypt / decrypt backups on the fly. The compression is now also optional.
  • if backup fails to write to backupstorage, we still restore the state of the MySQL daemon, instead of leaving it in a broken state.
  • added context to backupstorage API.

@alainjobart
Copy link
Contributor Author

This is ready for review. I will squash everything before merge, but maybe for review individual commits are better.

@michael-berlin you're the primary review, @enisoc this is a FYI, feel free to review.

filterOrTee = tee
}

// Create the gzip compression filter
Copy link
Member

Choose a reason for hiding this comment

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

Now that it's possible to plug in their own filter, users may want the option to disable built-in gzip compression. For example, maybe they want to use the filter hook to use a different compression algorithm, or their filter produces encrypted output that will only get bigger if sent through gzip.

@mberlin-bot
Copy link

Overall the change looks good.

I left several comments around naming the feature and how to enable it via a flag.


Reviewed 1 of 1 files at r1, 1 of 1 files at r2, 2 of 2 files at r3, 3 of 3 files at r4, 3 of 3 files at r5, 8 of 8 files at r6.
Review status: all files reviewed at latest revision, 18 unresolved discussions, some commit checks failed.


bootstrap.sh, line 138 at r6 (raw file):

vthook/backup_filter

Can you please include the word "test" in the filename?

Otherwise it's misleading and people would think that this file is the default backup filter.


go/vt/hook/hook.go, line 145 at r3 (raw file):

exits

typo: exit


go/vt/hook/hook.go, line 164 at r3 (raw file):

a wait() method

Optional: You could also define this as function type.


go/vt/hook/hook.go, line 165 at r3 (raw file):

Wait()

I prefer "cmd.Wait()" to avoid confusing it with the previous "wait()" mentioning.


go/vt/hook/hook.go, line 175 at r3 (raw file):

wc

This probably stands for "WriteCloser".

What about naming this and the writer "in" and "out" to better describe the data flow?


go/vt/hook/hook.go, line 161 at r4 (raw file):

Filter

I think "filter" is the wrong word and we should name it differently (throughout the codebase).

At no point data is getting filtered i.e. no backup data is getting omitted.

Instead, it gets transformed or processed e.g. compressed or encrypted.


go/vt/mysqlctl/backup.go, line 200 at r1 (raw file):

// Take the backup, and either AbortBackup or EndBackup.

Is this new error handling covered by any test? It would be nice to have?


go/vt/mysqlctl/backup.go, line 222 at r1 (raw file):

useable

nit: s/useable/usable/ to be consistent


go/vt/mysqlctl/backup.go, line 327 at r1 (raw file):

findFilesTobackup

nit: Can you please capitalize the "b" in "backup"?


go/vt/mysqlctl/backup.go, line 423 at r4 (raw file):

hwc

Same comment as in the other file.

I think his variable name is not intuitive.

Hook Write Closer?

This is more the transformed output.


go/vt/mysqlctl/backup.go, line 423 at r4 (raw file):

hclose

"close" in the variable name is confusing. I would expect "wait" here instead e.g. "hwait"?


go/vt/mysqlctl/backup.go, line 424 at r4 (raw file):

  h.ExtraEnv = hookExtraEnv
  hwc, hclose, status, err := h.ExecuteAsWriteFilter(tee)
  var filterOrTee io.Writer

Do you need to preserve the original value of tee?

Why not just override it?

filterOrTee is very long. Is it really relevant if the output is transformed/processed or not?


go/vt/mysqlctl/backup.go, line 62 at r5 (raw file):

  // and when decoding a backup, it is read from the manifest,
  // and sent to the filter hook again.
  backupStorageFilter = flag.String("backup_storage_filter", "", "if set, the backup_filter hook is used for processing backup files, with this parameter as 'filter'.")

I'm not in favor of this flag.

Instead, I think we should provide a flag where the user can specify the backup transformation/processing hook which should be used.

If somebody wants to run Vitess with two different hooks (like you do in this test), they would do so at the hook level. We don't need the "--filter" flag in that case.

Note that in the future we could provide multiple default implementations for transformation e.g. one for gzip. Users could then select which one they want to use by specifying the flag.

When we have such a hook flag, you could also the bogus value "-backup_storage_filter=enabled" in the test below.


go/vt/mysqlctl/backup.go, line 438 at r5 (raw file):

backup_filter

I would prefer if we don't hardcode this and instead provide a flag for that.


go/vt/mysqlctl/backupstorage/interface.go, line 73 at r6 (raw file):

remembered

"stored" ?


test/vthook-backup_filter, line 13 at r4 (raw file):

# Any error is displayed to stderr, and triggers an 'exit 1'.

while [[ $# -gt 1 ]]

Please move "do" on the same line:

while [[ $# -gt 1 ]]; do


test/vthook-backup_filter, line 15 at r4 (raw file):

while [[ $# -gt 1 ]]
do
key="$1"

Please indent the while block by two spaces.


Comments from Reviewable

@alainjobart-bot
Copy link

Review status: 0 of 13 files reviewed at latest revision, 18 unresolved discussions.


bootstrap.sh, line 138 at r6 (raw file):

Previously, mberlin-bot (Michael Berlin) wrote…

vthook/backup_filter

Can you please include the word "test" in the filename?

Otherwise it's misleading and people would think that this file is the default backup filter.

Done.

go/vt/hook/hook.go, line 145 at r3 (raw file):

Previously, mberlin-bot (Michael Berlin) wrote…

exits

typo: exit

Done.

go/vt/hook/hook.go, line 164 at r3 (raw file):

Previously, mberlin-bot (Michael Berlin) wrote…

a wait() method

Optional: You could also define this as function type.

Done.

go/vt/hook/hook.go, line 165 at r3 (raw file):

Previously, mberlin-bot (Michael Berlin) wrote…

Wait()

I prefer "cmd.Wait()" to avoid confusing it with the previous "wait()" mentioning.

Done.

go/vt/hook/hook.go, line 175 at r3 (raw file):

Previously, mberlin-bot (Michael Berlin) wrote…

wc

This probably stands for "WriteCloser".

What about naming this and the writer "in" and "out" to better describe the data flow?

Done.

go/vt/hook/hook.go, line 161 at r4 (raw file):

Previously, mberlin-bot (Michael Berlin) wrote…

Filter

I think "filter" is the wrong word and we should name it differently (throughout the codebase).

At no point data is getting filtered i.e. no backup data is getting omitted.

Instead, it gets transformed or processed e.g. compressed or encrypted.

I guess Pipe would be the unix term. Will use that in hook. I think pipe might be confusing in the backup case, I'll see there what I should use, probably transform.

go/vt/mysqlctl/backup.go, line 200 at r1 (raw file):

Previously, mberlin-bot (Michael Berlin) wrote…

// Take the backup, and either AbortBackup or EndBackup.

Is this new error handling covered by any test? It would be nice to have?

it was the same before, but the code was a bit more confusing. I'll make sure to test the number of backups though after a failure.

go/vt/mysqlctl/backup.go, line 222 at r1 (raw file):

Previously, mberlin-bot (Michael Berlin) wrote…

useable

nit: s/useable/usable/ to be consistent

Done.

go/vt/mysqlctl/backup.go, line 327 at r1 (raw file):

Previously, mberlin-bot (Michael Berlin) wrote…

findFilesTobackup

nit: Can you please capitalize the "b" in "backup"?

Done.

go/vt/mysqlctl/backup.go, line 423 at r4 (raw file):

Previously, mberlin-bot (Michael Berlin) wrote…

hwc

Same comment as in the other file.

I think his variable name is not intuitive.

Hook Write Closer?

This is more the transformed output.

Renamed to pipe.

go/vt/mysqlctl/backup.go, line 423 at r4 (raw file):

Previously, mberlin-bot (Michael Berlin) wrote…

hclose

"close" in the variable name is confusing. I would expect "wait" here instead e.g. "hwait"?

Done.

go/vt/mysqlctl/backup.go, line 424 at r4 (raw file):

Previously, mberlin-bot (Michael Berlin) wrote…

Do you need to preserve the original value of tee?

Why not just override it?

filterOrTee is very long. Is it really relevant if the output is transformed/processed or not?

Changed both the read and write side, simpler.

go/vt/mysqlctl/backup.go, line 62 at r5 (raw file):

Previously, mberlin-bot (Michael Berlin) wrote…

I'm not in favor of this flag.

Instead, I think we should provide a flag where the user can specify the backup transformation/processing hook which should be used.

If somebody wants to run Vitess with two different hooks (like you do in this test), they would do so at the hook level. We don't need the "--filter" flag in that case.

Note that in the future we could provide multiple default implementations for transformation e.g. one for gzip. Users could then select which one they want to use by specifying the flag.

When we have such a hook flag, you could also the bogus value "-backup_storage_filter=enabled" in the test below.

That makes more sense. Fixing it.

go/vt/mysqlctl/backup.go, line 438 at r5 (raw file):

Previously, mberlin-bot (Michael Berlin) wrote…

backup_filter

I would prefer if we don't hardcode this and instead provide a flag for that.

Done.

go/vt/mysqlctl/backupstorage/interface.go, line 73 at r6 (raw file):

Previously, mberlin-bot (Michael Berlin) wrote…

remembered

"stored" ?

done.

test/vthook-backup_filter, line 13 at r4 (raw file):

Previously, mberlin-bot (Michael Berlin) wrote…

Please move "do" on the same line:

while [[ $# -gt 1 ]]; do

Done.

test/vthook-backup_filter, line 15 at r4 (raw file):

Previously, mberlin-bot (Michael Berlin) wrote…

Please indent the while block by two spaces.

Done.

Comments from Reviewable

@alainjobart-bot
Copy link

Review status: 0 of 14 files reviewed at latest revision, 18 unresolved discussions.


go/vt/mysqlctl/backup.go, line 449 at r6 (raw file):

Previously, enisoc (Anthony Yeh) wrote…

Now that it's possible to plug in their own filter, users may want the option to disable built-in gzip compression. For example, maybe they want to use the filter hook to use a different compression algorithm, or their filter produces encrypted output that will only get bigger if sent through gzip.

Good idea, done in new commit.

Comments from Reviewable

@alainjobart
Copy link
Contributor Author

OK all comments addressed, much better.

@michael-berlin @enisoc ready for review.

@mberlin-bot
Copy link

mberlin-bot commented Nov 19, 2016

:lgtm:

Thank you for addressing all comments.


Reviewed 13 of 14 files at r7, 1 of 1 files at r8, 2 of 2 files at r9, 3 of 4 files at r10, 3 of 4 files at r11, 8 of 8 files at r12, 8 of 8 files at r13, 3 of 3 files at r14.
Review status: all files reviewed at latest revision, 6 unresolved discussions.


Comments from Reviewable

Approved with PullApprove

- better backup error handling:
When the backup fails, we now try to restore mysqld state anyway. That
way the tablet becomes usable again.
- Refactoring backup / restore code:
So individual file backup / restore are each in their own function, instead of
being two blocks deep.
- Adding support for piping data through hooks.
Also streamlining the hook creation, which changes the HookResult
details a bit. All errors now are in Stderr.
- Now supporting backup filters (optional, command-line driven).
And adding one to backup test.
- Add flag to disable backup compression (in case filter compresses).
And add a test to make sure no backup is left-over upon
backup failure.
- Adding context to backupstorage API.
The only current user is the GCS one, but it's way cleaner.
@alainjobart alainjobart merged commit 6fc3b48 into vitessio:master Nov 21, 2016
@alainjobart alainjobart deleted the backup branch November 21, 2016 16:06
frouioui pushed a commit to planetscale/vitess that referenced this pull request Nov 21, 2023
…ardized viper framework for vitess configuration parameters (vitessio#2407)

* backport of 2263

* resolve conflicts

Signed-off-by: Andrew Mason <andrew@planetscale.com>

---------

Signed-off-by: Andrew Mason <andrew@planetscale.com>
Co-authored-by: Andrew Mason <andrew@planetscale.com>
frouioui pushed a commit to planetscale/vitess that referenced this pull request Mar 26, 2024
…tess configuration parameters (vitessio#2263)

* cherry pick of 11456

* resolve go.mod

Signed-off-by: Andrew Mason <andrew@planetscale.com>

* resolve flagdata conflicts

Signed-off-by: Andrew Mason <andrew@planetscale.com>

---------

Signed-off-by: Andrew Mason <andrew@planetscale.com>
Co-authored-by: Andrew Mason <andrew@planetscale.com>
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.

6 participants