Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

--checksum=false won't work. #223

Merged
merged 17 commits into from
Apr 10, 2020
Merged

Conversation

YuJuncen
Copy link
Collaborator

@YuJuncen YuJuncen commented Apr 3, 2020

What problem does this PR solve?

The flag --checksum won't work properly, when you specify --checksum=false, you will(probably) receive a error message like "failed to checksum."

What is changed and how it works?

I have modified the RunBackup and RunRestore methods so they won't check checksums when disabled.
But for raw kv, I have not done any change yet.
One more thing, maybe use --skip-checksum instead of --checksum=false will be better, but this will break backward compatibility.

Check List

Tests

  • Unit test

  • Integration test
    Code changes

  • Has exported function/method change
    Related changes

  • Need to cherry-pick to the release branch

…flag won't work properly.

Some code of backup and restore ignored the flag (a.k.a. config.Checksum), so when checksum is disabled, we will face failure.
@YuJuncen YuJuncen changed the title backup,restore: work on progress to fix a bug that causes --checksum … --checksum=false won't work. Apr 3, 2020
@3pointer 3pointer added the WIP label Apr 3, 2020
Hillium added 3 commits April 3, 2020 12:14
…isabled.

Some code of backup and restore ignored the flag (a.k.a. config.Checksum), so when checksum is disabled, we will face failure.
…isabled.

Some code of backup and restore ignored the flag (a.k.a. config.Checksum), so when checksum is disabled, we will face failure.
Some of log has been lose. They are in ChecksumMatches now.
pkg/backup/client.go Outdated Show resolved Hide resolved
@YuJuncen
Copy link
Collaborator Author

YuJuncen commented Apr 3, 2020

/run-all-tests

pkg/backup/client.go Show resolved Hide resolved
pkg/task/restore.go Show resolved Hide resolved
pkg/task/backup.go Outdated Show resolved Hide resolved
Hillium added 3 commits April 3, 2020 18:08
@3pointer 3pointer added type/feature-request New feature or request and removed WIP labels Apr 7, 2020
@3pointer
Copy link
Collaborator

3pointer commented Apr 7, 2020

/run-all-tests

1 similar comment
@3pointer
Copy link
Collaborator

3pointer commented Apr 7, 2020

/run-all-tests

@codecov
Copy link

codecov bot commented Apr 7, 2020

Codecov Report

Merging #223 into master will not change coverage by %.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #223   +/-   ##
=======================================
  Coverage   72.65%   72.65%           
=======================================
  Files          48       48           
  Lines        5079     5079           
=======================================
  Hits         3690     3690           
  Misses        949      949           
  Partials      440      440           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a838be7...61bc8da. Read the comment docs.

Copy link
Collaborator

@3pointer 3pointer left a comment

Choose a reason for hiding this comment

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

Rest LGTM

pkg/task/backup.go Outdated Show resolved Hide resolved
pkg/backup/client.go Outdated Show resolved Hide resolved

// CopyMetaFrom copies schema metadata directly from pending backupSchemas, without calculating checksum.
// use this when user skip the checksum generating.
func (bc *Client) CopyMetaFrom(backupSchemas *Schemas) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

why do we need a deep copy here? i.e. why running

bc.backupMeta.Schemas = backupSchemas.schemas

isn't sufficient?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm not sure whether it's OK to just shallow copy(i.e. will the slice be unexpected changed somewhere?), the original version(schemas.Start() -> schemas.finishTableChecksum() -> client.CompleteMeta()) makes a deep copy of the slice, so I just followed it...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

BTW, I think it won't be costly since the number of schema is usually small... and this method is invoked just once per backup...

pkg/restore/client.go Outdated Show resolved Hide resolved
pkg/task/backup.go Outdated Show resolved Hide resolved
Co-Authored-By: kennytm <kennytm@gmail.com>
@3pointer 3pointer added the status/LGT1 LGTM1 label Apr 10, 2020
Copy link
Collaborator

@kennytm kennytm left a comment

Choose a reason for hiding this comment

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

LGTM

@kennytm kennytm added status/LGT2 LGTM2 and removed status/LGT1 LGTM1 labels Apr 10, 2020
@YuJuncen YuJuncen merged commit 593c33d into pingcap:master Apr 10, 2020
3pointer added a commit to 3pointer/br that referenced this pull request Apr 13, 2020
* backup,restore: work on progress to fix a bug that causes --checksum flag won't work properly.

Some code of backup and restore ignored the flag (a.k.a. config.Checksum), so when checksum is disabled, we will face failure.

* backup: backup will report total bytes and kvs when checksums check disabled.

Some code of backup and restore ignored the flag (a.k.a. config.Checksum), so when checksum is disabled, we will face failure.

* backup: backup will report total bytes and kvs when checksums check disabled.

Some code of backup and restore ignored the flag (a.k.a. config.Checksum), so when checksum is disabled, we will face failure.

* backup: add log to ChecksumMatches and new version of FastChecksum.

Some of log has been lose. They are in ChecksumMatches now.

* restore: restore could find non-checksum tables and skip them automatically.

for backup, ChecksumMatches returns error now.

* misc: add document for Table::NoChecksum.

* backup: omit checksum progress bar when user specify `--checksum=false`.

* backup: `CopyMetaFrom` overrides original `client.Schemes` instead of append at its end.

* backup: refactor about checksum logic, fix a bug.

the bug would cause: when multi tables are backup, the metadata contains only one table.

* backup: do some lints.

* backup,restore: do some refactor so that cyclomatic complexity won't be too large.

* misc: don't use underscore on receiver.

* backup: print "quick checksum success" message per table.

...to make br_full_index happy!

* backup: refactor a MinInt pattern.

* backup: Apply suggestions from code review

Co-Authored-By: kennytm <kennytm@gmail.com>

Co-authored-by: 3pointer <luancheng@pingcap.com>
Co-authored-by: kennytm <kennytm@gmail.com>
3pointer added a commit that referenced this pull request Apr 13, 2020
* enable tidb config by default (#230)

* enable tidb config by default

* backup,restore: fix --checksum flag. (#223)

* backup,restore: work on progress to fix a bug that causes --checksum flag won't work properly.

Some code of backup and restore ignored the flag (a.k.a. config.Checksum), so when checksum is disabled, we will face failure.

* backup: backup will report total bytes and kvs when checksums check disabled.

Some code of backup and restore ignored the flag (a.k.a. config.Checksum), so when checksum is disabled, we will face failure.

* backup: backup will report total bytes and kvs when checksums check disabled.

Some code of backup and restore ignored the flag (a.k.a. config.Checksum), so when checksum is disabled, we will face failure.

* backup: add log to ChecksumMatches and new version of FastChecksum.

Some of log has been lose. They are in ChecksumMatches now.

* restore: restore could find non-checksum tables and skip them automatically.

for backup, ChecksumMatches returns error now.

* misc: add document for Table::NoChecksum.

* backup: omit checksum progress bar when user specify `--checksum=false`.

* backup: `CopyMetaFrom` overrides original `client.Schemes` instead of append at its end.

* backup: refactor about checksum logic, fix a bug.

the bug would cause: when multi tables are backup, the metadata contains only one table.

* backup: do some lints.

* backup,restore: do some refactor so that cyclomatic complexity won't be too large.

* misc: don't use underscore on receiver.

* backup: print "quick checksum success" message per table.

...to make br_full_index happy!

* backup: refactor a MinInt pattern.

* backup: Apply suggestions from code review

Co-Authored-By: kennytm <kennytm@gmail.com>

Co-authored-by: 3pointer <luancheng@pingcap.com>
Co-authored-by: kennytm <kennytm@gmail.com>

* fill size in SSTMeta (#233)

* Use table info (#231)

* create with info during incremental restore

* add test

* fix log

* address comment

* fix ci

* address commemnt

* update 3.1 dependency

* remove conf.Experimental.AllowsExpressionIndex

Co-authored-by: 山岚 <36239017+YuJuncen@users.noreply.github.com>
Co-authored-by: kennytm <kennytm@gmail.com>
3pointer added a commit to 3pointer/br that referenced this pull request Apr 26, 2020
* backup,restore: work on progress to fix a bug that causes --checksum flag won't work properly.

Some code of backup and restore ignored the flag (a.k.a. config.Checksum), so when checksum is disabled, we will face failure.

* backup: backup will report total bytes and kvs when checksums check disabled.

Some code of backup and restore ignored the flag (a.k.a. config.Checksum), so when checksum is disabled, we will face failure.

* backup: backup will report total bytes and kvs when checksums check disabled.

Some code of backup and restore ignored the flag (a.k.a. config.Checksum), so when checksum is disabled, we will face failure.

* backup: add log to ChecksumMatches and new version of FastChecksum.

Some of log has been lose. They are in ChecksumMatches now.

* restore: restore could find non-checksum tables and skip them automatically.

for backup, ChecksumMatches returns error now.

* misc: add document for Table::NoChecksum.

* backup: omit checksum progress bar when user specify `--checksum=false`.

* backup: `CopyMetaFrom` overrides original `client.Schemes` instead of append at its end.

* backup: refactor about checksum logic, fix a bug.

the bug would cause: when multi tables are backup, the metadata contains only one table.

* backup: do some lints.

* backup,restore: do some refactor so that cyclomatic complexity won't be too large.

* misc: don't use underscore on receiver.

* backup: print "quick checksum success" message per table.

...to make br_full_index happy!

* backup: refactor a MinInt pattern.

* backup: Apply suggestions from code review

Co-Authored-By: kennytm <kennytm@gmail.com>

Co-authored-by: 3pointer <luancheng@pingcap.com>
Co-authored-by: kennytm <kennytm@gmail.com>
kennytm added a commit that referenced this pull request Apr 26, 2020
* enable tidb config by default (#230)

* enable tidb config by default

* backup,restore: fix --checksum flag. (#223)

* backup,restore: work on progress to fix a bug that causes --checksum flag won't work properly.

Some code of backup and restore ignored the flag (a.k.a. config.Checksum), so when checksum is disabled, we will face failure.

* backup: backup will report total bytes and kvs when checksums check disabled.

Some code of backup and restore ignored the flag (a.k.a. config.Checksum), so when checksum is disabled, we will face failure.

* backup: backup will report total bytes and kvs when checksums check disabled.

Some code of backup and restore ignored the flag (a.k.a. config.Checksum), so when checksum is disabled, we will face failure.

* backup: add log to ChecksumMatches and new version of FastChecksum.

Some of log has been lose. They are in ChecksumMatches now.

* restore: restore could find non-checksum tables and skip them automatically.

for backup, ChecksumMatches returns error now.

* misc: add document for Table::NoChecksum.

* backup: omit checksum progress bar when user specify `--checksum=false`.

* backup: `CopyMetaFrom` overrides original `client.Schemes` instead of append at its end.

* backup: refactor about checksum logic, fix a bug.

the bug would cause: when multi tables are backup, the metadata contains only one table.

* backup: do some lints.

* backup,restore: do some refactor so that cyclomatic complexity won't be too large.

* misc: don't use underscore on receiver.

* backup: print "quick checksum success" message per table.

...to make br_full_index happy!

* backup: refactor a MinInt pattern.

* backup: Apply suggestions from code review

Co-Authored-By: kennytm <kennytm@gmail.com>

Co-authored-by: 3pointer <luancheng@pingcap.com>
Co-authored-by: kennytm <kennytm@gmail.com>

* Use table info (#231)

* create with info during incremental restore

* add test

* fix log

* address comment

* fix ci

* address commemnt

* backup: generate backupmeta when backup empty. (#235)

* cmd: don't use ':' in the default log file name (#236)

* Update build status badge (#239)

* pass sse_kms_key_id to S3 (#243)

* redirect kvproto

Signed-off-by: Yi Wu <yiwu@pingcap.com>

* pass sse_kms_key_id

Signed-off-by: Yi Wu <yiwu@pingcap.com>

* fix hound

Signed-off-by: Yi Wu <yiwu@pingcap.com>

* update kvproto

Signed-off-by: Yi Wu <yiwu@pingcap.com>

* go mod tidy

Signed-off-by: Yi Wu <yiwu@pingcap.com>

Co-authored-by: kennytm <kennytm@gmail.com>

* storage: support placing the S3/GCS options into the storage URL (#246)

* update 4.0 dependency

* go mod tidy

* Update README.md

Co-Authored-By: Neil Shen <overvenus@gmail.com>

Co-authored-by: 山岚 <36239017+YuJuncen@users.noreply.github.com>
Co-authored-by: kennytm <kennytm@gmail.com>
Co-authored-by: Neil Shen <overvenus@gmail.com>
Co-authored-by: yiwu-arbug <yiwu@pingcap.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status/LGT2 LGTM2 type/feature-request New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants