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

mysqlctl: add MyRocks dir/files to backups #4549

Merged
merged 2 commits into from
Jan 25, 2019
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
8 changes: 7 additions & 1 deletion go/vt/mysqlctl/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func isDbDir(p string) bool {
return true
}

// Look for at least one .frm file
// Look for at least one database file
fis, err := ioutil.ReadDir(p)
if err != nil {
return false
Expand All @@ -174,6 +174,12 @@ func isDbDir(p string) bool {
return true
}

// the MyRocks engine stores data in RocksDB .sst files
// https://github.com/facebook/rocksdb/wiki/Rocksdb-BlockBasedTable-Format
if strings.HasSuffix(fi.Name(), ".sst") {
return true
}

// .frm files were removed in MySQL 8, so we need to check for two other file types
// https://dev.mysql.com/doc/refman/8.0/en/data-dictionary-file-removal.html
if strings.HasSuffix(fi.Name(), ".ibd") {
Expand Down
18 changes: 17 additions & 1 deletion go/vt/mysqlctl/backup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ func TestFindFilesToBackup(t *testing.T) {
dataDbDir := path.Join(dataDir, "vt_db")
extraDir := path.Join(dataDir, "extra_dir")
outsideDbDir := path.Join(root, "outside_db")
for _, s := range []string{innodbDataDir, innodbLogDir, dataDbDir, extraDir, outsideDbDir} {
rocksdbDir := path.Join(dataDir, ".rocksdb")
sdiOnlyDir := path.Join(dataDir, "sdi_dir")
for _, s := range []string{innodbDataDir, innodbLogDir, dataDbDir, extraDir, outsideDbDir, rocksdbDir, sdiOnlyDir} {
if err := os.MkdirAll(s, os.ModePerm); err != nil {
t.Fatalf("failed to create directory %v: %v", s, err)
}
Expand All @@ -62,6 +64,12 @@ func TestFindFilesToBackup(t *testing.T) {
if err := os.Symlink(outsideDbDir, path.Join(dataDir, "vt_symlink")); err != nil {
t.Fatalf("failed to symlink vt_symlink: %v", err)
}
if err := ioutil.WriteFile(path.Join(rocksdbDir, "000011.sst"), []byte("rocksdb file"), os.ModePerm); err != nil {
t.Fatalf("failed to write file 000011.sst: %v", err)
}
if err := ioutil.WriteFile(path.Join(sdiOnlyDir, "table1.sdi"), []byte("sdi file"), os.ModePerm); err != nil {
t.Fatalf("failed to write file table1.sdi: %v", err)
}

cnf := &Mycnf{
InnodbDataHomeDir: innodbDataDir,
Expand All @@ -76,6 +84,14 @@ func TestFindFilesToBackup(t *testing.T) {
sort.Sort(forTest(result))
t.Logf("findFilesToBackup returned: %v", result)
expected := []FileEntry{
{
Base: "Data",
Name: ".rocksdb/000011.sst",
},
{
Base: "Data",
Name: "sdi_dir/table1.sdi",
},
{
Base: "Data",
Name: "vt_db/db.opt",
Expand Down