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

bootstrap:correct comments mistake #3182

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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
20 changes: 10 additions & 10 deletions bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ const (
);`
)

// Bootstrap initiates system DB for a store.
// bootstrap initiates system DB for a store.
func bootstrap(s Session) {
b, err := checkBootstrapped(s)
if err != nil {
Expand Down Expand Up @@ -211,7 +211,7 @@ func checkBootstrapped(s Session) (bool, error) {
return isBootstrapped, nil
}

// Get variable value from mysql.tidb table.
// getTiDBVar gets variable value from mysql.tidb table.
// Those variables are used by TiDB server.
func getTiDBVar(s Session, name string) (types.Datum, error) {
sql := fmt.Sprintf(`SELECT VARIABLE_VALUE FROM %s.%s WHERE VARIABLE_NAME="%s"`,
Expand All @@ -232,7 +232,7 @@ func getTiDBVar(s Session, name string) (types.Datum, error) {
return row.Data[0], nil
}

// When the system is boostrapped by low version TiDB server, we should do some upgrade works.
// upgrade function will do some upgrade works, when the system is boostrapped by low version TiDB server
// For example, add new system variables into mysql.global_variables table.
func upgrade(s Session) {
ver, err := getBootstrapVersion(s)
Expand Down Expand Up @@ -283,7 +283,7 @@ func upgrade(s Session) {
return
}

// Update to version 2.
// upgradeToVer2 updates to version 2.
func upgradeToVer2(s Session) {
// Version 2 add two system variable for DistSQL concurrency controlling.
// Insert distsql related system variable.
Expand All @@ -298,15 +298,15 @@ func upgradeToVer2(s Session) {
mustExecute(s, sql)
}

// Update to version 3.
// upgradeToVer3 updates to version 3.
func upgradeToVer3(s Session) {
// Version 3 fix tx_read_only variable value.
sql := fmt.Sprintf("UPDATE %s.%s set variable_value = '0' where variable_name = 'tx_read_only';",
mysql.SystemDB, mysql.GlobalVariablesTable)
mustExecute(s, sql)
}

// Update to version 4.
// upgradeToVer4 updates to version 4.
func upgradeToVer4(s Session) {
sql := CreateStatsMetaTable
mustExecute(s, sql)
Expand Down Expand Up @@ -341,15 +341,15 @@ func upgradeToVer7(s Session) {
mustExecute(s, "UPDATE mysql.user SET Process_priv='Y'")
}

// Update boostrap version variable in mysql.TiDB table.
// updateBootstrapVer updates boostrap version variable in mysql.TiDB table.
func updateBootstrapVer(s Session) {
// Update bootstrap version.
sql := fmt.Sprintf(`INSERT INTO %s.%s VALUES ("%s", "%d", "TiDB bootstrap version.") ON DUPLICATE KEY UPDATE VARIABLE_VALUE="%d"`,
mysql.SystemDB, mysql.TiDBTable, tidbServerVersionVar, currentBootstrapVersion, currentBootstrapVersion)
mustExecute(s, sql)
}

// Gets bootstrap version from mysql.tidb table;
// getBootstrapVersion gets bootstrap version from mysql.tidb table;
func getBootstrapVersion(s Session) (int64, error) {
d, err := getTiDBVar(s, tidbServerVersionVar)
if err != nil {
Expand All @@ -361,7 +361,7 @@ func getBootstrapVersion(s Session) (int64, error) {
return strconv.ParseInt(d.GetString(), 10, 64)
}

// Execute DDL statements in bootstrap stage.
// doDDLWorks executes DDL statements in bootstrap stage.
func doDDLWorks(s Session) {
// Create a test database.
mustExecute(s, "CREATE DATABASE IF NOT EXISTS test")
Expand All @@ -387,7 +387,7 @@ func doDDLWorks(s Session) {
mustExecute(s, CreateStatsBucketsTable)
}

// Execute DML statements in bootstrap stage.
// doDMLWorks executes DML statements in bootstrap stage.
// All the statements run in a single transaction.
func doDMLWorks(s Session) {
mustExecute(s, "BEGIN")
Expand Down
5 changes: 3 additions & 2 deletions bootstrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func globalVarsCount() int64 {
return count
}

// Create a new session on store but only do ddl works.
// bootstrapWithOnlyDDLWork creates a new session on store but only do ddl works.
func (s *testBootstrapSuite) bootstrapWithOnlyDDLWork(store kv.Storage, c *C) {
ss := &session{
store: store,
Expand All @@ -126,6 +126,7 @@ func (s *testBootstrapSuite) bootstrapWithOnlyDDLWork(store kv.Storage, c *C) {
// Leave dml unfinished.
}

// testBootstrapWithError :
// When a session failed in bootstrap process (for example, the session is killed after doDDLWorks()).
// We should make sure that the following session could finish the bootstrap process.
func (s *testBootstrapSuite) testBootstrapWithError(c *C) {
Expand Down Expand Up @@ -163,7 +164,7 @@ func (s *testBootstrapSuite) testBootstrapWithError(c *C) {
c.Assert(err, IsNil)
}

// Test case for upgrade
// TestUpgrade tests case for upgrade
Copy link
Member

Choose a reason for hiding this comment

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

s/upgrade/upgrading/

func (s *testBootstrapSuite) TestUpgrade(c *C) {
defer testleak.AfterTest(c)()
store := newStoreWithBootstrap(c, s.dbName)
Expand Down