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

br: fix br debug encode panic #40880

Merged
merged 3 commits into from
Jan 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions br/pkg/utils/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ func makeJSONSchema(schema *backuppb.Schema) (*jsonSchema, error) {

func fromJSONSchema(jSchema *jsonSchema) (*backuppb.Schema, error) {
schema := jSchema.Schema
if schema == nil {
schema = &backuppb.Schema{}
}

var err error
schema.Db, err = json.Marshal(jSchema.DB)
if err != nil {
Expand Down
38 changes: 38 additions & 0 deletions br/pkg/utils/json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,44 @@ var testMetaJSONs = [][]byte{
"is_raw_kv": true,
"br_version": "BR\nRelease Version: v5.0.0-master\nGit Commit Hash: c0d60dae4998cf9ac40f02e5444731c15f0b2522\nGit Branch: HEAD\nGo Version: go1.13.4\nUTC Build Time: 2021-03-25 08:10:08\nRace Enabled: false"
}`),
[]byte(`{
"files": [
{
"sha256": "3ae857ef9b379d498ae913434f1d47c3e90a55f3a4cd9074950bfbd163d5e5fc",
"start_key": "7480000000000000115f720000000000000000",
"end_key": "7480000000000000115f72ffffffffffffffff00",
"name": "1_20_9_36adb8cedcd7af34708edff520499e712e2cfdcb202f5707dc9305a031d55a98_1675066275424_write.sst",
"end_version": 439108573623222300,
"crc64xor": 16261462091570213000,
"total_kvs": 15,
"total_bytes": 1679,
"cf": "write",
"size": 2514,
"cipher_iv": "56MTbxA4CaNILpirKnBxUw=="
}
],
"schemas": [
{
"db": {
"charset": "utf8mb4",
"collate": "utf8mb4_bin",
"db_name": {
"L": "test",
"O": "test"
},
"id": 1,
"policy_ref_info": null,
"state": 5
}
}
],
"ddls": [],
"cluster_id": 7194351714070942000,
"cluster_version": "\"6.1.0\"\n",
"br_version": "BR\nRelease Version: v6.1.0\nGit Commit Hash: 1a89decdb192cbdce6a7b0020d71128bc964d30f\nGit Branch: heads/refs/tags/v6.1.0\nGo Version: go1.18.2\nUTC Build Time: 2022-06-05 05:09:12\nRace Enabled: false",
"end_version": 439108573623222300,
"new_collations_enabled": "True"
}`),
}

func TestEncodeAndDecode(t *testing.T) {
Expand Down