Skip to content

Commit

Permalink
set mysqld tmpdir to avoid race condition with multiple mysql instanc…
Browse files Browse the repository at this point in the history
…es on a single host
  • Loading branch information
msolo committed Oct 31, 2012
1 parent e22838f commit 560c3c8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
2 changes: 2 additions & 0 deletions config/mycnf/default.cnf
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,15 @@ skip-name-resolve
# some extra work to skip mangled transactions or fudge the slave start
skip_slave_start
slave_net_timeout = 60
slave_load_tmpdir = {{.SlaveLoadTmpDir}}
slow-query-log
slow-query-log-file = {{.SlowLogPath}}
socket = {{.SocketFile}}
sort_buffer_size = 2M
table_cache = 2048
thread_cache = 200
thread_concurrency = 24
tmpdir = {{.TmpDir}}
tmp_table_size = 32M
transaction-isolation = REPEATABLE-READ
# READ-COMMITTED would be better, but mysql 5.1 disables this with statement based replication
Expand Down
2 changes: 2 additions & 0 deletions go/vt/mysqlctl/mycnf.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ type Mycnf struct {
BinLogIndexPath string
MasterInfoFile string
PidFile string
TmpDir string
SlaveLoadTmpDir string
mycnfMap map[string]string
}

Expand Down
28 changes: 12 additions & 16 deletions go/vt/mysqlctl/mycnf_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

/*
Generate my.cnf files from templates.
*/
// Generate my.cnf files from templates.

package mysqlctl

Expand Down Expand Up @@ -34,13 +32,11 @@ const (
snapshotDir = "snapshot"
)

/*
NewMycnf fills the Mycnf structure with vt root paths and derived values.
This is used to fill out the cnfTemplate values and generate my.cnf.
uid is a unique id for a particular tablet - it must be unique within the
tabletservers deployed within a keyspace, lest there be collisions on disk.
mysqldPort needs to be unique per instance per machine.
*/
// NewMycnf fills the Mycnf structure with vt root paths and derived values.
// This is used to fill out the cnfTemplate values and generate my.cnf.
// uid is a unique id for a particular tablet - it must be unique within the
// tabletservers deployed within a keyspace, lest there be collisions on disk.
// mysqldPort needs to be unique per instance per machine.
func NewMycnf(uid uint32, mysqlPort int, vtRepl VtReplParams) *Mycnf {
cnf := new(Mycnf)
tabletDir := TabletDir(uid)
Expand All @@ -63,6 +59,8 @@ func NewMycnf(uid uint32, mysqlPort int, vtRepl VtReplParams) *Mycnf {
cnf.BinLogIndexPath = cnf.BinLogPath + ".index"
cnf.MasterInfoFile = path.Join(tabletDir, "master.info")
cnf.PidFile = path.Join(tabletDir, "mysql.pid")
cnf.TmpDir = path.Join(tabletDir, "tmp")
cnf.SlaveLoadTmpDir = cnf.TmpDir
return cnf
}

Expand All @@ -87,14 +85,13 @@ func DirectoryList(cnf *Mycnf) []string {
cnf.DataDir,
cnf.InnodbDataHomeDir,
cnf.InnodbLogGroupHomeDir,
cnf.TmpDir,
path.Join(TabletDir(cnf.ServerId), relayLogDir),
path.Join(TabletDir(cnf.ServerId), binLogDir),
}
}

/*
Join cnf files cnfPaths and subsitute in the right values.
*/
// Join cnf files cnfPaths and subsitute in the right values.
func MakeMycnf(cnfFiles []string, mycnf *Mycnf, header string) (string, error) {
myTemplateSource := new(bytes.Buffer)
for _, line := range strings.Split(header, "\n") {
Expand Down Expand Up @@ -122,9 +119,8 @@ func MakeMycnf(cnfFiles []string, mycnf *Mycnf, header string) (string, error) {
return mycnfData.String(), nil
}

/* Create a config for this instance. Search cnfFiles for the appropriate
cnf template files.
*/
// Create a config for this instance. Search cnfFiles for the
// appropriate cnf template files.
func MakeMycnfForMysqld(mysqld *Mysqld, cnfFiles, header string) (string, error) {
// FIXME(msolomon) determine config list from mysqld struct
cnfs := []string{"default", "master", "replica"}
Expand Down

0 comments on commit 560c3c8

Please sign in to comment.