repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
vitessio/vitess | go/bytes2/buffer.go | Write | func (buf *Buffer) Write(b []byte) (int, error) {
buf.bytes = append(buf.bytes, b...)
return len(b), nil
} | go | func (buf *Buffer) Write(b []byte) (int, error) {
buf.bytes = append(buf.bytes, b...)
return len(b), nil
} | [
"func",
"(",
"buf",
"*",
"Buffer",
")",
"Write",
"(",
"b",
"[",
"]",
"byte",
")",
"(",
"int",
",",
"error",
")",
"{",
"buf",
".",
"bytes",
"=",
"append",
"(",
"buf",
".",
"bytes",
",",
"b",
"...",
")",
"\n",
"return",
"len",
"(",
"b",
")",
... | // Write is equivalent to bytes.Buffer.Write. | [
"Write",
"is",
"equivalent",
"to",
"bytes",
".",
"Buffer",
".",
"Write",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/bytes2/buffer.go#L35-L38 | train |
vitessio/vitess | go/bytes2/buffer.go | WriteString | func (buf *Buffer) WriteString(s string) (int, error) {
buf.bytes = append(buf.bytes, s...)
return len(s), nil
} | go | func (buf *Buffer) WriteString(s string) (int, error) {
buf.bytes = append(buf.bytes, s...)
return len(s), nil
} | [
"func",
"(",
"buf",
"*",
"Buffer",
")",
"WriteString",
"(",
"s",
"string",
")",
"(",
"int",
",",
"error",
")",
"{",
"buf",
".",
"bytes",
"=",
"append",
"(",
"buf",
".",
"bytes",
",",
"s",
"...",
")",
"\n",
"return",
"len",
"(",
"s",
")",
",",
... | // WriteString is equivalent to bytes.Buffer.WriteString. | [
"WriteString",
"is",
"equivalent",
"to",
"bytes",
".",
"Buffer",
".",
"WriteString",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/bytes2/buffer.go#L41-L44 | train |
vitessio/vitess | go/bytes2/buffer.go | WriteByte | func (buf *Buffer) WriteByte(b byte) error {
buf.bytes = append(buf.bytes, b)
return nil
} | go | func (buf *Buffer) WriteByte(b byte) error {
buf.bytes = append(buf.bytes, b)
return nil
} | [
"func",
"(",
"buf",
"*",
"Buffer",
")",
"WriteByte",
"(",
"b",
"byte",
")",
"error",
"{",
"buf",
".",
"bytes",
"=",
"append",
"(",
"buf",
".",
"bytes",
",",
"b",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // WriteByte is equivalent to bytes.Buffer.WriteByte. | [
"WriteByte",
"is",
"equivalent",
"to",
"bytes",
".",
"Buffer",
".",
"WriteByte",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/bytes2/buffer.go#L47-L50 | train |
vitessio/vitess | go/vt/vterrors/vterrors.go | NewWithoutCode | func NewWithoutCode(message string) error {
return &fundamental{
msg: message,
code: vtrpcpb.Code_UNKNOWN,
stack: callers(),
}
} | go | func NewWithoutCode(message string) error {
return &fundamental{
msg: message,
code: vtrpcpb.Code_UNKNOWN,
stack: callers(),
}
} | [
"func",
"NewWithoutCode",
"(",
"message",
"string",
")",
"error",
"{",
"return",
"&",
"fundamental",
"{",
"msg",
":",
"message",
",",
"code",
":",
"vtrpcpb",
".",
"Code_UNKNOWN",
",",
"stack",
":",
"callers",
"(",
")",
",",
"}",
"\n",
"}"
] | // NewWithoutCode returns an error when no applicable error code is available
// It will record the stack trace when creating the error | [
"NewWithoutCode",
"returns",
"an",
"error",
"when",
"no",
"applicable",
"error",
"code",
"is",
"available",
"It",
"will",
"record",
"the",
"stack",
"trace",
"when",
"creating",
"the",
"error"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vterrors/vterrors.go#L101-L107 | train |
vitessio/vitess | go/vt/vterrors/vterrors.go | Code | func Code(err error) vtrpcpb.Code {
if err == nil {
return vtrpcpb.Code_OK
}
if err, ok := err.(*fundamental); ok {
return err.code
}
cause := Cause(err)
if cause != err && cause != nil {
// If we did not find an error code at the outer level, let's find the cause and check it's code
return Code(cause)
... | go | func Code(err error) vtrpcpb.Code {
if err == nil {
return vtrpcpb.Code_OK
}
if err, ok := err.(*fundamental); ok {
return err.code
}
cause := Cause(err)
if cause != err && cause != nil {
// If we did not find an error code at the outer level, let's find the cause and check it's code
return Code(cause)
... | [
"func",
"Code",
"(",
"err",
"error",
")",
"vtrpcpb",
".",
"Code",
"{",
"if",
"err",
"==",
"nil",
"{",
"return",
"vtrpcpb",
".",
"Code_OK",
"\n",
"}",
"\n",
"if",
"err",
",",
"ok",
":=",
"err",
".",
"(",
"*",
"fundamental",
")",
";",
"ok",
"{",
... | // Code returns the error code if it's a vtError.
// If err is nil, it returns ok. | [
"Code",
"returns",
"the",
"error",
"code",
"if",
"it",
"s",
"a",
"vtError",
".",
"If",
"err",
"is",
"nil",
"it",
"returns",
"ok",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vterrors/vterrors.go#L147-L169 | train |
vitessio/vitess | go/vt/vtgate/engine/pullout_subquery.go | Execute | func (ps *PulloutSubquery) Execute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error) {
combinedVars, err := ps.execSubquery(vcursor, bindVars)
if err != nil {
return nil, err
}
return ps.Underlying.Execute(vcursor, combinedVars, wantfields)
} | go | func (ps *PulloutSubquery) Execute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error) {
combinedVars, err := ps.execSubquery(vcursor, bindVars)
if err != nil {
return nil, err
}
return ps.Underlying.Execute(vcursor, combinedVars, wantfields)
} | [
"func",
"(",
"ps",
"*",
"PulloutSubquery",
")",
"Execute",
"(",
"vcursor",
"VCursor",
",",
"bindVars",
"map",
"[",
"string",
"]",
"*",
"querypb",
".",
"BindVariable",
",",
"wantfields",
"bool",
")",
"(",
"*",
"sqltypes",
".",
"Result",
",",
"error",
")",... | // Execute satisfies the Primitive interface. | [
"Execute",
"satisfies",
"the",
"Primitive",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/engine/pullout_subquery.go#L47-L53 | train |
vitessio/vitess | go/vt/schemamanager/schemaswap/schema_swap.go | Init | func (*SwapWorkflowFactory) Init(_ *workflow.Manager, workflowProto *workflowpb.Workflow, args []string) error {
subFlags := flag.NewFlagSet(workflowFactoryName, flag.ContinueOnError)
keyspace := subFlags.String("keyspace", "", "Name of a keyspace to perform schema swap on")
sql := subFlags.String("sql", "", "Query... | go | func (*SwapWorkflowFactory) Init(_ *workflow.Manager, workflowProto *workflowpb.Workflow, args []string) error {
subFlags := flag.NewFlagSet(workflowFactoryName, flag.ContinueOnError)
keyspace := subFlags.String("keyspace", "", "Name of a keyspace to perform schema swap on")
sql := subFlags.String("sql", "", "Query... | [
"func",
"(",
"*",
"SwapWorkflowFactory",
")",
"Init",
"(",
"_",
"*",
"workflow",
".",
"Manager",
",",
"workflowProto",
"*",
"workflowpb",
".",
"Workflow",
",",
"args",
"[",
"]",
"string",
")",
"error",
"{",
"subFlags",
":=",
"flag",
".",
"NewFlagSet",
"(... | // Init is a part of workflow.Factory interface. It initializes a Workflow protobuf object. | [
"Init",
"is",
"a",
"part",
"of",
"workflow",
".",
"Factory",
"interface",
".",
"It",
"initializes",
"a",
"Workflow",
"protobuf",
"object",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/schemamanager/schemaswap/schema_swap.go#L182-L205 | train |
vitessio/vitess | go/vt/schemamanager/schemaswap/schema_swap.go | Instantiate | func (*SwapWorkflowFactory) Instantiate(_ *workflow.Manager, workflowProto *workflowpb.Workflow, rootNode *workflow.Node) (workflow.Workflow, error) {
data := &swapWorkflowData{}
if err := json.Unmarshal(workflowProto.Data, data); err != nil {
return nil, err
}
rootNode.Message = fmt.Sprintf("Schema swap is execu... | go | func (*SwapWorkflowFactory) Instantiate(_ *workflow.Manager, workflowProto *workflowpb.Workflow, rootNode *workflow.Node) (workflow.Workflow, error) {
data := &swapWorkflowData{}
if err := json.Unmarshal(workflowProto.Data, data); err != nil {
return nil, err
}
rootNode.Message = fmt.Sprintf("Schema swap is execu... | [
"func",
"(",
"*",
"SwapWorkflowFactory",
")",
"Instantiate",
"(",
"_",
"*",
"workflow",
".",
"Manager",
",",
"workflowProto",
"*",
"workflowpb",
".",
"Workflow",
",",
"rootNode",
"*",
"workflow",
".",
"Node",
")",
"(",
"workflow",
".",
"Workflow",
",",
"er... | // Instantiate is a part of workflow.Factory interface. It instantiates workflow.Workflow object from
// workflowpb.Workflow protobuf object. | [
"Instantiate",
"is",
"a",
"part",
"of",
"workflow",
".",
"Factory",
"interface",
".",
"It",
"instantiates",
"workflow",
".",
"Workflow",
"object",
"from",
"workflowpb",
".",
"Workflow",
"protobuf",
"object",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/schemamanager/schemaswap/schema_swap.go#L209-L222 | train |
vitessio/vitess | go/vt/schemamanager/schemaswap/schema_swap.go | Run | func (schemaSwap *Swap) Run(ctx context.Context, manager *workflow.Manager, workflowInfo *topo.WorkflowInfo) error {
schemaSwap.ctx = ctx
schemaSwap.workflowManager = manager
schemaSwap.topoServer = manager.TopoServer()
schemaSwap.tabletClient = tmclient.NewTabletManagerClient()
log.Infof("Starting schema swap on... | go | func (schemaSwap *Swap) Run(ctx context.Context, manager *workflow.Manager, workflowInfo *topo.WorkflowInfo) error {
schemaSwap.ctx = ctx
schemaSwap.workflowManager = manager
schemaSwap.topoServer = manager.TopoServer()
schemaSwap.tabletClient = tmclient.NewTabletManagerClient()
log.Infof("Starting schema swap on... | [
"func",
"(",
"schemaSwap",
"*",
"Swap",
")",
"Run",
"(",
"ctx",
"context",
".",
"Context",
",",
"manager",
"*",
"workflow",
".",
"Manager",
",",
"workflowInfo",
"*",
"topo",
".",
"WorkflowInfo",
")",
"error",
"{",
"schemaSwap",
".",
"ctx",
"=",
"ctx",
... | // Run is a part of workflow.Workflow interface. This is the main entrance point of the schema swap workflow. | [
"Run",
"is",
"a",
"part",
"of",
"workflow",
".",
"Workflow",
"interface",
".",
"This",
"is",
"the",
"main",
"entrance",
"point",
"of",
"the",
"schema",
"swap",
"workflow",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/schemamanager/schemaswap/schema_swap.go#L225-L269 | train |
vitessio/vitess | go/vt/schemamanager/schemaswap/schema_swap.go | closeRetryChannel | func (schemaSwap *Swap) closeRetryChannel() {
schemaSwap.retryMutex.Lock()
defer schemaSwap.retryMutex.Unlock()
if len(schemaSwap.rootUINode.Actions) != 0 {
schemaSwap.rootUINode.Actions = []*workflow.Action{}
close(schemaSwap.retryChannel)
}
} | go | func (schemaSwap *Swap) closeRetryChannel() {
schemaSwap.retryMutex.Lock()
defer schemaSwap.retryMutex.Unlock()
if len(schemaSwap.rootUINode.Actions) != 0 {
schemaSwap.rootUINode.Actions = []*workflow.Action{}
close(schemaSwap.retryChannel)
}
} | [
"func",
"(",
"schemaSwap",
"*",
"Swap",
")",
"closeRetryChannel",
"(",
")",
"{",
"schemaSwap",
".",
"retryMutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"schemaSwap",
".",
"retryMutex",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"len",
"(",
"schemaSwap",
".",... | // closeRetryChannel closes the retryChannel and empties the Actions list in the rootUINode
// to indicate that the channel is closed and Retry action is not waited for anymore. | [
"closeRetryChannel",
"closes",
"the",
"retryChannel",
"and",
"empties",
"the",
"Actions",
"list",
"in",
"the",
"rootUINode",
"to",
"indicate",
"that",
"the",
"channel",
"is",
"closed",
"and",
"Retry",
"action",
"is",
"not",
"waited",
"for",
"anymore",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/schemamanager/schemaswap/schema_swap.go#L273-L281 | train |
vitessio/vitess | go/vt/schemamanager/schemaswap/schema_swap.go | Action | func (schemaSwap *Swap) Action(ctx context.Context, path, name string) error {
if name != "Retry" {
return fmt.Errorf("unknown action on schema swap: %v", name)
}
schemaSwap.closeRetryChannel()
schemaSwap.rootUINode.BroadcastChanges(false /* updateChildren */)
return nil
} | go | func (schemaSwap *Swap) Action(ctx context.Context, path, name string) error {
if name != "Retry" {
return fmt.Errorf("unknown action on schema swap: %v", name)
}
schemaSwap.closeRetryChannel()
schemaSwap.rootUINode.BroadcastChanges(false /* updateChildren */)
return nil
} | [
"func",
"(",
"schemaSwap",
"*",
"Swap",
")",
"Action",
"(",
"ctx",
"context",
".",
"Context",
",",
"path",
",",
"name",
"string",
")",
"error",
"{",
"if",
"name",
"!=",
"\"",
"\"",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"name",
... | // Action is a part of workflow.ActionListener interface. It registers "Retry" actions
// from UI. | [
"Action",
"is",
"a",
"part",
"of",
"workflow",
".",
"ActionListener",
"interface",
".",
"It",
"registers",
"Retry",
"actions",
"from",
"UI",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/schemamanager/schemaswap/schema_swap.go#L285-L292 | train |
vitessio/vitess | go/vt/schemamanager/schemaswap/schema_swap.go | executeSwap | func (schemaSwap *Swap) executeSwap() error {
schemaSwap.setUIMessage("Initializing schema swap")
if len(schemaSwap.allShards) == 0 {
if err := schemaSwap.createShardObjects(); err != nil {
return err
}
schemaSwap.rootUINode.BroadcastChanges(true /* updateChildren */)
}
if err := schemaSwap.initializeSwap(... | go | func (schemaSwap *Swap) executeSwap() error {
schemaSwap.setUIMessage("Initializing schema swap")
if len(schemaSwap.allShards) == 0 {
if err := schemaSwap.createShardObjects(); err != nil {
return err
}
schemaSwap.rootUINode.BroadcastChanges(true /* updateChildren */)
}
if err := schemaSwap.initializeSwap(... | [
"func",
"(",
"schemaSwap",
"*",
"Swap",
")",
"executeSwap",
"(",
")",
"error",
"{",
"schemaSwap",
".",
"setUIMessage",
"(",
"\"",
"\"",
")",
"\n",
"if",
"len",
"(",
"schemaSwap",
".",
"allShards",
")",
"==",
"0",
"{",
"if",
"err",
":=",
"schemaSwap",
... | // executeSwap is the main entry point of the schema swap process. It drives the process from start
// to finish, including possible restart of already started process. In the latter case the
// method should be just called again and it will pick up already started process. The only
// input argument is the SQL stateme... | [
"executeSwap",
"is",
"the",
"main",
"entry",
"point",
"of",
"the",
"schema",
"swap",
"process",
".",
"It",
"drives",
"the",
"process",
"from",
"start",
"to",
"finish",
"including",
"possible",
"restart",
"of",
"already",
"started",
"process",
".",
"In",
"the... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/schemamanager/schemaswap/schema_swap.go#L299-L377 | train |
vitessio/vitess | go/vt/schemamanager/schemaswap/schema_swap.go | setUIMessage | func (schemaSwap *Swap) setUIMessage(message string) {
log.Infof("Schema swap on keyspace %v: %v", schemaSwap.keyspace, message)
schemaSwap.uiLogger.Infof(message)
schemaSwap.rootUINode.Log = schemaSwap.uiLogger.String()
schemaSwap.rootUINode.Message = message
schemaSwap.rootUINode.BroadcastChanges(false /* update... | go | func (schemaSwap *Swap) setUIMessage(message string) {
log.Infof("Schema swap on keyspace %v: %v", schemaSwap.keyspace, message)
schemaSwap.uiLogger.Infof(message)
schemaSwap.rootUINode.Log = schemaSwap.uiLogger.String()
schemaSwap.rootUINode.Message = message
schemaSwap.rootUINode.BroadcastChanges(false /* update... | [
"func",
"(",
"schemaSwap",
"*",
"Swap",
")",
"setUIMessage",
"(",
"message",
"string",
")",
"{",
"log",
".",
"Infof",
"(",
"\"",
"\"",
",",
"schemaSwap",
".",
"keyspace",
",",
"message",
")",
"\n",
"schemaSwap",
".",
"uiLogger",
".",
"Infof",
"(",
"mes... | // setUIMessage updates message on the schema swap's root UI node and broadcasts changes. | [
"setUIMessage",
"updates",
"message",
"on",
"the",
"schema",
"swap",
"s",
"root",
"UI",
"node",
"and",
"broadcasts",
"changes",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/schemamanager/schemaswap/schema_swap.go#L380-L386 | train |
vitessio/vitess | go/vt/schemamanager/schemaswap/schema_swap.go | runOnAllShards | func (schemaSwap *Swap) runOnAllShards(shardFunc func(shard *shardSchemaSwap) error) error {
var errorRecorder concurrency.AllErrorRecorder
var waitGroup sync.WaitGroup
for _, shardSwap := range schemaSwap.allShards {
waitGroup.Add(1)
go func(shard *shardSchemaSwap) {
defer waitGroup.Done()
errorRecorder.R... | go | func (schemaSwap *Swap) runOnAllShards(shardFunc func(shard *shardSchemaSwap) error) error {
var errorRecorder concurrency.AllErrorRecorder
var waitGroup sync.WaitGroup
for _, shardSwap := range schemaSwap.allShards {
waitGroup.Add(1)
go func(shard *shardSchemaSwap) {
defer waitGroup.Done()
errorRecorder.R... | [
"func",
"(",
"schemaSwap",
"*",
"Swap",
")",
"runOnAllShards",
"(",
"shardFunc",
"func",
"(",
"shard",
"*",
"shardSchemaSwap",
")",
"error",
")",
"error",
"{",
"var",
"errorRecorder",
"concurrency",
".",
"AllErrorRecorder",
"\n",
"var",
"waitGroup",
"sync",
".... | // runOnAllShards is a helper method that executes the passed function for all shards in parallel.
// The method returns no error if the function succeeds on all shards. If on any of the shards
// the function fails then the method returns error. If several shards return error then only one
// of them is returned. | [
"runOnAllShards",
"is",
"a",
"helper",
"method",
"that",
"executes",
"the",
"passed",
"function",
"for",
"all",
"shards",
"in",
"parallel",
".",
"The",
"method",
"returns",
"no",
"error",
"if",
"the",
"function",
"succeeds",
"on",
"all",
"shards",
".",
"If",... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/schemamanager/schemaswap/schema_swap.go#L392-L404 | train |
vitessio/vitess | go/vt/schemamanager/schemaswap/schema_swap.go | createShardObjects | func (schemaSwap *Swap) createShardObjects() error {
shardsList, err := schemaSwap.topoServer.FindAllShardsInKeyspace(schemaSwap.ctx, schemaSwap.keyspace)
if err != nil {
return err
}
for _, shardInfo := range shardsList {
shardSwap := &shardSchemaSwap{
parent: schemaSwap,
shardName: shardInfo.ShardNam... | go | func (schemaSwap *Swap) createShardObjects() error {
shardsList, err := schemaSwap.topoServer.FindAllShardsInKeyspace(schemaSwap.ctx, schemaSwap.keyspace)
if err != nil {
return err
}
for _, shardInfo := range shardsList {
shardSwap := &shardSchemaSwap{
parent: schemaSwap,
shardName: shardInfo.ShardNam... | [
"func",
"(",
"schemaSwap",
"*",
"Swap",
")",
"createShardObjects",
"(",
")",
"error",
"{",
"shardsList",
",",
"err",
":=",
"schemaSwap",
".",
"topoServer",
".",
"FindAllShardsInKeyspace",
"(",
"schemaSwap",
".",
"ctx",
",",
"schemaSwap",
".",
"keyspace",
")",
... | // createShardObjects creates per-shard swap objects for all shards in the keyspace. | [
"createShardObjects",
"creates",
"per",
"-",
"shard",
"swap",
"objects",
"for",
"all",
"shards",
"in",
"the",
"keyspace",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/schemamanager/schemaswap/schema_swap.go#L407-L450 | train |
vitessio/vitess | go/vt/schemamanager/schemaswap/schema_swap.go | stopAllHealthWatchers | func (schemaSwap *Swap) stopAllHealthWatchers() {
schemaSwap.runOnAllShards(
func(shard *shardSchemaSwap) error {
shard.stopHealthWatchers()
return nil
})
} | go | func (schemaSwap *Swap) stopAllHealthWatchers() {
schemaSwap.runOnAllShards(
func(shard *shardSchemaSwap) error {
shard.stopHealthWatchers()
return nil
})
} | [
"func",
"(",
"schemaSwap",
"*",
"Swap",
")",
"stopAllHealthWatchers",
"(",
")",
"{",
"schemaSwap",
".",
"runOnAllShards",
"(",
"func",
"(",
"shard",
"*",
"shardSchemaSwap",
")",
"error",
"{",
"shard",
".",
"stopHealthWatchers",
"(",
")",
"\n",
"return",
"nil... | // stopAllHealthWatchers stops watching for health on each shard. It's separated into a separate
// function mainly to make "defer" statement where it's used simpler. | [
"stopAllHealthWatchers",
"stops",
"watching",
"for",
"health",
"on",
"each",
"shard",
".",
"It",
"s",
"separated",
"into",
"a",
"separate",
"function",
"mainly",
"to",
"make",
"defer",
"statement",
"where",
"it",
"s",
"used",
"simpler",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/schemamanager/schemaswap/schema_swap.go#L454-L460 | train |
vitessio/vitess | go/vt/schemamanager/schemaswap/schema_swap.go | initializeSwap | func (schemaSwap *Swap) initializeSwap() error {
var waitGroup sync.WaitGroup
metadataList := make([]shardSwapMetadata, len(schemaSwap.allShards))
for i, shard := range schemaSwap.allShards {
waitGroup.Add(1)
go shard.readShardMetadata(&metadataList[i], &waitGroup)
}
waitGroup.Wait()
var recorder concurrency... | go | func (schemaSwap *Swap) initializeSwap() error {
var waitGroup sync.WaitGroup
metadataList := make([]shardSwapMetadata, len(schemaSwap.allShards))
for i, shard := range schemaSwap.allShards {
waitGroup.Add(1)
go shard.readShardMetadata(&metadataList[i], &waitGroup)
}
waitGroup.Wait()
var recorder concurrency... | [
"func",
"(",
"schemaSwap",
"*",
"Swap",
")",
"initializeSwap",
"(",
")",
"error",
"{",
"var",
"waitGroup",
"sync",
".",
"WaitGroup",
"\n",
"metadataList",
":=",
"make",
"(",
"[",
"]",
"shardSwapMetadata",
",",
"len",
"(",
"schemaSwap",
".",
"allShards",
")... | // initializeSwap starts the schema swap process. If there is already a schema swap process started
// the method just picks up that. Otherwise it starts a new one and writes into the database that
// the process was started. | [
"initializeSwap",
"starts",
"the",
"schema",
"swap",
"process",
".",
"If",
"there",
"is",
"already",
"a",
"schema",
"swap",
"process",
"started",
"the",
"method",
"just",
"picks",
"up",
"that",
".",
"Otherwise",
"it",
"starts",
"a",
"new",
"one",
"and",
"w... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/schemamanager/schemaswap/schema_swap.go#L465-L532 | train |
vitessio/vitess | go/vt/schemamanager/schemaswap/schema_swap.go | finalizeSwap | func (schemaSwap *Swap) finalizeSwap() error {
return schemaSwap.runOnAllShards(
func(shard *shardSchemaSwap) error {
return shard.writeFinishedSwap()
})
} | go | func (schemaSwap *Swap) finalizeSwap() error {
return schemaSwap.runOnAllShards(
func(shard *shardSchemaSwap) error {
return shard.writeFinishedSwap()
})
} | [
"func",
"(",
"schemaSwap",
"*",
"Swap",
")",
"finalizeSwap",
"(",
")",
"error",
"{",
"return",
"schemaSwap",
".",
"runOnAllShards",
"(",
"func",
"(",
"shard",
"*",
"shardSchemaSwap",
")",
"error",
"{",
"return",
"shard",
".",
"writeFinishedSwap",
"(",
")",
... | // finalizeSwap finishes the completed swap process by modifying the database to register the completion. | [
"finalizeSwap",
"finishes",
"the",
"completed",
"swap",
"process",
"by",
"modifying",
"the",
"database",
"to",
"register",
"the",
"completion",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/schemamanager/schemaswap/schema_swap.go#L535-L540 | train |
vitessio/vitess | go/vt/schemamanager/schemaswap/schema_swap.go | markStepInProgress | func (shardSwap *shardSchemaSwap) markStepInProgress(uiNode *workflow.Node) {
uiNode.Message = ""
uiNode.State = workflowpb.WorkflowState_Running
uiNode.Display = workflow.NodeDisplayIndeterminate
uiNode.BroadcastChanges(false /* updateChildren */)
} | go | func (shardSwap *shardSchemaSwap) markStepInProgress(uiNode *workflow.Node) {
uiNode.Message = ""
uiNode.State = workflowpb.WorkflowState_Running
uiNode.Display = workflow.NodeDisplayIndeterminate
uiNode.BroadcastChanges(false /* updateChildren */)
} | [
"func",
"(",
"shardSwap",
"*",
"shardSchemaSwap",
")",
"markStepInProgress",
"(",
"uiNode",
"*",
"workflow",
".",
"Node",
")",
"{",
"uiNode",
".",
"Message",
"=",
"\"",
"\"",
"\n",
"uiNode",
".",
"State",
"=",
"workflowpb",
".",
"WorkflowState_Running",
"\n"... | // markStepInProgress marks one step of the shard schema swap workflow as running. | [
"markStepInProgress",
"marks",
"one",
"step",
"of",
"the",
"shard",
"schema",
"swap",
"workflow",
"as",
"running",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/schemamanager/schemaswap/schema_swap.go#L554-L559 | train |
vitessio/vitess | go/vt/schemamanager/schemaswap/schema_swap.go | addShardLog | func (shardSwap *shardSchemaSwap) addShardLog(message string) {
log.Infof("Shard %v: %v", shardSwap.shardName, message)
shardSwap.shardUILogger.Infof(message)
shardSwap.shardUINode.Log = shardSwap.shardUILogger.String()
shardSwap.shardUINode.BroadcastChanges(false /* updateChildren */)
} | go | func (shardSwap *shardSchemaSwap) addShardLog(message string) {
log.Infof("Shard %v: %v", shardSwap.shardName, message)
shardSwap.shardUILogger.Infof(message)
shardSwap.shardUINode.Log = shardSwap.shardUILogger.String()
shardSwap.shardUINode.BroadcastChanges(false /* updateChildren */)
} | [
"func",
"(",
"shardSwap",
"*",
"shardSchemaSwap",
")",
"addShardLog",
"(",
"message",
"string",
")",
"{",
"log",
".",
"Infof",
"(",
"\"",
"\"",
",",
"shardSwap",
".",
"shardName",
",",
"message",
")",
"\n",
"shardSwap",
".",
"shardUILogger",
".",
"Infof",
... | // addShardLog prints the message into logs and adds it into logs displayed in UI on the
// shard node. | [
"addShardLog",
"prints",
"the",
"message",
"into",
"logs",
"and",
"adds",
"it",
"into",
"logs",
"displayed",
"in",
"UI",
"on",
"the",
"shard",
"node",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/schemamanager/schemaswap/schema_swap.go#L563-L568 | train |
vitessio/vitess | go/vt/schemamanager/schemaswap/schema_swap.go | markStepDone | func (shardSwap *shardSchemaSwap) markStepDone(uiNode *workflow.Node, err *error) {
if *err != nil {
msg := fmt.Sprintf("Error: %v", *err)
shardSwap.addShardLog(msg)
uiNode.Message = msg
}
uiNode.State = workflowpb.WorkflowState_Done
uiNode.Display = workflow.NodeDisplayNone
uiNode.BroadcastChanges(false /* ... | go | func (shardSwap *shardSchemaSwap) markStepDone(uiNode *workflow.Node, err *error) {
if *err != nil {
msg := fmt.Sprintf("Error: %v", *err)
shardSwap.addShardLog(msg)
uiNode.Message = msg
}
uiNode.State = workflowpb.WorkflowState_Done
uiNode.Display = workflow.NodeDisplayNone
uiNode.BroadcastChanges(false /* ... | [
"func",
"(",
"shardSwap",
"*",
"shardSchemaSwap",
")",
"markStepDone",
"(",
"uiNode",
"*",
"workflow",
".",
"Node",
",",
"err",
"*",
"error",
")",
"{",
"if",
"*",
"err",
"!=",
"nil",
"{",
"msg",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"*... | // markStepDone marks one step of the shard schema swap workflow as finished successfully
// or with an error. | [
"markStepDone",
"marks",
"one",
"step",
"of",
"the",
"shard",
"schema",
"swap",
"workflow",
"as",
"finished",
"successfully",
"or",
"with",
"an",
"error",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/schemamanager/schemaswap/schema_swap.go#L572-L581 | train |
vitessio/vitess | go/vt/schemamanager/schemaswap/schema_swap.go | getMasterTablet | func (shardSwap *shardSchemaSwap) getMasterTablet() (*topodatapb.Tablet, error) {
topoServer := shardSwap.parent.topoServer
shardInfo, err := topoServer.GetShard(shardSwap.parent.ctx, shardSwap.parent.keyspace, shardSwap.shardName)
if err != nil {
return nil, err
}
tabletInfo, err := topoServer.GetTablet(shardSw... | go | func (shardSwap *shardSchemaSwap) getMasterTablet() (*topodatapb.Tablet, error) {
topoServer := shardSwap.parent.topoServer
shardInfo, err := topoServer.GetShard(shardSwap.parent.ctx, shardSwap.parent.keyspace, shardSwap.shardName)
if err != nil {
return nil, err
}
tabletInfo, err := topoServer.GetTablet(shardSw... | [
"func",
"(",
"shardSwap",
"*",
"shardSchemaSwap",
")",
"getMasterTablet",
"(",
")",
"(",
"*",
"topodatapb",
".",
"Tablet",
",",
"error",
")",
"{",
"topoServer",
":=",
"shardSwap",
".",
"parent",
".",
"topoServer",
"\n",
"shardInfo",
",",
"err",
":=",
"topo... | // getMasterTablet returns the tablet that is currently master on the shard. | [
"getMasterTablet",
"returns",
"the",
"tablet",
"that",
"is",
"currently",
"master",
"on",
"the",
"shard",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/schemamanager/schemaswap/schema_swap.go#L584-L595 | train |
vitessio/vitess | go/vt/schemamanager/schemaswap/schema_swap.go | readShardMetadata | func (shardSwap *shardSchemaSwap) readShardMetadata(metadata *shardSwapMetadata, waitGroup *sync.WaitGroup) {
defer waitGroup.Done()
tablet, err := shardSwap.getMasterTablet()
if err != nil {
metadata.err = err
return
}
query := fmt.Sprintf(
"SELECT name, value FROM _vt.shard_metadata WHERE db_name = '%s' a... | go | func (shardSwap *shardSchemaSwap) readShardMetadata(metadata *shardSwapMetadata, waitGroup *sync.WaitGroup) {
defer waitGroup.Done()
tablet, err := shardSwap.getMasterTablet()
if err != nil {
metadata.err = err
return
}
query := fmt.Sprintf(
"SELECT name, value FROM _vt.shard_metadata WHERE db_name = '%s' a... | [
"func",
"(",
"shardSwap",
"*",
"shardSchemaSwap",
")",
"readShardMetadata",
"(",
"metadata",
"*",
"shardSwapMetadata",
",",
"waitGroup",
"*",
"sync",
".",
"WaitGroup",
")",
"{",
"defer",
"waitGroup",
".",
"Done",
"(",
")",
"\n\n",
"tablet",
",",
"err",
":=",... | // readShardMetadata reads info about schema swaps on this shard from _vt.shard_metadata table. | [
"readShardMetadata",
"reads",
"info",
"about",
"schema",
"swaps",
"on",
"this",
"shard",
"from",
"_vt",
".",
"shard_metadata",
"table",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/schemamanager/schemaswap/schema_swap.go#L598-L634 | train |
vitessio/vitess | go/vt/schemamanager/schemaswap/schema_swap.go | writeStartedSwap | func (shardSwap *shardSchemaSwap) writeStartedSwap() error {
tablet, err := shardSwap.getMasterTablet()
if err != nil {
return err
}
queryBuf := bytes.Buffer{}
queryBuf.WriteString("INSERT INTO _vt.shard_metadata (db_name, name, value) VALUES ('")
queryBuf.WriteString(topoproto.TabletDbName(tablet))
queryBuf.W... | go | func (shardSwap *shardSchemaSwap) writeStartedSwap() error {
tablet, err := shardSwap.getMasterTablet()
if err != nil {
return err
}
queryBuf := bytes.Buffer{}
queryBuf.WriteString("INSERT INTO _vt.shard_metadata (db_name, name, value) VALUES ('")
queryBuf.WriteString(topoproto.TabletDbName(tablet))
queryBuf.W... | [
"func",
"(",
"shardSwap",
"*",
"shardSchemaSwap",
")",
"writeStartedSwap",
"(",
")",
"error",
"{",
"tablet",
",",
"err",
":=",
"shardSwap",
".",
"getMasterTablet",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"queryBuf... | // writeStartedSwap registers in the _vt.shard_metadata table in the database the information
// about the new schema swap process being started. | [
"writeStartedSwap",
"registers",
"in",
"the",
"_vt",
".",
"shard_metadata",
"table",
"in",
"the",
"database",
"the",
"information",
"about",
"the",
"new",
"schema",
"swap",
"process",
"being",
"started",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/schemamanager/schemaswap/schema_swap.go#L638-L662 | train |
vitessio/vitess | go/vt/schemamanager/schemaswap/schema_swap.go | writeFinishedSwap | func (shardSwap *shardSchemaSwap) writeFinishedSwap() error {
tablet, err := shardSwap.getMasterTablet()
if err != nil {
return err
}
query := fmt.Sprintf(
"INSERT INTO _vt.shard_metadata (db_name, name, value) VALUES ('%s', '%s', '%d') ON DUPLICATE KEY UPDATE value = '%d'",
topoproto.TabletDbName(tablet), la... | go | func (shardSwap *shardSchemaSwap) writeFinishedSwap() error {
tablet, err := shardSwap.getMasterTablet()
if err != nil {
return err
}
query := fmt.Sprintf(
"INSERT INTO _vt.shard_metadata (db_name, name, value) VALUES ('%s', '%s', '%d') ON DUPLICATE KEY UPDATE value = '%d'",
topoproto.TabletDbName(tablet), la... | [
"func",
"(",
"shardSwap",
"*",
"shardSchemaSwap",
")",
"writeFinishedSwap",
"(",
")",
"error",
"{",
"tablet",
",",
"err",
":=",
"shardSwap",
".",
"getMasterTablet",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"query",... | // writeFinishedSwap registers in the _vt.shard_metadata table in the database that the schema
// swap process has finished. | [
"writeFinishedSwap",
"registers",
"in",
"the",
"_vt",
".",
"shard_metadata",
"table",
"in",
"the",
"database",
"that",
"the",
"schema",
"swap",
"process",
"has",
"finished",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/schemamanager/schemaswap/schema_swap.go#L666-L681 | train |
vitessio/vitess | go/vt/schemamanager/schemaswap/schema_swap.go | startHealthWatchers | func (shardSwap *shardSchemaSwap) startHealthWatchers(ctx context.Context) error {
shardSwap.allTablets = make(map[string]*discovery.TabletStats)
shardSwap.tabletHealthCheck = discovery.NewHealthCheck(*vtctl.HealthcheckRetryDelay, *vtctl.HealthCheckTimeout)
shardSwap.tabletHealthCheck.SetListener(shardSwap, true /*... | go | func (shardSwap *shardSchemaSwap) startHealthWatchers(ctx context.Context) error {
shardSwap.allTablets = make(map[string]*discovery.TabletStats)
shardSwap.tabletHealthCheck = discovery.NewHealthCheck(*vtctl.HealthcheckRetryDelay, *vtctl.HealthCheckTimeout)
shardSwap.tabletHealthCheck.SetListener(shardSwap, true /*... | [
"func",
"(",
"shardSwap",
"*",
"shardSchemaSwap",
")",
"startHealthWatchers",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"shardSwap",
".",
"allTablets",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"discovery",
".",
"TabletStats",
")",
... | // startHealthWatchers launches the topology watchers and health checking to monitor
// all tablets on the shard. Function should be called before the start of the schema
// swap process. | [
"startHealthWatchers",
"launches",
"the",
"topology",
"watchers",
"and",
"health",
"checking",
"to",
"monitor",
"all",
"tablets",
"on",
"the",
"shard",
".",
"Function",
"should",
"be",
"called",
"before",
"the",
"start",
"of",
"the",
"schema",
"swap",
"process",... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/schemamanager/schemaswap/schema_swap.go#L686-L733 | train |
vitessio/vitess | go/vt/schemamanager/schemaswap/schema_swap.go | isTabletHealthy | func isTabletHealthy(tabletStats *discovery.TabletStats) bool {
return tabletStats.Stats.HealthError == "" && !discovery.IsReplicationLagHigh(tabletStats)
} | go | func isTabletHealthy(tabletStats *discovery.TabletStats) bool {
return tabletStats.Stats.HealthError == "" && !discovery.IsReplicationLagHigh(tabletStats)
} | [
"func",
"isTabletHealthy",
"(",
"tabletStats",
"*",
"discovery",
".",
"TabletStats",
")",
"bool",
"{",
"return",
"tabletStats",
".",
"Stats",
".",
"HealthError",
"==",
"\"",
"\"",
"&&",
"!",
"discovery",
".",
"IsReplicationLagHigh",
"(",
"tabletStats",
")",
"\... | // isTabletHealthy verifies that the given TabletStats represents a healthy tablet that is
// caught up with replication to a serving level. | [
"isTabletHealthy",
"verifies",
"that",
"the",
"given",
"TabletStats",
"represents",
"a",
"healthy",
"tablet",
"that",
"is",
"caught",
"up",
"with",
"replication",
"to",
"a",
"serving",
"level",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/schemamanager/schemaswap/schema_swap.go#L751-L753 | train |
vitessio/vitess | go/vt/schemamanager/schemaswap/schema_swap.go | checkWaitingTabletHealthiness | func (shardSwap *shardSchemaSwap) checkWaitingTabletHealthiness(tabletStats *discovery.TabletStats) {
if shardSwap.healthWaitingTablet == tabletStats.Key && isTabletHealthy(tabletStats) {
close(*shardSwap.healthWaitingChannel)
shardSwap.healthWaitingChannel = nil
shardSwap.healthWaitingTablet = ""
}
} | go | func (shardSwap *shardSchemaSwap) checkWaitingTabletHealthiness(tabletStats *discovery.TabletStats) {
if shardSwap.healthWaitingTablet == tabletStats.Key && isTabletHealthy(tabletStats) {
close(*shardSwap.healthWaitingChannel)
shardSwap.healthWaitingChannel = nil
shardSwap.healthWaitingTablet = ""
}
} | [
"func",
"(",
"shardSwap",
"*",
"shardSchemaSwap",
")",
"checkWaitingTabletHealthiness",
"(",
"tabletStats",
"*",
"discovery",
".",
"TabletStats",
")",
"{",
"if",
"shardSwap",
".",
"healthWaitingTablet",
"==",
"tabletStats",
".",
"Key",
"&&",
"isTabletHealthy",
"(",
... | // checkWaitingTabletHealthiness verifies whether the provided TabletStats represent the
// tablet that is being waited to become healthy, and notifies the waiting go routine if
// it is the tablet and if it is healthy now.
// The function should be called with shardSwap.allTabletsLock mutex locked. | [
"checkWaitingTabletHealthiness",
"verifies",
"whether",
"the",
"provided",
"TabletStats",
"represent",
"the",
"tablet",
"that",
"is",
"being",
"waited",
"to",
"become",
"healthy",
"and",
"notifies",
"the",
"waiting",
"go",
"routine",
"if",
"it",
"is",
"the",
"tabl... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/schemamanager/schemaswap/schema_swap.go#L783-L789 | train |
vitessio/vitess | go/vt/schemamanager/schemaswap/schema_swap.go | StatsUpdate | func (shardSwap *shardSchemaSwap) StatsUpdate(newTabletStats *discovery.TabletStats) {
shardSwap.allTabletsLock.Lock()
defer shardSwap.allTabletsLock.Unlock()
existingStats, found := shardSwap.allTablets[newTabletStats.Key]
if newTabletStats.Up {
if found {
*existingStats = *newTabletStats
} else {
shard... | go | func (shardSwap *shardSchemaSwap) StatsUpdate(newTabletStats *discovery.TabletStats) {
shardSwap.allTabletsLock.Lock()
defer shardSwap.allTabletsLock.Unlock()
existingStats, found := shardSwap.allTablets[newTabletStats.Key]
if newTabletStats.Up {
if found {
*existingStats = *newTabletStats
} else {
shard... | [
"func",
"(",
"shardSwap",
"*",
"shardSchemaSwap",
")",
"StatsUpdate",
"(",
"newTabletStats",
"*",
"discovery",
".",
"TabletStats",
")",
"{",
"shardSwap",
".",
"allTabletsLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"shardSwap",
".",
"allTabletsLock",
".",
"Unl... | // StatsUpdate is the part of discovery.HealthCheckStatsListener interface. It makes sure
// that when a change of tablet health happens it's recorded in allTablets list, and if
// this is the tablet that is being waited for after restore, the function wakes up the
// waiting go routine. | [
"StatsUpdate",
"is",
"the",
"part",
"of",
"discovery",
".",
"HealthCheckStatsListener",
"interface",
".",
"It",
"makes",
"sure",
"that",
"when",
"a",
"change",
"of",
"tablet",
"health",
"happens",
"it",
"s",
"recorded",
"in",
"allTablets",
"list",
"and",
"if",... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/schemamanager/schemaswap/schema_swap.go#L795-L810 | train |
vitessio/vitess | go/vt/schemamanager/schemaswap/schema_swap.go | getTabletList | func (shardSwap *shardSchemaSwap) getTabletList() []discovery.TabletStats {
shardSwap.allTabletsLock.RLock()
defer shardSwap.allTabletsLock.RUnlock()
tabletList := make([]discovery.TabletStats, 0, len(shardSwap.allTablets))
for _, tabletStats := range shardSwap.allTablets {
tabletList = append(tabletList, *table... | go | func (shardSwap *shardSchemaSwap) getTabletList() []discovery.TabletStats {
shardSwap.allTabletsLock.RLock()
defer shardSwap.allTabletsLock.RUnlock()
tabletList := make([]discovery.TabletStats, 0, len(shardSwap.allTablets))
for _, tabletStats := range shardSwap.allTablets {
tabletList = append(tabletList, *table... | [
"func",
"(",
"shardSwap",
"*",
"shardSchemaSwap",
")",
"getTabletList",
"(",
")",
"[",
"]",
"discovery",
".",
"TabletStats",
"{",
"shardSwap",
".",
"allTabletsLock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"shardSwap",
".",
"allTabletsLock",
".",
"RUnlock",
"... | // getTabletList returns the list of all known tablets in the shard so that the caller
// could operate with it without holding the allTabletsLock. | [
"getTabletList",
"returns",
"the",
"list",
"of",
"all",
"known",
"tablets",
"in",
"the",
"shard",
"so",
"that",
"the",
"caller",
"could",
"operate",
"with",
"it",
"without",
"holding",
"the",
"allTabletsLock",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/schemamanager/schemaswap/schema_swap.go#L814-L823 | train |
vitessio/vitess | go/vt/schemamanager/schemaswap/schema_swap.go | Swap | func (array orderTabletsForSwap) Swap(i, j int) {
array[i], array[j] = array[j], array[i]
} | go | func (array orderTabletsForSwap) Swap(i, j int) {
array[i], array[j] = array[j], array[i]
} | [
"func",
"(",
"array",
"orderTabletsForSwap",
")",
"Swap",
"(",
"i",
",",
"j",
"int",
")",
"{",
"array",
"[",
"i",
"]",
",",
"array",
"[",
"j",
"]",
"=",
"array",
"[",
"j",
"]",
",",
"array",
"[",
"i",
"]",
"\n",
"}"
] | // Swap is part of sort.Interface interface. | [
"Swap",
"is",
"part",
"of",
"sort",
".",
"Interface",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/schemamanager/schemaswap/schema_swap.go#L836-L838 | train |
vitessio/vitess | go/vt/schemamanager/schemaswap/schema_swap.go | getTabletTypeFromStats | func getTabletTypeFromStats(tabletStats *discovery.TabletStats) topodatapb.TabletType {
if tabletStats.Target == nil || tabletStats.Target.TabletType == topodatapb.TabletType_UNKNOWN {
return tabletStats.Tablet.Type
}
return tabletStats.Target.TabletType
} | go | func getTabletTypeFromStats(tabletStats *discovery.TabletStats) topodatapb.TabletType {
if tabletStats.Target == nil || tabletStats.Target.TabletType == topodatapb.TabletType_UNKNOWN {
return tabletStats.Tablet.Type
}
return tabletStats.Target.TabletType
} | [
"func",
"getTabletTypeFromStats",
"(",
"tabletStats",
"*",
"discovery",
".",
"TabletStats",
")",
"topodatapb",
".",
"TabletType",
"{",
"if",
"tabletStats",
".",
"Target",
"==",
"nil",
"||",
"tabletStats",
".",
"Target",
".",
"TabletType",
"==",
"topodatapb",
"."... | // getTabletTypeFromStats returns the tablet type saved in the TabletStats object. If there is Target
// data in the TabletStats object then the function returns TabletType from it because it will be more
// up-to-date. But if that's not available then it returns Tablet.Type which will contain data read
// from the top... | [
"getTabletTypeFromStats",
"returns",
"the",
"tablet",
"type",
"saved",
"in",
"the",
"TabletStats",
"object",
".",
"If",
"there",
"is",
"Target",
"data",
"in",
"the",
"TabletStats",
"object",
"then",
"the",
"function",
"returns",
"TabletType",
"from",
"it",
"beca... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/schemamanager/schemaswap/schema_swap.go#L844-L849 | train |
vitessio/vitess | go/vt/schemamanager/schemaswap/schema_swap.go | Less | func (array orderTabletsForSwap) Less(i, j int) bool {
return tabletSortIndex(&array[i]) < tabletSortIndex(&array[j])
} | go | func (array orderTabletsForSwap) Less(i, j int) bool {
return tabletSortIndex(&array[i]) < tabletSortIndex(&array[j])
} | [
"func",
"(",
"array",
"orderTabletsForSwap",
")",
"Less",
"(",
"i",
",",
"j",
"int",
")",
"bool",
"{",
"return",
"tabletSortIndex",
"(",
"&",
"array",
"[",
"i",
"]",
")",
"<",
"tabletSortIndex",
"(",
"&",
"array",
"[",
"j",
"]",
")",
"\n",
"}"
] | // Less is part of sort.Interface interface. It should compare too elements of the array. | [
"Less",
"is",
"part",
"of",
"sort",
".",
"Interface",
"interface",
".",
"It",
"should",
"compare",
"too",
"elements",
"of",
"the",
"array",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/schemamanager/schemaswap/schema_swap.go#L875-L877 | train |
vitessio/vitess | go/vt/schemamanager/schemaswap/schema_swap.go | isSwapApplied | func (shardSwap *shardSchemaSwap) isSwapApplied(tablet *topodatapb.Tablet) (bool, error) {
swapIDResult, err := shardSwap.executeAdminQuery(
tablet,
fmt.Sprintf("SELECT value FROM _vt.local_metadata WHERE db_name = '%s' AND name = '%s'", topoproto.TabletDbName(tablet), lastAppliedMetadataName),
1 /* maxRows */)
... | go | func (shardSwap *shardSchemaSwap) isSwapApplied(tablet *topodatapb.Tablet) (bool, error) {
swapIDResult, err := shardSwap.executeAdminQuery(
tablet,
fmt.Sprintf("SELECT value FROM _vt.local_metadata WHERE db_name = '%s' AND name = '%s'", topoproto.TabletDbName(tablet), lastAppliedMetadataName),
1 /* maxRows */)
... | [
"func",
"(",
"shardSwap",
"*",
"shardSchemaSwap",
")",
"isSwapApplied",
"(",
"tablet",
"*",
"topodatapb",
".",
"Tablet",
")",
"(",
"bool",
",",
"error",
")",
"{",
"swapIDResult",
",",
"err",
":=",
"shardSwap",
".",
"executeAdminQuery",
"(",
"tablet",
",",
... | // isSwapApplied verifies whether the schema swap was already applied to the tablet. It's
// considered to be applied if _vt.local_metadata table has the swap id in the row titled
// 'LastAppliedSchemaSwap'. | [
"isSwapApplied",
"verifies",
"whether",
"the",
"schema",
"swap",
"was",
"already",
"applied",
"to",
"the",
"tablet",
".",
"It",
"s",
"considered",
"to",
"be",
"applied",
"if",
"_vt",
".",
"local_metadata",
"table",
"has",
"the",
"swap",
"id",
"in",
"the",
... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/schemamanager/schemaswap/schema_swap.go#L900-L917 | train |
vitessio/vitess | go/vt/schemamanager/schemaswap/schema_swap.go | undrainSeedTablet | func (shardSwap *shardSchemaSwap) undrainSeedTablet(seedTablet *topodatapb.Tablet, tabletType topodatapb.TabletType) error {
_, err := shardSwap.parent.topoServer.UpdateTabletFields(shardSwap.parent.ctx, seedTablet.Alias,
func(tablet *topodatapb.Tablet) error {
delete(tablet.Tags, "drain_reason")
return nil
... | go | func (shardSwap *shardSchemaSwap) undrainSeedTablet(seedTablet *topodatapb.Tablet, tabletType topodatapb.TabletType) error {
_, err := shardSwap.parent.topoServer.UpdateTabletFields(shardSwap.parent.ctx, seedTablet.Alias,
func(tablet *topodatapb.Tablet) error {
delete(tablet.Tags, "drain_reason")
return nil
... | [
"func",
"(",
"shardSwap",
"*",
"shardSchemaSwap",
")",
"undrainSeedTablet",
"(",
"seedTablet",
"*",
"topodatapb",
".",
"Tablet",
",",
"tabletType",
"topodatapb",
".",
"TabletType",
")",
"error",
"{",
"_",
",",
"err",
":=",
"shardSwap",
".",
"parent",
".",
"t... | // undrainSeedTablet undrains the tablet that was used to apply seed schema change,
// and returns it to the same type as it was before. | [
"undrainSeedTablet",
"undrains",
"the",
"tablet",
"that",
"was",
"used",
"to",
"apply",
"seed",
"schema",
"change",
"and",
"returns",
"it",
"to",
"the",
"same",
"type",
"as",
"it",
"was",
"before",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/schemamanager/schemaswap/schema_swap.go#L964-L979 | train |
vitessio/vitess | go/vt/schemamanager/schemaswap/schema_swap.go | takeSeedBackup | func (shardSwap *shardSchemaSwap) takeSeedBackup() (err error) {
shardSwap.markStepInProgress(shardSwap.backupUINode)
defer shardSwap.markStepDone(shardSwap.backupUINode, &err)
tabletList := shardSwap.getTabletList()
sort.Sort(orderTabletsForSwap(tabletList))
var seedTablet *topodatapb.Tablet
for seedTablet == n... | go | func (shardSwap *shardSchemaSwap) takeSeedBackup() (err error) {
shardSwap.markStepInProgress(shardSwap.backupUINode)
defer shardSwap.markStepDone(shardSwap.backupUINode, &err)
tabletList := shardSwap.getTabletList()
sort.Sort(orderTabletsForSwap(tabletList))
var seedTablet *topodatapb.Tablet
for seedTablet == n... | [
"func",
"(",
"shardSwap",
"*",
"shardSchemaSwap",
")",
"takeSeedBackup",
"(",
")",
"(",
"err",
"error",
")",
"{",
"shardSwap",
".",
"markStepInProgress",
"(",
"shardSwap",
".",
"backupUINode",
")",
"\n",
"defer",
"shardSwap",
".",
"markStepDone",
"(",
"shardSw... | // takeSeedBackup takes backup on the seed tablet. The method assumes that the seed tablet is any tablet that
// has info that schema swap was already applied on it. This way the function can be re-used if the seed backup
// is lost somewhere half way through the schema swap process. | [
"takeSeedBackup",
"takes",
"backup",
"on",
"the",
"seed",
"tablet",
".",
"The",
"method",
"assumes",
"that",
"the",
"seed",
"tablet",
"is",
"any",
"tablet",
"that",
"has",
"info",
"that",
"schema",
"swap",
"was",
"already",
"applied",
"on",
"it",
".",
"Thi... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/schemamanager/schemaswap/schema_swap.go#L1072-L1118 | train |
vitessio/vitess | go/vt/schemamanager/schemaswap/schema_swap.go | swapOnTablet | func (shardSwap *shardSchemaSwap) swapOnTablet(tablet *topodatapb.Tablet) error {
shardSwap.addPropagationLog(fmt.Sprintf("Restoring tablet %v from backup", tablet.Alias))
eventStream, err := shardSwap.parent.tabletClient.RestoreFromBackup(shardSwap.parent.ctx, tablet)
if err != nil {
return err
}
waitForRestore... | go | func (shardSwap *shardSchemaSwap) swapOnTablet(tablet *topodatapb.Tablet) error {
shardSwap.addPropagationLog(fmt.Sprintf("Restoring tablet %v from backup", tablet.Alias))
eventStream, err := shardSwap.parent.tabletClient.RestoreFromBackup(shardSwap.parent.ctx, tablet)
if err != nil {
return err
}
waitForRestore... | [
"func",
"(",
"shardSwap",
"*",
"shardSchemaSwap",
")",
"swapOnTablet",
"(",
"tablet",
"*",
"topodatapb",
".",
"Tablet",
")",
"error",
"{",
"shardSwap",
".",
"addPropagationLog",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"tablet",
".",
"Alias",
")",... | // swapOnTablet performs the schema swap on the provided tablet and then waits for it
// to become healthy and to catch up with replication. | [
"swapOnTablet",
"performs",
"the",
"schema",
"swap",
"on",
"the",
"provided",
"tablet",
"and",
"then",
"waits",
"for",
"it",
"to",
"become",
"healthy",
"and",
"to",
"catch",
"up",
"with",
"replication",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/schemamanager/schemaswap/schema_swap.go#L1122-L1153 | train |
vitessio/vitess | go/vt/schemamanager/schemaswap/schema_swap.go | waitForTabletToBeHealthy | func (shardSwap *shardSchemaSwap) waitForTabletToBeHealthy(tablet *topodatapb.Tablet) error {
waitChannel, err := shardSwap.startWaitingOnUnhealthyTablet(tablet)
if err != nil {
return err
}
if waitChannel != nil {
select {
case <-shardSwap.parent.ctx.Done():
return shardSwap.parent.ctx.Err()
case <-*wai... | go | func (shardSwap *shardSchemaSwap) waitForTabletToBeHealthy(tablet *topodatapb.Tablet) error {
waitChannel, err := shardSwap.startWaitingOnUnhealthyTablet(tablet)
if err != nil {
return err
}
if waitChannel != nil {
select {
case <-shardSwap.parent.ctx.Done():
return shardSwap.parent.ctx.Err()
case <-*wai... | [
"func",
"(",
"shardSwap",
"*",
"shardSchemaSwap",
")",
"waitForTabletToBeHealthy",
"(",
"tablet",
"*",
"topodatapb",
".",
"Tablet",
")",
"error",
"{",
"waitChannel",
",",
"err",
":=",
"shardSwap",
".",
"startWaitingOnUnhealthyTablet",
"(",
"tablet",
")",
"\n",
"... | // waitForTabletToBeHealthy waits until the given tablet becomes healthy and caught up with
// replication. If the tablet is already healthy and caught up when this method is called then
// it returns immediately. | [
"waitForTabletToBeHealthy",
"waits",
"until",
"the",
"given",
"tablet",
"becomes",
"healthy",
"and",
"caught",
"up",
"with",
"replication",
".",
"If",
"the",
"tablet",
"is",
"already",
"healthy",
"and",
"caught",
"up",
"when",
"this",
"method",
"is",
"called",
... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/schemamanager/schemaswap/schema_swap.go#L1158-L1172 | train |
vitessio/vitess | go/vt/schemamanager/schemaswap/schema_swap.go | updatePropagationProgressUI | func (shardSwap *shardSchemaSwap) updatePropagationProgressUI() {
shardSwap.propagationUINode.ProgressMessage = fmt.Sprintf("%v/%v", shardSwap.numTabletsSwapped, shardSwap.numTabletsTotal)
if shardSwap.numTabletsTotal == 0 {
shardSwap.propagationUINode.Progress = 0
} else {
shardSwap.propagationUINode.Progress =... | go | func (shardSwap *shardSchemaSwap) updatePropagationProgressUI() {
shardSwap.propagationUINode.ProgressMessage = fmt.Sprintf("%v/%v", shardSwap.numTabletsSwapped, shardSwap.numTabletsTotal)
if shardSwap.numTabletsTotal == 0 {
shardSwap.propagationUINode.Progress = 0
} else {
shardSwap.propagationUINode.Progress =... | [
"func",
"(",
"shardSwap",
"*",
"shardSchemaSwap",
")",
"updatePropagationProgressUI",
"(",
")",
"{",
"shardSwap",
".",
"propagationUINode",
".",
"ProgressMessage",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"shardSwap",
".",
"numTabletsSwapped",
",",
"sha... | // updatePropagationProgressUI updates the progress bar in the workflow UI to reflect appropriate
// percentage in line with how many tablets have schema swapped already. | [
"updatePropagationProgressUI",
"updates",
"the",
"progress",
"bar",
"in",
"the",
"workflow",
"UI",
"to",
"reflect",
"appropriate",
"percentage",
"in",
"line",
"with",
"how",
"many",
"tablets",
"have",
"schema",
"swapped",
"already",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/schemamanager/schemaswap/schema_swap.go#L1176-L1184 | train |
vitessio/vitess | go/vt/schemamanager/schemaswap/schema_swap.go | markPropagationInProgress | func (shardSwap *shardSchemaSwap) markPropagationInProgress() {
shardSwap.propagationUINode.Message = ""
shardSwap.propagationUINode.State = workflowpb.WorkflowState_Running
shardSwap.propagationUINode.Display = workflow.NodeDisplayDeterminate
shardSwap.propagationUINode.BroadcastChanges(false /* updateChildren */)... | go | func (shardSwap *shardSchemaSwap) markPropagationInProgress() {
shardSwap.propagationUINode.Message = ""
shardSwap.propagationUINode.State = workflowpb.WorkflowState_Running
shardSwap.propagationUINode.Display = workflow.NodeDisplayDeterminate
shardSwap.propagationUINode.BroadcastChanges(false /* updateChildren */)... | [
"func",
"(",
"shardSwap",
"*",
"shardSchemaSwap",
")",
"markPropagationInProgress",
"(",
")",
"{",
"shardSwap",
".",
"propagationUINode",
".",
"Message",
"=",
"\"",
"\"",
"\n",
"shardSwap",
".",
"propagationUINode",
".",
"State",
"=",
"workflowpb",
".",
"Workflo... | // markPropagationInProgress marks the propagation step of the shard schema swap workflow as running. | [
"markPropagationInProgress",
"marks",
"the",
"propagation",
"step",
"of",
"the",
"shard",
"schema",
"swap",
"workflow",
"as",
"running",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/schemamanager/schemaswap/schema_swap.go#L1187-L1192 | train |
vitessio/vitess | go/vt/schemamanager/schemaswap/schema_swap.go | addPropagationLog | func (shardSwap *shardSchemaSwap) addPropagationLog(message string) {
shardSwap.propagationUILogger.Infof(message)
shardSwap.propagationUINode.Log = shardSwap.propagationUILogger.String()
shardSwap.propagationUINode.Message = message
shardSwap.propagationUINode.BroadcastChanges(false /* updateChildren */)
shardSwa... | go | func (shardSwap *shardSchemaSwap) addPropagationLog(message string) {
shardSwap.propagationUILogger.Infof(message)
shardSwap.propagationUINode.Log = shardSwap.propagationUILogger.String()
shardSwap.propagationUINode.Message = message
shardSwap.propagationUINode.BroadcastChanges(false /* updateChildren */)
shardSwa... | [
"func",
"(",
"shardSwap",
"*",
"shardSchemaSwap",
")",
"addPropagationLog",
"(",
"message",
"string",
")",
"{",
"shardSwap",
".",
"propagationUILogger",
".",
"Infof",
"(",
"message",
")",
"\n",
"shardSwap",
".",
"propagationUINode",
".",
"Log",
"=",
"shardSwap",... | // addPropagationLog prints the message to logs, adds it to logs displayed in the UI on the "Propagate to all tablets"
// node and adds the message to the logs displayed on the overall shard node, so that everything happening to this
// shard was visible in one log. | [
"addPropagationLog",
"prints",
"the",
"message",
"to",
"logs",
"adds",
"it",
"to",
"logs",
"displayed",
"in",
"the",
"UI",
"on",
"the",
"Propagate",
"to",
"all",
"tablets",
"node",
"and",
"adds",
"the",
"message",
"to",
"the",
"logs",
"displayed",
"on",
"t... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/schemamanager/schemaswap/schema_swap.go#L1197-L1203 | train |
vitessio/vitess | go/vt/schemamanager/schemaswap/schema_swap.go | markPropagationDone | func (shardSwap *shardSchemaSwap) markPropagationDone(err *error) {
if *err != nil {
msg := fmt.Sprintf("Error: %v", *err)
shardSwap.addPropagationLog(msg)
shardSwap.propagationUINode.Message = msg
shardSwap.propagationUINode.State = workflowpb.WorkflowState_Done
} else if shardSwap.numTabletsSwapped == shard... | go | func (shardSwap *shardSchemaSwap) markPropagationDone(err *error) {
if *err != nil {
msg := fmt.Sprintf("Error: %v", *err)
shardSwap.addPropagationLog(msg)
shardSwap.propagationUINode.Message = msg
shardSwap.propagationUINode.State = workflowpb.WorkflowState_Done
} else if shardSwap.numTabletsSwapped == shard... | [
"func",
"(",
"shardSwap",
"*",
"shardSchemaSwap",
")",
"markPropagationDone",
"(",
"err",
"*",
"error",
")",
"{",
"if",
"*",
"err",
"!=",
"nil",
"{",
"msg",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"*",
"err",
")",
"\n",
"shardSwap",
".",
... | // markPropagationDone marks the propagation step of the shard schema swap workflow as finished successfully
// or with an error. | [
"markPropagationDone",
"marks",
"the",
"propagation",
"step",
"of",
"the",
"shard",
"schema",
"swap",
"workflow",
"as",
"finished",
"successfully",
"or",
"with",
"an",
"error",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/schemamanager/schemaswap/schema_swap.go#L1207-L1217 | train |
vitessio/vitess | go/vt/schemamanager/schemaswap/schema_swap.go | propagateToAllTablets | func (shardSwap *shardSchemaSwap) propagateToAllTablets(withMasterReparent bool) (err error) {
shardSwap.markPropagationInProgress()
defer shardSwap.markPropagationDone(&err)
for {
shardSwap.updatePropagationProgressUI()
tablet, err := shardSwap.findNextTabletToSwap()
// Update UI immediately after finding ne... | go | func (shardSwap *shardSchemaSwap) propagateToAllTablets(withMasterReparent bool) (err error) {
shardSwap.markPropagationInProgress()
defer shardSwap.markPropagationDone(&err)
for {
shardSwap.updatePropagationProgressUI()
tablet, err := shardSwap.findNextTabletToSwap()
// Update UI immediately after finding ne... | [
"func",
"(",
"shardSwap",
"*",
"shardSchemaSwap",
")",
"propagateToAllTablets",
"(",
"withMasterReparent",
"bool",
")",
"(",
"err",
"error",
")",
"{",
"shardSwap",
".",
"markPropagationInProgress",
"(",
")",
"\n",
"defer",
"shardSwap",
".",
"markPropagationDone",
... | // propagateToNonMasterTablets propagates the schema change to all non-master tablets
// in the shard. When it returns nil it means that only master can remain left with the
// old schema, everything else is verified to have schema swap applied. | [
"propagateToNonMasterTablets",
"propagates",
"the",
"schema",
"change",
"to",
"all",
"non",
"-",
"master",
"tablets",
"in",
"the",
"shard",
".",
"When",
"it",
"returns",
"nil",
"it",
"means",
"that",
"only",
"master",
"can",
"remain",
"left",
"with",
"the",
... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/schemamanager/schemaswap/schema_swap.go#L1222-L1275 | train |
vitessio/vitess | go/vt/schemamanager/schemaswap/schema_swap.go | reparentFromMaster | func (shardSwap *shardSchemaSwap) reparentFromMaster(masterTablet *topodatapb.Tablet) (err error) {
shardSwap.markStepInProgress(shardSwap.reparentUINode)
defer shardSwap.markStepDone(shardSwap.reparentUINode, &err)
shardSwap.addShardLog(fmt.Sprintf("Reparenting away from master %v", masterTablet.Alias))
if *mysql... | go | func (shardSwap *shardSchemaSwap) reparentFromMaster(masterTablet *topodatapb.Tablet) (err error) {
shardSwap.markStepInProgress(shardSwap.reparentUINode)
defer shardSwap.markStepDone(shardSwap.reparentUINode, &err)
shardSwap.addShardLog(fmt.Sprintf("Reparenting away from master %v", masterTablet.Alias))
if *mysql... | [
"func",
"(",
"shardSwap",
"*",
"shardSchemaSwap",
")",
"reparentFromMaster",
"(",
"masterTablet",
"*",
"topodatapb",
".",
"Tablet",
")",
"(",
"err",
"error",
")",
"{",
"shardSwap",
".",
"markStepInProgress",
"(",
"shardSwap",
".",
"reparentUINode",
")",
"\n",
... | // propagateToMaster propagates the schema change to the master. If the master already has
// the schema change applied then the method does nothing. | [
"propagateToMaster",
"propagates",
"the",
"schema",
"change",
"to",
"the",
"master",
".",
"If",
"the",
"master",
"already",
"has",
"the",
"schema",
"change",
"applied",
"then",
"the",
"method",
"does",
"nothing",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/schemamanager/schemaswap/schema_swap.go#L1279-L1309 | train |
vitessio/vitess | go/vt/binlog/slave_connection.go | connectForReplication | func connectForReplication(cp *mysql.ConnParams) (*mysql.Conn, error) {
params, err := dbconfigs.WithCredentials(cp)
if err != nil {
return nil, err
}
ctx := context.Background()
conn, err := mysql.Connect(ctx, params)
if err != nil {
return nil, err
}
// Tell the server that we understand the format of e... | go | func connectForReplication(cp *mysql.ConnParams) (*mysql.Conn, error) {
params, err := dbconfigs.WithCredentials(cp)
if err != nil {
return nil, err
}
ctx := context.Background()
conn, err := mysql.Connect(ctx, params)
if err != nil {
return nil, err
}
// Tell the server that we understand the format of e... | [
"func",
"connectForReplication",
"(",
"cp",
"*",
"mysql",
".",
"ConnParams",
")",
"(",
"*",
"mysql",
".",
"Conn",
",",
"error",
")",
"{",
"params",
",",
"err",
":=",
"dbconfigs",
".",
"WithCredentials",
"(",
"cp",
")",
"\n",
"if",
"err",
"!=",
"nil",
... | // connectForReplication create a MySQL connection ready to use for replication. | [
"connectForReplication",
"create",
"a",
"MySQL",
"connection",
"ready",
"to",
"use",
"for",
"replication",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/binlog/slave_connection.go#L72-L91 | train |
vitessio/vitess | go/vt/binlog/slave_connection.go | StartBinlogDumpFromCurrent | func (sc *SlaveConnection) StartBinlogDumpFromCurrent(ctx context.Context) (mysql.Position, <-chan mysql.BinlogEvent, error) {
ctx, sc.cancel = context.WithCancel(ctx)
masterPosition, err := sc.Conn.MasterPosition()
if err != nil {
return mysql.Position{}, nil, fmt.Errorf("failed to get master position: %v", err)... | go | func (sc *SlaveConnection) StartBinlogDumpFromCurrent(ctx context.Context) (mysql.Position, <-chan mysql.BinlogEvent, error) {
ctx, sc.cancel = context.WithCancel(ctx)
masterPosition, err := sc.Conn.MasterPosition()
if err != nil {
return mysql.Position{}, nil, fmt.Errorf("failed to get master position: %v", err)... | [
"func",
"(",
"sc",
"*",
"SlaveConnection",
")",
"StartBinlogDumpFromCurrent",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"mysql",
".",
"Position",
",",
"<-",
"chan",
"mysql",
".",
"BinlogEvent",
",",
"error",
")",
"{",
"ctx",
",",
"sc",
".",
"cance... | // StartBinlogDumpFromCurrent requests a replication binlog dump from
// the current position. | [
"StartBinlogDumpFromCurrent",
"requests",
"a",
"replication",
"binlog",
"dump",
"from",
"the",
"current",
"position",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/binlog/slave_connection.go#L98-L108 | train |
vitessio/vitess | go/vt/binlog/slave_connection.go | StartBinlogDumpFromPosition | func (sc *SlaveConnection) StartBinlogDumpFromPosition(ctx context.Context, startPos mysql.Position) (<-chan mysql.BinlogEvent, error) {
ctx, sc.cancel = context.WithCancel(ctx)
log.Infof("sending binlog dump command: startPos=%v, slaveID=%v", startPos, sc.slaveID)
if err := sc.SendBinlogDumpCommand(sc.slaveID, sta... | go | func (sc *SlaveConnection) StartBinlogDumpFromPosition(ctx context.Context, startPos mysql.Position) (<-chan mysql.BinlogEvent, error) {
ctx, sc.cancel = context.WithCancel(ctx)
log.Infof("sending binlog dump command: startPos=%v, slaveID=%v", startPos, sc.slaveID)
if err := sc.SendBinlogDumpCommand(sc.slaveID, sta... | [
"func",
"(",
"sc",
"*",
"SlaveConnection",
")",
"StartBinlogDumpFromPosition",
"(",
"ctx",
"context",
".",
"Context",
",",
"startPos",
"mysql",
".",
"Position",
")",
"(",
"<-",
"chan",
"mysql",
".",
"BinlogEvent",
",",
"error",
")",
"{",
"ctx",
",",
"sc",
... | // StartBinlogDumpFromPosition requests a replication binlog dump from
// the master mysqld at the given Position and then sends binlog
// events to the provided channel.
// The stream will continue in the background, waiting for new events if
// necessary, until the connection is closed, either by the master or
// by ... | [
"StartBinlogDumpFromPosition",
"requests",
"a",
"replication",
"binlog",
"dump",
"from",
"the",
"master",
"mysqld",
"at",
"the",
"given",
"Position",
"and",
"then",
"sends",
"binlog",
"events",
"to",
"the",
"provided",
"channel",
".",
"The",
"stream",
"will",
"c... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/binlog/slave_connection.go#L118-L128 | train |
vitessio/vitess | go/vt/binlog/slave_connection.go | streamEvents | func (sc *SlaveConnection) streamEvents(ctx context.Context) chan mysql.BinlogEvent {
// FIXME(alainjobart) I think we can use a buffered channel for better performance.
eventChan := make(chan mysql.BinlogEvent)
// Start reading events.
sc.wg.Add(1)
go func() {
defer func() {
close(eventChan)
sc.wg.Done()... | go | func (sc *SlaveConnection) streamEvents(ctx context.Context) chan mysql.BinlogEvent {
// FIXME(alainjobart) I think we can use a buffered channel for better performance.
eventChan := make(chan mysql.BinlogEvent)
// Start reading events.
sc.wg.Add(1)
go func() {
defer func() {
close(eventChan)
sc.wg.Done()... | [
"func",
"(",
"sc",
"*",
"SlaveConnection",
")",
"streamEvents",
"(",
"ctx",
"context",
".",
"Context",
")",
"chan",
"mysql",
".",
"BinlogEvent",
"{",
"// FIXME(alainjobart) I think we can use a buffered channel for better performance.",
"eventChan",
":=",
"make",
"(",
"... | // streamEvents returns a channel on which events are streamed. | [
"streamEvents",
"returns",
"a",
"channel",
"on",
"which",
"events",
"are",
"streamed",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/binlog/slave_connection.go#L131-L164 | train |
vitessio/vitess | go/vt/throttler/interval_history.go | average | func (h *intervalHistory) average(from, to time.Time) float64 {
// Search only entries whose time of observation is in [start, end).
// Example: [from, to) = [1.5s, 2.5s) => [start, end) = [1s, 2s)
start := from.Truncate(h.interval)
end := to.Truncate(h.interval)
sum := 0.0
count := 0.0
var nextIntervalStart ti... | go | func (h *intervalHistory) average(from, to time.Time) float64 {
// Search only entries whose time of observation is in [start, end).
// Example: [from, to) = [1.5s, 2.5s) => [start, end) = [1s, 2s)
start := from.Truncate(h.interval)
end := to.Truncate(h.interval)
sum := 0.0
count := 0.0
var nextIntervalStart ti... | [
"func",
"(",
"h",
"*",
"intervalHistory",
")",
"average",
"(",
"from",
",",
"to",
"time",
".",
"Time",
")",
"float64",
"{",
"// Search only entries whose time of observation is in [start, end).",
"// Example: [from, to) = [1.5s, 2.5s) => [start, end) = [1s, 2s)",
"start",
":=... | // average returns the average value across all observations which span
// the range [from, to).
// Partially included observations are accounted by their included fraction.
// Missing observations are assumed with the value zero. | [
"average",
"returns",
"the",
"average",
"value",
"across",
"all",
"observations",
"which",
"span",
"the",
"range",
"[",
"from",
"to",
")",
".",
"Partially",
"included",
"observations",
"are",
"accounted",
"by",
"their",
"included",
"fraction",
".",
"Missing",
... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/throttler/interval_history.go#L64-L106 | train |
vitessio/vitess | go/vt/vttime/time_clock.go | Now | func (t TimeClock) Now() (Interval, error) {
now := time.Now()
return NewInterval(now.Add(-(*uncertainty)), now.Add(*uncertainty))
} | go | func (t TimeClock) Now() (Interval, error) {
now := time.Now()
return NewInterval(now.Add(-(*uncertainty)), now.Add(*uncertainty))
} | [
"func",
"(",
"t",
"TimeClock",
")",
"Now",
"(",
")",
"(",
"Interval",
",",
"error",
")",
"{",
"now",
":=",
"time",
".",
"Now",
"(",
")",
"\n",
"return",
"NewInterval",
"(",
"now",
".",
"Add",
"(",
"-",
"(",
"*",
"uncertainty",
")",
")",
",",
"n... | // Now is part of the Clock interface. | [
"Now",
"is",
"part",
"of",
"the",
"Clock",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttime/time_clock.go#L33-L36 | train |
vitessio/vitess | go/vt/vttablet/tabletmanager/rpc_replication.go | SlaveStatus | func (agent *ActionAgent) SlaveStatus(ctx context.Context) (*replicationdatapb.Status, error) {
status, err := agent.MysqlDaemon.SlaveStatus()
if err != nil {
return nil, err
}
return mysql.SlaveStatusToProto(status), nil
} | go | func (agent *ActionAgent) SlaveStatus(ctx context.Context) (*replicationdatapb.Status, error) {
status, err := agent.MysqlDaemon.SlaveStatus()
if err != nil {
return nil, err
}
return mysql.SlaveStatusToProto(status), nil
} | [
"func",
"(",
"agent",
"*",
"ActionAgent",
")",
"SlaveStatus",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"*",
"replicationdatapb",
".",
"Status",
",",
"error",
")",
"{",
"status",
",",
"err",
":=",
"agent",
".",
"MysqlDaemon",
".",
"SlaveStatus",
"... | // SlaveStatus returns the replication status | [
"SlaveStatus",
"returns",
"the",
"replication",
"status"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletmanager/rpc_replication.go#L45-L51 | train |
vitessio/vitess | go/vt/vttablet/tabletmanager/rpc_replication.go | MasterPosition | func (agent *ActionAgent) MasterPosition(ctx context.Context) (string, error) {
pos, err := agent.MysqlDaemon.MasterPosition()
if err != nil {
return "", err
}
return mysql.EncodePosition(pos), nil
} | go | func (agent *ActionAgent) MasterPosition(ctx context.Context) (string, error) {
pos, err := agent.MysqlDaemon.MasterPosition()
if err != nil {
return "", err
}
return mysql.EncodePosition(pos), nil
} | [
"func",
"(",
"agent",
"*",
"ActionAgent",
")",
"MasterPosition",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"string",
",",
"error",
")",
"{",
"pos",
",",
"err",
":=",
"agent",
".",
"MysqlDaemon",
".",
"MasterPosition",
"(",
")",
"\n",
"if",
"err"... | // MasterPosition returns the master position | [
"MasterPosition",
"returns",
"the",
"master",
"position"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletmanager/rpc_replication.go#L54-L60 | train |
vitessio/vitess | go/vt/vttablet/tabletmanager/rpc_replication.go | StartSlaveUntilAfter | func (agent *ActionAgent) StartSlaveUntilAfter(ctx context.Context, position string, waitTime time.Duration) error {
if err := agent.lock(ctx); err != nil {
return err
}
defer agent.unlock()
waitCtx, cancel := context.WithTimeout(ctx, waitTime)
defer cancel()
pos, err := mysql.DecodePosition(position)
if err... | go | func (agent *ActionAgent) StartSlaveUntilAfter(ctx context.Context, position string, waitTime time.Duration) error {
if err := agent.lock(ctx); err != nil {
return err
}
defer agent.unlock()
waitCtx, cancel := context.WithTimeout(ctx, waitTime)
defer cancel()
pos, err := mysql.DecodePosition(position)
if err... | [
"func",
"(",
"agent",
"*",
"ActionAgent",
")",
"StartSlaveUntilAfter",
"(",
"ctx",
"context",
".",
"Context",
",",
"position",
"string",
",",
"waitTime",
"time",
".",
"Duration",
")",
"error",
"{",
"if",
"err",
":=",
"agent",
".",
"lock",
"(",
"ctx",
")"... | // StartSlaveUntilAfter will start the replication and let it catch up
// until and including the transactions in `position` | [
"StartSlaveUntilAfter",
"will",
"start",
"the",
"replication",
"and",
"let",
"it",
"catch",
"up",
"until",
"and",
"including",
"the",
"transactions",
"in",
"position"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletmanager/rpc_replication.go#L150-L165 | train |
vitessio/vitess | go/vt/vttablet/tabletmanager/rpc_replication.go | GetSlaves | func (agent *ActionAgent) GetSlaves(ctx context.Context) ([]string, error) {
return mysqlctl.FindSlaves(agent.MysqlDaemon)
} | go | func (agent *ActionAgent) GetSlaves(ctx context.Context) ([]string, error) {
return mysqlctl.FindSlaves(agent.MysqlDaemon)
} | [
"func",
"(",
"agent",
"*",
"ActionAgent",
")",
"GetSlaves",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"return",
"mysqlctl",
".",
"FindSlaves",
"(",
"agent",
".",
"MysqlDaemon",
")",
"\n",
"}"
] | // GetSlaves returns the address of all the slaves | [
"GetSlaves",
"returns",
"the",
"address",
"of",
"all",
"the",
"slaves"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletmanager/rpc_replication.go#L168-L170 | train |
vitessio/vitess | go/vt/vttablet/tabletmanager/rpc_replication.go | ResetReplication | func (agent *ActionAgent) ResetReplication(ctx context.Context) error {
if err := agent.lock(ctx); err != nil {
return err
}
defer agent.unlock()
agent.setSlaveStopped(true)
return agent.MysqlDaemon.ResetReplication(ctx)
} | go | func (agent *ActionAgent) ResetReplication(ctx context.Context) error {
if err := agent.lock(ctx); err != nil {
return err
}
defer agent.unlock()
agent.setSlaveStopped(true)
return agent.MysqlDaemon.ResetReplication(ctx)
} | [
"func",
"(",
"agent",
"*",
"ActionAgent",
")",
"ResetReplication",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"if",
"err",
":=",
"agent",
".",
"lock",
"(",
"ctx",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"... | // ResetReplication completely resets the replication on the host.
// All binary and relay logs are flushed. All replication positions are reset. | [
"ResetReplication",
"completely",
"resets",
"the",
"replication",
"on",
"the",
"host",
".",
"All",
"binary",
"and",
"relay",
"logs",
"are",
"flushed",
".",
"All",
"replication",
"positions",
"are",
"reset",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletmanager/rpc_replication.go#L174-L182 | train |
vitessio/vitess | go/vt/vttablet/tabletmanager/rpc_replication.go | InitMaster | func (agent *ActionAgent) InitMaster(ctx context.Context) (string, error) {
if err := agent.lock(ctx); err != nil {
return "", err
}
defer agent.unlock()
// Initializing as master implies undoing any previous "do not replicate".
agent.setSlaveStopped(false)
// we need to insert something in the binlogs, so we... | go | func (agent *ActionAgent) InitMaster(ctx context.Context) (string, error) {
if err := agent.lock(ctx); err != nil {
return "", err
}
defer agent.unlock()
// Initializing as master implies undoing any previous "do not replicate".
agent.setSlaveStopped(false)
// we need to insert something in the binlogs, so we... | [
"func",
"(",
"agent",
"*",
"ActionAgent",
")",
"InitMaster",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"err",
":=",
"agent",
".",
"lock",
"(",
"ctx",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"\"",
... | // InitMaster enables writes and returns the replication position. | [
"InitMaster",
"enables",
"writes",
"and",
"returns",
"the",
"replication",
"position",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletmanager/rpc_replication.go#L185-L235 | train |
vitessio/vitess | go/vt/vttablet/tabletmanager/rpc_replication.go | PopulateReparentJournal | func (agent *ActionAgent) PopulateReparentJournal(ctx context.Context, timeCreatedNS int64, actionName string, masterAlias *topodatapb.TabletAlias, position string) error {
pos, err := mysql.DecodePosition(position)
if err != nil {
return err
}
cmds := mysqlctl.CreateReparentJournal()
cmds = append(cmds, mysqlct... | go | func (agent *ActionAgent) PopulateReparentJournal(ctx context.Context, timeCreatedNS int64, actionName string, masterAlias *topodatapb.TabletAlias, position string) error {
pos, err := mysql.DecodePosition(position)
if err != nil {
return err
}
cmds := mysqlctl.CreateReparentJournal()
cmds = append(cmds, mysqlct... | [
"func",
"(",
"agent",
"*",
"ActionAgent",
")",
"PopulateReparentJournal",
"(",
"ctx",
"context",
".",
"Context",
",",
"timeCreatedNS",
"int64",
",",
"actionName",
"string",
",",
"masterAlias",
"*",
"topodatapb",
".",
"TabletAlias",
",",
"position",
"string",
")"... | // PopulateReparentJournal adds an entry into the reparent_journal table. | [
"PopulateReparentJournal",
"adds",
"an",
"entry",
"into",
"the",
"reparent_journal",
"table",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletmanager/rpc_replication.go#L238-L247 | train |
vitessio/vitess | go/vt/vttablet/tabletmanager/rpc_replication.go | InitSlave | func (agent *ActionAgent) InitSlave(ctx context.Context, parent *topodatapb.TabletAlias, position string, timeCreatedNS int64) error {
if err := agent.lock(ctx); err != nil {
return err
}
defer agent.unlock()
pos, err := mysql.DecodePosition(position)
if err != nil {
return err
}
ti, err := agent.TopoServer... | go | func (agent *ActionAgent) InitSlave(ctx context.Context, parent *topodatapb.TabletAlias, position string, timeCreatedNS int64) error {
if err := agent.lock(ctx); err != nil {
return err
}
defer agent.unlock()
pos, err := mysql.DecodePosition(position)
if err != nil {
return err
}
ti, err := agent.TopoServer... | [
"func",
"(",
"agent",
"*",
"ActionAgent",
")",
"InitSlave",
"(",
"ctx",
"context",
".",
"Context",
",",
"parent",
"*",
"topodatapb",
".",
"TabletAlias",
",",
"position",
"string",
",",
"timeCreatedNS",
"int64",
")",
"error",
"{",
"if",
"err",
":=",
"agent"... | // InitSlave sets replication master and position, and waits for the
// reparent_journal table entry up to context timeout | [
"InitSlave",
"sets",
"replication",
"master",
"and",
"position",
"and",
"waits",
"for",
"the",
"reparent_journal",
"table",
"entry",
"up",
"to",
"context",
"timeout"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletmanager/rpc_replication.go#L251-L302 | train |
vitessio/vitess | go/vt/vttablet/tabletmanager/rpc_replication.go | DemoteMaster | func (agent *ActionAgent) DemoteMaster(ctx context.Context) (string, error) {
if err := agent.lock(ctx); err != nil {
return "", err
}
defer agent.unlock()
// Tell Orchestrator we're stopped on purpose the demotion.
// This is a best effort task, so run it in a goroutine.
go func() {
if agent.orc == nil {
... | go | func (agent *ActionAgent) DemoteMaster(ctx context.Context) (string, error) {
if err := agent.lock(ctx); err != nil {
return "", err
}
defer agent.unlock()
// Tell Orchestrator we're stopped on purpose the demotion.
// This is a best effort task, so run it in a goroutine.
go func() {
if agent.orc == nil {
... | [
"func",
"(",
"agent",
"*",
"ActionAgent",
")",
"DemoteMaster",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"err",
":=",
"agent",
".",
"lock",
"(",
"ctx",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"\""... | // DemoteMaster marks the server read-only, wait until it is done with
// its current transactions, and returns its master position. | [
"DemoteMaster",
"marks",
"the",
"server",
"read",
"-",
"only",
"wait",
"until",
"it",
"is",
"done",
"with",
"its",
"current",
"transactions",
"and",
"returns",
"its",
"master",
"position",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletmanager/rpc_replication.go#L306-L390 | train |
vitessio/vitess | go/vt/vttablet/tabletmanager/rpc_replication.go | UndoDemoteMaster | func (agent *ActionAgent) UndoDemoteMaster(ctx context.Context) error {
if err := agent.lock(ctx); err != nil {
return err
}
defer agent.unlock()
// If using semi-sync, we need to enable master-side.
if err := agent.fixSemiSync(topodatapb.TabletType_MASTER); err != nil {
return err
}
// Now, set the server... | go | func (agent *ActionAgent) UndoDemoteMaster(ctx context.Context) error {
if err := agent.lock(ctx); err != nil {
return err
}
defer agent.unlock()
// If using semi-sync, we need to enable master-side.
if err := agent.fixSemiSync(topodatapb.TabletType_MASTER); err != nil {
return err
}
// Now, set the server... | [
"func",
"(",
"agent",
"*",
"ActionAgent",
")",
"UndoDemoteMaster",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"if",
"err",
":=",
"agent",
".",
"lock",
"(",
"ctx",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"... | // UndoDemoteMaster reverts a previous call to DemoteMaster
// it sets read-only to false, fixes semi-sync
// and returns its master position. | [
"UndoDemoteMaster",
"reverts",
"a",
"previous",
"call",
"to",
"DemoteMaster",
"it",
"sets",
"read",
"-",
"only",
"to",
"false",
"fixes",
"semi",
"-",
"sync",
"and",
"returns",
"its",
"master",
"position",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletmanager/rpc_replication.go#L395-L419 | train |
vitessio/vitess | go/vt/vttablet/tabletmanager/rpc_replication.go | SlaveWasPromoted | func (agent *ActionAgent) SlaveWasPromoted(ctx context.Context) error {
if err := agent.lock(ctx); err != nil {
return err
}
defer agent.unlock()
if _, err := topotools.ChangeType(ctx, agent.TopoServer, agent.TabletAlias, topodatapb.TabletType_MASTER); err != nil {
return err
}
if err := agent.refreshTablet... | go | func (agent *ActionAgent) SlaveWasPromoted(ctx context.Context) error {
if err := agent.lock(ctx); err != nil {
return err
}
defer agent.unlock()
if _, err := topotools.ChangeType(ctx, agent.TopoServer, agent.TabletAlias, topodatapb.TabletType_MASTER); err != nil {
return err
}
if err := agent.refreshTablet... | [
"func",
"(",
"agent",
"*",
"ActionAgent",
")",
"SlaveWasPromoted",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"if",
"err",
":=",
"agent",
".",
"lock",
"(",
"ctx",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"... | // SlaveWasPromoted promotes a slave to master, no questions asked. | [
"SlaveWasPromoted",
"promotes",
"a",
"slave",
"to",
"master",
"no",
"questions",
"asked",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletmanager/rpc_replication.go#L467-L482 | train |
vitessio/vitess | go/vt/vttablet/tabletmanager/rpc_replication.go | SetMaster | func (agent *ActionAgent) SetMaster(ctx context.Context, parentAlias *topodatapb.TabletAlias, timeCreatedNS int64, forceStartSlave bool) error {
if err := agent.lock(ctx); err != nil {
return err
}
defer agent.unlock()
return agent.setMasterLocked(ctx, parentAlias, timeCreatedNS, forceStartSlave)
} | go | func (agent *ActionAgent) SetMaster(ctx context.Context, parentAlias *topodatapb.TabletAlias, timeCreatedNS int64, forceStartSlave bool) error {
if err := agent.lock(ctx); err != nil {
return err
}
defer agent.unlock()
return agent.setMasterLocked(ctx, parentAlias, timeCreatedNS, forceStartSlave)
} | [
"func",
"(",
"agent",
"*",
"ActionAgent",
")",
"SetMaster",
"(",
"ctx",
"context",
".",
"Context",
",",
"parentAlias",
"*",
"topodatapb",
".",
"TabletAlias",
",",
"timeCreatedNS",
"int64",
",",
"forceStartSlave",
"bool",
")",
"error",
"{",
"if",
"err",
":=",... | // SetMaster sets replication master, and waits for the
// reparent_journal table entry up to context timeout | [
"SetMaster",
"sets",
"replication",
"master",
"and",
"waits",
"for",
"the",
"reparent_journal",
"table",
"entry",
"up",
"to",
"context",
"timeout"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletmanager/rpc_replication.go#L486-L493 | train |
vitessio/vitess | go/vt/vttablet/tabletmanager/rpc_replication.go | SlaveWasRestarted | func (agent *ActionAgent) SlaveWasRestarted(ctx context.Context, parent *topodatapb.TabletAlias) error {
if err := agent.lock(ctx); err != nil {
return err
}
defer agent.unlock()
typeChanged := false
// Once this action completes, update authoritative tablet node first.
if _, err := agent.TopoServer.UpdateTab... | go | func (agent *ActionAgent) SlaveWasRestarted(ctx context.Context, parent *topodatapb.TabletAlias) error {
if err := agent.lock(ctx); err != nil {
return err
}
defer agent.unlock()
typeChanged := false
// Once this action completes, update authoritative tablet node first.
if _, err := agent.TopoServer.UpdateTab... | [
"func",
"(",
"agent",
"*",
"ActionAgent",
")",
"SlaveWasRestarted",
"(",
"ctx",
"context",
".",
"Context",
",",
"parent",
"*",
"topodatapb",
".",
"TabletAlias",
")",
"error",
"{",
"if",
"err",
":=",
"agent",
".",
"lock",
"(",
"ctx",
")",
";",
"err",
"!... | // SlaveWasRestarted updates the parent record for a tablet. | [
"SlaveWasRestarted",
"updates",
"the",
"parent",
"record",
"for",
"a",
"tablet",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletmanager/rpc_replication.go#L590-L617 | train |
vitessio/vitess | go/vt/vttablet/tabletmanager/rpc_replication.go | StopReplicationAndGetStatus | func (agent *ActionAgent) StopReplicationAndGetStatus(ctx context.Context) (*replicationdatapb.Status, error) {
if err := agent.lock(ctx); err != nil {
return nil, err
}
defer agent.unlock()
// get the status before we stop replication
rs, err := agent.MysqlDaemon.SlaveStatus()
if err != nil {
return nil, vt... | go | func (agent *ActionAgent) StopReplicationAndGetStatus(ctx context.Context) (*replicationdatapb.Status, error) {
if err := agent.lock(ctx); err != nil {
return nil, err
}
defer agent.unlock()
// get the status before we stop replication
rs, err := agent.MysqlDaemon.SlaveStatus()
if err != nil {
return nil, vt... | [
"func",
"(",
"agent",
"*",
"ActionAgent",
")",
"StopReplicationAndGetStatus",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"*",
"replicationdatapb",
".",
"Status",
",",
"error",
")",
"{",
"if",
"err",
":=",
"agent",
".",
"lock",
"(",
"ctx",
")",
";",... | // StopReplicationAndGetStatus stops MySQL replication, and returns the
// current status. | [
"StopReplicationAndGetStatus",
"stops",
"MySQL",
"replication",
"and",
"returns",
"the",
"current",
"status",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletmanager/rpc_replication.go#L621-L645 | train |
vitessio/vitess | go/vt/vttablet/tabletmanager/rpc_replication.go | PromoteSlave | func (agent *ActionAgent) PromoteSlave(ctx context.Context) (string, error) {
if err := agent.lock(ctx); err != nil {
return "", err
}
defer agent.unlock()
pos, err := agent.MysqlDaemon.PromoteSlave(agent.hookExtraEnv())
if err != nil {
return "", err
}
// If using semi-sync, we need to enable it before go... | go | func (agent *ActionAgent) PromoteSlave(ctx context.Context) (string, error) {
if err := agent.lock(ctx); err != nil {
return "", err
}
defer agent.unlock()
pos, err := agent.MysqlDaemon.PromoteSlave(agent.hookExtraEnv())
if err != nil {
return "", err
}
// If using semi-sync, we need to enable it before go... | [
"func",
"(",
"agent",
"*",
"ActionAgent",
")",
"PromoteSlave",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"err",
":=",
"agent",
".",
"lock",
"(",
"ctx",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"\""... | // PromoteSlave makes the current tablet the master | [
"PromoteSlave",
"makes",
"the",
"current",
"tablet",
"the",
"master"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletmanager/rpc_replication.go#L648-L680 | train |
vitessio/vitess | go/vt/wrangler/reparent.go | ShardReplicationStatuses | func (wr *Wrangler) ShardReplicationStatuses(ctx context.Context, keyspace, shard string) ([]*topo.TabletInfo, []*replicationdatapb.Status, error) {
tabletMap, err := wr.ts.GetTabletMapForShard(ctx, keyspace, shard)
if err != nil {
return nil, nil, err
}
tablets := topotools.CopyMapValues(tabletMap, []*topo.Table... | go | func (wr *Wrangler) ShardReplicationStatuses(ctx context.Context, keyspace, shard string) ([]*topo.TabletInfo, []*replicationdatapb.Status, error) {
tabletMap, err := wr.ts.GetTabletMapForShard(ctx, keyspace, shard)
if err != nil {
return nil, nil, err
}
tablets := topotools.CopyMapValues(tabletMap, []*topo.Table... | [
"func",
"(",
"wr",
"*",
"Wrangler",
")",
"ShardReplicationStatuses",
"(",
"ctx",
"context",
".",
"Context",
",",
"keyspace",
",",
"shard",
"string",
")",
"(",
"[",
"]",
"*",
"topo",
".",
"TabletInfo",
",",
"[",
"]",
"*",
"replicationdatapb",
".",
"Status... | // ShardReplicationStatuses returns the ReplicationStatus for each tablet in a shard. | [
"ShardReplicationStatuses",
"returns",
"the",
"ReplicationStatus",
"for",
"each",
"tablet",
"in",
"a",
"shard",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/wrangler/reparent.go#L50-L93 | train |
vitessio/vitess | go/vt/wrangler/reparent.go | ReparentTablet | func (wr *Wrangler) ReparentTablet(ctx context.Context, tabletAlias *topodatapb.TabletAlias) error {
// Get specified tablet.
// Get current shard master tablet.
// Sanity check they are in the same keyspace/shard.
// Issue a SetMaster to the tablet.
ti, err := wr.ts.GetTablet(ctx, tabletAlias)
if err != nil {
... | go | func (wr *Wrangler) ReparentTablet(ctx context.Context, tabletAlias *topodatapb.TabletAlias) error {
// Get specified tablet.
// Get current shard master tablet.
// Sanity check they are in the same keyspace/shard.
// Issue a SetMaster to the tablet.
ti, err := wr.ts.GetTablet(ctx, tabletAlias)
if err != nil {
... | [
"func",
"(",
"wr",
"*",
"Wrangler",
")",
"ReparentTablet",
"(",
"ctx",
"context",
".",
"Context",
",",
"tabletAlias",
"*",
"topodatapb",
".",
"TabletAlias",
")",
"error",
"{",
"// Get specified tablet.",
"// Get current shard master tablet.",
"// Sanity check they are i... | // ReparentTablet tells a tablet to reparent this tablet to the current
// master, based on the current replication position. If there is no
// match, it will fail. | [
"ReparentTablet",
"tells",
"a",
"tablet",
"to",
"reparent",
"this",
"tablet",
"to",
"the",
"current",
"master",
"based",
"on",
"the",
"current",
"replication",
"position",
".",
"If",
"there",
"is",
"no",
"match",
"it",
"will",
"fail",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/wrangler/reparent.go#L98-L131 | train |
vitessio/vitess | go/vt/wrangler/reparent.go | PlannedReparentShard | func (wr *Wrangler) PlannedReparentShard(ctx context.Context, keyspace, shard string, masterElectTabletAlias, avoidMasterAlias *topodatapb.TabletAlias, waitSlaveTimeout time.Duration) (err error) {
// lock the shard
lockAction := fmt.Sprintf(
"PlannedReparentShard(%v, avoid_master=%v)",
topoproto.TabletAliasStrin... | go | func (wr *Wrangler) PlannedReparentShard(ctx context.Context, keyspace, shard string, masterElectTabletAlias, avoidMasterAlias *topodatapb.TabletAlias, waitSlaveTimeout time.Duration) (err error) {
// lock the shard
lockAction := fmt.Sprintf(
"PlannedReparentShard(%v, avoid_master=%v)",
topoproto.TabletAliasStrin... | [
"func",
"(",
"wr",
"*",
"Wrangler",
")",
"PlannedReparentShard",
"(",
"ctx",
"context",
".",
"Context",
",",
"keyspace",
",",
"shard",
"string",
",",
"masterElectTabletAlias",
",",
"avoidMasterAlias",
"*",
"topodatapb",
".",
"TabletAlias",
",",
"waitSlaveTimeout",... | // PlannedReparentShard will make the provided tablet the master for the shard,
// when both the current and new master are reachable and in good shape. | [
"PlannedReparentShard",
"will",
"make",
"the",
"provided",
"tablet",
"the",
"master",
"for",
"the",
"shard",
"when",
"both",
"the",
"current",
"and",
"new",
"master",
"are",
"reachable",
"and",
"in",
"good",
"shape",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/wrangler/reparent.go#L331-L363 | train |
vitessio/vitess | go/vt/wrangler/reparent.go | EmergencyReparentShard | func (wr *Wrangler) EmergencyReparentShard(ctx context.Context, keyspace, shard string, masterElectTabletAlias *topodatapb.TabletAlias, waitSlaveTimeout time.Duration) (err error) {
// lock the shard
ctx, unlock, lockErr := wr.ts.LockShard(ctx, keyspace, shard, fmt.Sprintf("EmergencyReparentShard(%v)", topoproto.Tabl... | go | func (wr *Wrangler) EmergencyReparentShard(ctx context.Context, keyspace, shard string, masterElectTabletAlias *topodatapb.TabletAlias, waitSlaveTimeout time.Duration) (err error) {
// lock the shard
ctx, unlock, lockErr := wr.ts.LockShard(ctx, keyspace, shard, fmt.Sprintf("EmergencyReparentShard(%v)", topoproto.Tabl... | [
"func",
"(",
"wr",
"*",
"Wrangler",
")",
"EmergencyReparentShard",
"(",
"ctx",
"context",
".",
"Context",
",",
"keyspace",
",",
"shard",
"string",
",",
"masterElectTabletAlias",
"*",
"topodatapb",
".",
"TabletAlias",
",",
"waitSlaveTimeout",
"time",
".",
"Durati... | // EmergencyReparentShard will make the provided tablet the master for
// the shard, when the old master is completely unreachable. | [
"EmergencyReparentShard",
"will",
"make",
"the",
"provided",
"tablet",
"the",
"master",
"for",
"the",
"shard",
"when",
"the",
"old",
"master",
"is",
"completely",
"unreachable",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/wrangler/reparent.go#L606-L625 | train |
vitessio/vitess | go/vt/vttablet/tabletserver/messager/engine.go | Subscribe | func (me *Engine) Subscribe(ctx context.Context, name string, send func(*sqltypes.Result) error) (done <-chan struct{}, err error) {
me.mu.Lock()
defer me.mu.Unlock()
if !me.isOpen {
return nil, vterrors.Errorf(vtrpcpb.Code_UNAVAILABLE, "messager engine is closed, probably because this is not a master any more")
... | go | func (me *Engine) Subscribe(ctx context.Context, name string, send func(*sqltypes.Result) error) (done <-chan struct{}, err error) {
me.mu.Lock()
defer me.mu.Unlock()
if !me.isOpen {
return nil, vterrors.Errorf(vtrpcpb.Code_UNAVAILABLE, "messager engine is closed, probably because this is not a master any more")
... | [
"func",
"(",
"me",
"*",
"Engine",
")",
"Subscribe",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
",",
"send",
"func",
"(",
"*",
"sqltypes",
".",
"Result",
")",
"error",
")",
"(",
"done",
"<-",
"chan",
"struct",
"{",
"}",
",",
"err"... | // Subscribe subscribes to messages from the requested table.
// The function returns a done channel that will be closed when
// the subscription ends, which can be initiated by the send function
// returning io.EOF. The engine can also end a subscription which is
// usually triggered by Close. It's the responsibility ... | [
"Subscribe",
"subscribes",
"to",
"messages",
"from",
"the",
"requested",
"table",
".",
"The",
"function",
"returns",
"a",
"done",
"channel",
"that",
"will",
"be",
"closed",
"when",
"the",
"subscription",
"ends",
"which",
"can",
"be",
"initiated",
"by",
"the",
... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/messager/engine.go#L117-L128 | train |
vitessio/vitess | go/vt/vttablet/tabletserver/messager/engine.go | LockDB | func (me *Engine) LockDB(newMessages map[string][]*MessageRow, changedMessages map[string][]string) func() {
// Short-circuit to avoid taking any locks if there's nothing to do.
if len(newMessages) == 0 && len(changedMessages) == 0 {
return func() {}
}
// Build the set of affected messages tables.
combined := m... | go | func (me *Engine) LockDB(newMessages map[string][]*MessageRow, changedMessages map[string][]string) func() {
// Short-circuit to avoid taking any locks if there's nothing to do.
if len(newMessages) == 0 && len(changedMessages) == 0 {
return func() {}
}
// Build the set of affected messages tables.
combined := m... | [
"func",
"(",
"me",
"*",
"Engine",
")",
"LockDB",
"(",
"newMessages",
"map",
"[",
"string",
"]",
"[",
"]",
"*",
"MessageRow",
",",
"changedMessages",
"map",
"[",
"string",
"]",
"[",
"]",
"string",
")",
"func",
"(",
")",
"{",
"// Short-circuit to avoid tak... | // LockDB obtains db locks for all messages that need to
// be updated and returns the counterpart unlock function. | [
"LockDB",
"obtains",
"db",
"locks",
"for",
"all",
"messages",
"that",
"need",
"to",
"be",
"updated",
"and",
"returns",
"the",
"counterpart",
"unlock",
"function",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/messager/engine.go#L132-L178 | train |
vitessio/vitess | go/vt/vttablet/tabletserver/messager/engine.go | UpdateCaches | func (me *Engine) UpdateCaches(newMessages map[string][]*MessageRow, changedMessages map[string][]string) {
// Short-circuit to avoid taking any locks if there's nothing to do.
if len(newMessages) == 0 && len(changedMessages) == 0 {
return
}
me.mu.Lock()
defer me.mu.Unlock()
now := time.Now().UnixNano()
for n... | go | func (me *Engine) UpdateCaches(newMessages map[string][]*MessageRow, changedMessages map[string][]string) {
// Short-circuit to avoid taking any locks if there's nothing to do.
if len(newMessages) == 0 && len(changedMessages) == 0 {
return
}
me.mu.Lock()
defer me.mu.Unlock()
now := time.Now().UnixNano()
for n... | [
"func",
"(",
"me",
"*",
"Engine",
")",
"UpdateCaches",
"(",
"newMessages",
"map",
"[",
"string",
"]",
"[",
"]",
"*",
"MessageRow",
",",
"changedMessages",
"map",
"[",
"string",
"]",
"[",
"]",
"string",
")",
"{",
"// Short-circuit to avoid taking any locks if t... | // UpdateCaches updates the caches for the committed changes. | [
"UpdateCaches",
"updates",
"the",
"caches",
"for",
"the",
"committed",
"changes",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/messager/engine.go#L181-L211 | train |
vitessio/vitess | go/vt/vttablet/tabletserver/messager/engine.go | GenerateLoadMessagesQuery | func (me *Engine) GenerateLoadMessagesQuery(name string) (*sqlparser.ParsedQuery, error) {
me.mu.Lock()
defer me.mu.Unlock()
mm := me.managers[name]
if mm == nil {
return nil, vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "message table %s not found in schema", name)
}
return mm.loadMessagesQuery, nil
} | go | func (me *Engine) GenerateLoadMessagesQuery(name string) (*sqlparser.ParsedQuery, error) {
me.mu.Lock()
defer me.mu.Unlock()
mm := me.managers[name]
if mm == nil {
return nil, vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "message table %s not found in schema", name)
}
return mm.loadMessagesQuery, nil
} | [
"func",
"(",
"me",
"*",
"Engine",
")",
"GenerateLoadMessagesQuery",
"(",
"name",
"string",
")",
"(",
"*",
"sqlparser",
".",
"ParsedQuery",
",",
"error",
")",
"{",
"me",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"me",
".",
"mu",
".",
"Unlock",
... | // GenerateLoadMessagesQuery returns the ParsedQuery for loading messages by pk.
// The results of the query can be used in a BuildMessageRow call. | [
"GenerateLoadMessagesQuery",
"returns",
"the",
"ParsedQuery",
"for",
"loading",
"messages",
"by",
"pk",
".",
"The",
"results",
"of",
"the",
"query",
"can",
"be",
"used",
"in",
"a",
"BuildMessageRow",
"call",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/messager/engine.go#L215-L223 | train |
vitessio/vitess | go/vt/topo/zk2topo/zk_conn.go | Connect | func Connect(addr string) *ZkConn {
return &ZkConn{
addr: addr,
sem: sync2.NewSemaphore(*maxConcurrency, 0),
}
} | go | func Connect(addr string) *ZkConn {
return &ZkConn{
addr: addr,
sem: sync2.NewSemaphore(*maxConcurrency, 0),
}
} | [
"func",
"Connect",
"(",
"addr",
"string",
")",
"*",
"ZkConn",
"{",
"return",
"&",
"ZkConn",
"{",
"addr",
":",
"addr",
",",
"sem",
":",
"sync2",
".",
"NewSemaphore",
"(",
"*",
"maxConcurrency",
",",
"0",
")",
",",
"}",
"\n",
"}"
] | // Connect to the Zookeeper servers specified in addr
// addr can be a comma separated list of servers and each server can be a DNS entry with multiple values.
// Connects to the endpoints in a randomized order to avoid hot spots. | [
"Connect",
"to",
"the",
"Zookeeper",
"servers",
"specified",
"in",
"addr",
"addr",
"can",
"be",
"a",
"comma",
"separated",
"list",
"of",
"servers",
"and",
"each",
"server",
"can",
"be",
"a",
"DNS",
"entry",
"with",
"multiple",
"values",
".",
"Connects",
"t... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/zk2topo/zk_conn.go#L96-L101 | train |
vitessio/vitess | go/vt/topo/zk2topo/zk_conn.go | Get | func (c *ZkConn) Get(ctx context.Context, path string) (data []byte, stat *zk.Stat, err error) {
err = c.withRetry(ctx, func(conn *zk.Conn) error {
data, stat, err = conn.Get(path)
return err
})
return
} | go | func (c *ZkConn) Get(ctx context.Context, path string) (data []byte, stat *zk.Stat, err error) {
err = c.withRetry(ctx, func(conn *zk.Conn) error {
data, stat, err = conn.Get(path)
return err
})
return
} | [
"func",
"(",
"c",
"*",
"ZkConn",
")",
"Get",
"(",
"ctx",
"context",
".",
"Context",
",",
"path",
"string",
")",
"(",
"data",
"[",
"]",
"byte",
",",
"stat",
"*",
"zk",
".",
"Stat",
",",
"err",
"error",
")",
"{",
"err",
"=",
"c",
".",
"withRetry"... | // Get is part of the Conn interface. | [
"Get",
"is",
"part",
"of",
"the",
"Conn",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/zk2topo/zk_conn.go#L104-L110 | train |
vitessio/vitess | go/vt/topo/zk2topo/zk_conn.go | Children | func (c *ZkConn) Children(ctx context.Context, path string) (children []string, stat *zk.Stat, err error) {
err = c.withRetry(ctx, func(conn *zk.Conn) error {
children, stat, err = conn.Children(path)
return err
})
return
} | go | func (c *ZkConn) Children(ctx context.Context, path string) (children []string, stat *zk.Stat, err error) {
err = c.withRetry(ctx, func(conn *zk.Conn) error {
children, stat, err = conn.Children(path)
return err
})
return
} | [
"func",
"(",
"c",
"*",
"ZkConn",
")",
"Children",
"(",
"ctx",
"context",
".",
"Context",
",",
"path",
"string",
")",
"(",
"children",
"[",
"]",
"string",
",",
"stat",
"*",
"zk",
".",
"Stat",
",",
"err",
"error",
")",
"{",
"err",
"=",
"c",
".",
... | // Children is part of the Conn interface. | [
"Children",
"is",
"part",
"of",
"the",
"Conn",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/zk2topo/zk_conn.go#L122-L128 | train |
vitessio/vitess | go/vt/topo/zk2topo/zk_conn.go | Exists | func (c *ZkConn) Exists(ctx context.Context, path string) (exists bool, stat *zk.Stat, err error) {
err = c.withRetry(ctx, func(conn *zk.Conn) error {
exists, stat, err = conn.Exists(path)
return err
})
return
} | go | func (c *ZkConn) Exists(ctx context.Context, path string) (exists bool, stat *zk.Stat, err error) {
err = c.withRetry(ctx, func(conn *zk.Conn) error {
exists, stat, err = conn.Exists(path)
return err
})
return
} | [
"func",
"(",
"c",
"*",
"ZkConn",
")",
"Exists",
"(",
"ctx",
"context",
".",
"Context",
",",
"path",
"string",
")",
"(",
"exists",
"bool",
",",
"stat",
"*",
"zk",
".",
"Stat",
",",
"err",
"error",
")",
"{",
"err",
"=",
"c",
".",
"withRetry",
"(",
... | // Exists is part of the Conn interface. | [
"Exists",
"is",
"part",
"of",
"the",
"Conn",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/zk2topo/zk_conn.go#L140-L146 | train |
vitessio/vitess | go/vt/topo/zk2topo/zk_conn.go | Create | func (c *ZkConn) Create(ctx context.Context, path string, value []byte, flags int32, aclv []zk.ACL) (pathCreated string, err error) {
err = c.withRetry(ctx, func(conn *zk.Conn) error {
pathCreated, err = conn.Create(path, value, flags, aclv)
return err
})
return
} | go | func (c *ZkConn) Create(ctx context.Context, path string, value []byte, flags int32, aclv []zk.ACL) (pathCreated string, err error) {
err = c.withRetry(ctx, func(conn *zk.Conn) error {
pathCreated, err = conn.Create(path, value, flags, aclv)
return err
})
return
} | [
"func",
"(",
"c",
"*",
"ZkConn",
")",
"Create",
"(",
"ctx",
"context",
".",
"Context",
",",
"path",
"string",
",",
"value",
"[",
"]",
"byte",
",",
"flags",
"int32",
",",
"aclv",
"[",
"]",
"zk",
".",
"ACL",
")",
"(",
"pathCreated",
"string",
",",
... | // Create is part of the Conn interface. | [
"Create",
"is",
"part",
"of",
"the",
"Conn",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/zk2topo/zk_conn.go#L158-L164 | train |
vitessio/vitess | go/vt/topo/zk2topo/zk_conn.go | Set | func (c *ZkConn) Set(ctx context.Context, path string, value []byte, version int32) (stat *zk.Stat, err error) {
err = c.withRetry(ctx, func(conn *zk.Conn) error {
stat, err = conn.Set(path, value, version)
return err
})
return
} | go | func (c *ZkConn) Set(ctx context.Context, path string, value []byte, version int32) (stat *zk.Stat, err error) {
err = c.withRetry(ctx, func(conn *zk.Conn) error {
stat, err = conn.Set(path, value, version)
return err
})
return
} | [
"func",
"(",
"c",
"*",
"ZkConn",
")",
"Set",
"(",
"ctx",
"context",
".",
"Context",
",",
"path",
"string",
",",
"value",
"[",
"]",
"byte",
",",
"version",
"int32",
")",
"(",
"stat",
"*",
"zk",
".",
"Stat",
",",
"err",
"error",
")",
"{",
"err",
... | // Set is part of the Conn interface. | [
"Set",
"is",
"part",
"of",
"the",
"Conn",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/zk2topo/zk_conn.go#L167-L173 | train |
vitessio/vitess | go/vt/topo/zk2topo/zk_conn.go | Delete | func (c *ZkConn) Delete(ctx context.Context, path string, version int32) error {
return c.withRetry(ctx, func(conn *zk.Conn) error {
return conn.Delete(path, version)
})
} | go | func (c *ZkConn) Delete(ctx context.Context, path string, version int32) error {
return c.withRetry(ctx, func(conn *zk.Conn) error {
return conn.Delete(path, version)
})
} | [
"func",
"(",
"c",
"*",
"ZkConn",
")",
"Delete",
"(",
"ctx",
"context",
".",
"Context",
",",
"path",
"string",
",",
"version",
"int32",
")",
"error",
"{",
"return",
"c",
".",
"withRetry",
"(",
"ctx",
",",
"func",
"(",
"conn",
"*",
"zk",
".",
"Conn",... | // Delete is part of the Conn interface. | [
"Delete",
"is",
"part",
"of",
"the",
"Conn",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/zk2topo/zk_conn.go#L176-L180 | train |
vitessio/vitess | go/vt/topo/zk2topo/zk_conn.go | GetACL | func (c *ZkConn) GetACL(ctx context.Context, path string) (aclv []zk.ACL, stat *zk.Stat, err error) {
err = c.withRetry(ctx, func(conn *zk.Conn) error {
aclv, stat, err = conn.GetACL(path)
return err
})
return
} | go | func (c *ZkConn) GetACL(ctx context.Context, path string) (aclv []zk.ACL, stat *zk.Stat, err error) {
err = c.withRetry(ctx, func(conn *zk.Conn) error {
aclv, stat, err = conn.GetACL(path)
return err
})
return
} | [
"func",
"(",
"c",
"*",
"ZkConn",
")",
"GetACL",
"(",
"ctx",
"context",
".",
"Context",
",",
"path",
"string",
")",
"(",
"aclv",
"[",
"]",
"zk",
".",
"ACL",
",",
"stat",
"*",
"zk",
".",
"Stat",
",",
"err",
"error",
")",
"{",
"err",
"=",
"c",
"... | // GetACL is part of the Conn interface. | [
"GetACL",
"is",
"part",
"of",
"the",
"Conn",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/zk2topo/zk_conn.go#L183-L189 | train |
vitessio/vitess | go/vt/topo/zk2topo/zk_conn.go | SetACL | func (c *ZkConn) SetACL(ctx context.Context, path string, aclv []zk.ACL, version int32) error {
return c.withRetry(ctx, func(conn *zk.Conn) error {
_, err := conn.SetACL(path, aclv, version)
return err
})
} | go | func (c *ZkConn) SetACL(ctx context.Context, path string, aclv []zk.ACL, version int32) error {
return c.withRetry(ctx, func(conn *zk.Conn) error {
_, err := conn.SetACL(path, aclv, version)
return err
})
} | [
"func",
"(",
"c",
"*",
"ZkConn",
")",
"SetACL",
"(",
"ctx",
"context",
".",
"Context",
",",
"path",
"string",
",",
"aclv",
"[",
"]",
"zk",
".",
"ACL",
",",
"version",
"int32",
")",
"error",
"{",
"return",
"c",
".",
"withRetry",
"(",
"ctx",
",",
"... | // SetACL is part of the Conn interface. | [
"SetACL",
"is",
"part",
"of",
"the",
"Conn",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/zk2topo/zk_conn.go#L192-L197 | train |
vitessio/vitess | go/vt/topo/zk2topo/zk_conn.go | AddAuth | func (c *ZkConn) AddAuth(ctx context.Context, scheme string, auth []byte) error {
return c.withRetry(ctx, func(conn *zk.Conn) error {
err := conn.AddAuth(scheme, auth)
return err
})
} | go | func (c *ZkConn) AddAuth(ctx context.Context, scheme string, auth []byte) error {
return c.withRetry(ctx, func(conn *zk.Conn) error {
err := conn.AddAuth(scheme, auth)
return err
})
} | [
"func",
"(",
"c",
"*",
"ZkConn",
")",
"AddAuth",
"(",
"ctx",
"context",
".",
"Context",
",",
"scheme",
"string",
",",
"auth",
"[",
"]",
"byte",
")",
"error",
"{",
"return",
"c",
".",
"withRetry",
"(",
"ctx",
",",
"func",
"(",
"conn",
"*",
"zk",
"... | // AddAuth is part of the Conn interface. | [
"AddAuth",
"is",
"part",
"of",
"the",
"Conn",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/zk2topo/zk_conn.go#L200-L205 | train |
vitessio/vitess | go/vt/topo/zk2topo/zk_conn.go | Close | func (c *ZkConn) Close() error {
c.mu.Lock()
defer c.mu.Unlock()
if c.conn != nil {
c.conn.Close()
}
return nil
} | go | func (c *ZkConn) Close() error {
c.mu.Lock()
defer c.mu.Unlock()
if c.conn != nil {
c.conn.Close()
}
return nil
} | [
"func",
"(",
"c",
"*",
"ZkConn",
")",
"Close",
"(",
")",
"error",
"{",
"c",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"if",
"c",
".",
"conn",
"!=",
"nil",
"{",
"c",
".",
"conn",
".",
"... | // Close is part of the Conn interface. | [
"Close",
"is",
"part",
"of",
"the",
"Conn",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/zk2topo/zk_conn.go#L208-L215 | train |
vitessio/vitess | go/vt/topo/zk2topo/zk_conn.go | getConn | func (c *ZkConn) getConn(ctx context.Context) (*zk.Conn, error) {
c.mu.Lock()
defer c.mu.Unlock()
if c.conn == nil {
conn, events, err := dialZk(ctx, c.addr)
if err != nil {
return nil, err
}
c.conn = conn
go c.handleSessionEvents(conn, events)
c.maybeAddAuth(ctx)
}
return c.conn, nil
} | go | func (c *ZkConn) getConn(ctx context.Context) (*zk.Conn, error) {
c.mu.Lock()
defer c.mu.Unlock()
if c.conn == nil {
conn, events, err := dialZk(ctx, c.addr)
if err != nil {
return nil, err
}
c.conn = conn
go c.handleSessionEvents(conn, events)
c.maybeAddAuth(ctx)
}
return c.conn, nil
} | [
"func",
"(",
"c",
"*",
"ZkConn",
")",
"getConn",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"*",
"zk",
".",
"Conn",
",",
"error",
")",
"{",
"c",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"mu",
".",
"Unlock",
"(",
")",
... | // getConn returns the connection in a thread safe way. It will try to connect
// if not connected yet. | [
"getConn",
"returns",
"the",
"connection",
"in",
"a",
"thread",
"safe",
"way",
".",
"It",
"will",
"try",
"to",
"connect",
"if",
"not",
"connected",
"yet",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/zk2topo/zk_conn.go#L272-L286 | train |
vitessio/vitess | go/vt/topo/zk2topo/zk_conn.go | maybeAddAuth | func (c *ZkConn) maybeAddAuth(ctx context.Context) {
if *authFile == "" {
return
}
authInfoBytes, err := ioutil.ReadFile(*authFile)
if err != nil {
log.Errorf("failed to read topo_zk_auth_file: %v", err)
return
}
authInfo := string(authInfoBytes)
authInfoParts := strings.SplitN(authInfo, ":", 2)
if len(au... | go | func (c *ZkConn) maybeAddAuth(ctx context.Context) {
if *authFile == "" {
return
}
authInfoBytes, err := ioutil.ReadFile(*authFile)
if err != nil {
log.Errorf("failed to read topo_zk_auth_file: %v", err)
return
}
authInfo := string(authInfoBytes)
authInfoParts := strings.SplitN(authInfo, ":", 2)
if len(au... | [
"func",
"(",
"c",
"*",
"ZkConn",
")",
"maybeAddAuth",
"(",
"ctx",
"context",
".",
"Context",
")",
"{",
"if",
"*",
"authFile",
"==",
"\"",
"\"",
"{",
"return",
"\n",
"}",
"\n",
"authInfoBytes",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"*",
... | // maybeAddAuth calls AddAuth if the `-topo_zk_auth_file` flag was specified | [
"maybeAddAuth",
"calls",
"AddAuth",
"if",
"the",
"-",
"topo_zk_auth_file",
"flag",
"was",
"specified"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/zk2topo/zk_conn.go#L289-L309 | train |
vitessio/vitess | go/vt/topo/zk2topo/zk_conn.go | handleSessionEvents | func (c *ZkConn) handleSessionEvents(conn *zk.Conn, session <-chan zk.Event) {
for event := range session {
closeRequired := false
switch event.State {
case zk.StateExpired, zk.StateConnecting:
closeRequired = true
fallthrough
case zk.StateDisconnected:
c.mu.Lock()
if c.conn == conn {
// The Z... | go | func (c *ZkConn) handleSessionEvents(conn *zk.Conn, session <-chan zk.Event) {
for event := range session {
closeRequired := false
switch event.State {
case zk.StateExpired, zk.StateConnecting:
closeRequired = true
fallthrough
case zk.StateDisconnected:
c.mu.Lock()
if c.conn == conn {
// The Z... | [
"func",
"(",
"c",
"*",
"ZkConn",
")",
"handleSessionEvents",
"(",
"conn",
"*",
"zk",
".",
"Conn",
",",
"session",
"<-",
"chan",
"zk",
".",
"Event",
")",
"{",
"for",
"event",
":=",
"range",
"session",
"{",
"closeRequired",
":=",
"false",
"\n\n",
"switch... | // handleSessionEvents is processing events from the session channel.
// When it detects that the connection is not working any more, it
// clears out the connection record. | [
"handleSessionEvents",
"is",
"processing",
"events",
"from",
"the",
"session",
"channel",
".",
"When",
"it",
"detects",
"that",
"the",
"connection",
"is",
"not",
"working",
"any",
"more",
"it",
"clears",
"out",
"the",
"connection",
"record",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/zk2topo/zk_conn.go#L314-L338 | train |
vitessio/vitess | go/vt/topo/zk2topo/zk_conn.go | dialZk | func dialZk(ctx context.Context, addr string) (*zk.Conn, <-chan zk.Event, error) {
servers := strings.Split(addr, ",")
options := zk.WithDialer(net.DialTimeout)
// If TLS is enabled use a TLS enabled dialer option
if *certPath != "" && *keyPath != "" {
if strings.Contains(addr, ",") {
log.Fatalf("This TLS zk c... | go | func dialZk(ctx context.Context, addr string) (*zk.Conn, <-chan zk.Event, error) {
servers := strings.Split(addr, ",")
options := zk.WithDialer(net.DialTimeout)
// If TLS is enabled use a TLS enabled dialer option
if *certPath != "" && *keyPath != "" {
if strings.Contains(addr, ",") {
log.Fatalf("This TLS zk c... | [
"func",
"dialZk",
"(",
"ctx",
"context",
".",
"Context",
",",
"addr",
"string",
")",
"(",
"*",
"zk",
".",
"Conn",
",",
"<-",
"chan",
"zk",
".",
"Event",
",",
"error",
")",
"{",
"servers",
":=",
"strings",
".",
"Split",
"(",
"addr",
",",
"\"",
"\"... | // dialZk dials the server, and waits until connection. | [
"dialZk",
"dials",
"the",
"server",
"and",
"waits",
"until",
"connection",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/zk2topo/zk_conn.go#L341-L406 | train |
vitessio/vitess | go/vt/vtgate/planbuilder/delete.go | buildDeletePlan | func buildDeletePlan(del *sqlparser.Delete, vschema ContextVSchema) (*engine.Delete, error) {
edel := &engine.Delete{}
pb := newPrimitiveBuilder(vschema, newJointab(sqlparser.GetBindvars(del)))
ro, err := pb.processDMLTable(del.TableExprs)
if err != nil {
return nil, err
}
edel.Query = generateQuery(del)
edel.... | go | func buildDeletePlan(del *sqlparser.Delete, vschema ContextVSchema) (*engine.Delete, error) {
edel := &engine.Delete{}
pb := newPrimitiveBuilder(vschema, newJointab(sqlparser.GetBindvars(del)))
ro, err := pb.processDMLTable(del.TableExprs)
if err != nil {
return nil, err
}
edel.Query = generateQuery(del)
edel.... | [
"func",
"buildDeletePlan",
"(",
"del",
"*",
"sqlparser",
".",
"Delete",
",",
"vschema",
"ContextVSchema",
")",
"(",
"*",
"engine",
".",
"Delete",
",",
"error",
")",
"{",
"edel",
":=",
"&",
"engine",
".",
"Delete",
"{",
"}",
"\n",
"pb",
":=",
"newPrimit... | // buildDeletePlan builds the instructions for a DELETE statement. | [
"buildDeletePlan",
"builds",
"the",
"instructions",
"for",
"a",
"DELETE",
"statement",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/planbuilder/delete.go#L32-L97 | train |
vitessio/vitess | go/vt/vtgate/planbuilder/delete.go | generateDeleteSubquery | func generateDeleteSubquery(del *sqlparser.Delete, table *vindexes.Table) string {
if len(table.Owned) == 0 {
return ""
}
buf := sqlparser.NewTrackedBuffer(nil)
buf.WriteString("select ")
for vIdx, cv := range table.Owned {
for cIdx, column := range cv.Columns {
if cIdx == 0 && vIdx == 0 {
buf.Myprintf(... | go | func generateDeleteSubquery(del *sqlparser.Delete, table *vindexes.Table) string {
if len(table.Owned) == 0 {
return ""
}
buf := sqlparser.NewTrackedBuffer(nil)
buf.WriteString("select ")
for vIdx, cv := range table.Owned {
for cIdx, column := range cv.Columns {
if cIdx == 0 && vIdx == 0 {
buf.Myprintf(... | [
"func",
"generateDeleteSubquery",
"(",
"del",
"*",
"sqlparser",
".",
"Delete",
",",
"table",
"*",
"vindexes",
".",
"Table",
")",
"string",
"{",
"if",
"len",
"(",
"table",
".",
"Owned",
")",
"==",
"0",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"buf"... | // generateDeleteSubquery generates the query to fetch the rows
// that will be deleted. This allows VTGate to clean up any
// owned vindexes as needed. | [
"generateDeleteSubquery",
"generates",
"the",
"query",
"to",
"fetch",
"the",
"rows",
"that",
"will",
"be",
"deleted",
".",
"This",
"allows",
"VTGate",
"to",
"clean",
"up",
"any",
"owned",
"vindexes",
"as",
"needed",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/planbuilder/delete.go#L102-L119 | train |
vitessio/vitess | go/vt/vterrors/stack.go | file | func (f Frame) file() string {
fn := runtime.FuncForPC(f.pc())
if fn == nil {
return "unknown"
}
file, _ := fn.FileLine(f.pc())
return file
} | go | func (f Frame) file() string {
fn := runtime.FuncForPC(f.pc())
if fn == nil {
return "unknown"
}
file, _ := fn.FileLine(f.pc())
return file
} | [
"func",
"(",
"f",
"Frame",
")",
"file",
"(",
")",
"string",
"{",
"fn",
":=",
"runtime",
".",
"FuncForPC",
"(",
"f",
".",
"pc",
"(",
")",
")",
"\n",
"if",
"fn",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"file",
",",
"_",
":=",
... | // file returns the full path to the file that contains the
// function for this Frame's pc. | [
"file",
"returns",
"the",
"full",
"path",
"to",
"the",
"file",
"that",
"contains",
"the",
"function",
"for",
"this",
"Frame",
"s",
"pc",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vterrors/stack.go#L22-L29 | train |
vitessio/vitess | go/vt/vterrors/stack.go | line | func (f Frame) line() int {
fn := runtime.FuncForPC(f.pc())
if fn == nil {
return 0
}
_, line := fn.FileLine(f.pc())
return line
} | go | func (f Frame) line() int {
fn := runtime.FuncForPC(f.pc())
if fn == nil {
return 0
}
_, line := fn.FileLine(f.pc())
return line
} | [
"func",
"(",
"f",
"Frame",
")",
"line",
"(",
")",
"int",
"{",
"fn",
":=",
"runtime",
".",
"FuncForPC",
"(",
"f",
".",
"pc",
"(",
")",
")",
"\n",
"if",
"fn",
"==",
"nil",
"{",
"return",
"0",
"\n",
"}",
"\n",
"_",
",",
"line",
":=",
"fn",
"."... | // line returns the line number of source code of the
// function for this Frame's pc. | [
"line",
"returns",
"the",
"line",
"number",
"of",
"source",
"code",
"of",
"the",
"function",
"for",
"this",
"Frame",
"s",
"pc",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vterrors/stack.go#L33-L40 | train |
vitessio/vitess | go/vt/vttablet/tabletserver/splitquery/equal_splits_algorithm.go | NewEqualSplitsAlgorithm | func NewEqualSplitsAlgorithm(splitParams *SplitParams, sqlExecuter SQLExecuter) (
*EqualSplitsAlgorithm, error) {
if len(splitParams.splitColumns) == 0 {
panic(fmt.Sprintf("len(splitParams.splitColumns) == 0." +
" SplitParams should have defaulted the split columns to the primary key columns."))
}
// This alg... | go | func NewEqualSplitsAlgorithm(splitParams *SplitParams, sqlExecuter SQLExecuter) (
*EqualSplitsAlgorithm, error) {
if len(splitParams.splitColumns) == 0 {
panic(fmt.Sprintf("len(splitParams.splitColumns) == 0." +
" SplitParams should have defaulted the split columns to the primary key columns."))
}
// This alg... | [
"func",
"NewEqualSplitsAlgorithm",
"(",
"splitParams",
"*",
"SplitParams",
",",
"sqlExecuter",
"SQLExecuter",
")",
"(",
"*",
"EqualSplitsAlgorithm",
",",
"error",
")",
"{",
"if",
"len",
"(",
"splitParams",
".",
"splitColumns",
")",
"==",
"0",
"{",
"panic",
"("... | // NewEqualSplitsAlgorithm constructs a new equal splits algorithm.
// It requires an SQLExecuter since it needs to execute a query to figure out the
// minimum and maximum elements in the table. | [
"NewEqualSplitsAlgorithm",
"constructs",
"a",
"new",
"equal",
"splits",
"algorithm",
".",
"It",
"requires",
"an",
"SQLExecuter",
"since",
"it",
"needs",
"to",
"execute",
"a",
"query",
"to",
"figure",
"out",
"the",
"minimum",
"and",
"maximum",
"elements",
"in",
... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/splitquery/equal_splits_algorithm.go#L58-L87 | train |
vitessio/vitess | go/vt/vttablet/tabletserver/splitquery/equal_splits_algorithm.go | bigIntToSliceOfBytes | func bigIntToSliceOfBytes(bigInt *big.Int) []byte {
// Go1.6 introduced the method bigInt.Append() which makes this conversion
// a lot easier.
// TODO(erez): Use bigInt.Append() once we switch to GO-1.6.
result := strconv.AppendQuoteToASCII([]byte{}, bigInt.String())
// AppendQuoteToASCII adds a double-quoted str... | go | func bigIntToSliceOfBytes(bigInt *big.Int) []byte {
// Go1.6 introduced the method bigInt.Append() which makes this conversion
// a lot easier.
// TODO(erez): Use bigInt.Append() once we switch to GO-1.6.
result := strconv.AppendQuoteToASCII([]byte{}, bigInt.String())
// AppendQuoteToASCII adds a double-quoted str... | [
"func",
"bigIntToSliceOfBytes",
"(",
"bigInt",
"*",
"big",
".",
"Int",
")",
"[",
"]",
"byte",
"{",
"// Go1.6 introduced the method bigInt.Append() which makes this conversion",
"// a lot easier.",
"// TODO(erez): Use bigInt.Append() once we switch to GO-1.6.",
"result",
":=",
"st... | // Converts a big.Int into a slice of bytes. | [
"Converts",
"a",
"big",
".",
"Int",
"into",
"a",
"slice",
"of",
"bytes",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/splitquery/equal_splits_algorithm.go#L229-L236 | train |
vitessio/vitess | go/vt/worker/interactive.go | InitInteractiveMode | func (wi *Instance) InitInteractiveMode() {
indexTemplate := mustParseTemplate("index", indexHTML)
subIndexTemplate := mustParseTemplate("subIndex", subIndexHTML)
// toplevel menu
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
if err := acl.CheckAccessHTTP(r, acl.ADMIN); err != nil {
acl.... | go | func (wi *Instance) InitInteractiveMode() {
indexTemplate := mustParseTemplate("index", indexHTML)
subIndexTemplate := mustParseTemplate("subIndex", subIndexHTML)
// toplevel menu
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
if err := acl.CheckAccessHTTP(r, acl.ADMIN); err != nil {
acl.... | [
"func",
"(",
"wi",
"*",
"Instance",
")",
"InitInteractiveMode",
"(",
")",
"{",
"indexTemplate",
":=",
"mustParseTemplate",
"(",
"\"",
"\"",
",",
"indexHTML",
")",
"\n",
"subIndexTemplate",
":=",
"mustParseTemplate",
"(",
"\"",
"\"",
",",
"subIndexHTML",
")",
... | // InitInteractiveMode installs webserver handlers for each known command. | [
"InitInteractiveMode",
"installs",
"webserver",
"handlers",
"for",
"each",
"known",
"command",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/worker/interactive.go#L80-L140 | train |
vitessio/vitess | go/mysql/schema.go | ShowIndexFromTableRow | func ShowIndexFromTableRow(table string, unique bool, keyName string, seqInIndex int, columnName string, nullable bool) []sqltypes.Value {
nonUnique := "1"
if unique {
nonUnique = "0"
}
nullableStr := ""
if nullable {
nullableStr = "YES"
}
return []sqltypes.Value{
sqltypes.MakeTrusted(sqltypes.VarChar, []b... | go | func ShowIndexFromTableRow(table string, unique bool, keyName string, seqInIndex int, columnName string, nullable bool) []sqltypes.Value {
nonUnique := "1"
if unique {
nonUnique = "0"
}
nullableStr := ""
if nullable {
nullableStr = "YES"
}
return []sqltypes.Value{
sqltypes.MakeTrusted(sqltypes.VarChar, []b... | [
"func",
"ShowIndexFromTableRow",
"(",
"table",
"string",
",",
"unique",
"bool",
",",
"keyName",
"string",
",",
"seqInIndex",
"int",
",",
"columnName",
"string",
",",
"nullable",
"bool",
")",
"[",
"]",
"sqltypes",
".",
"Value",
"{",
"nonUnique",
":=",
"\"",
... | // ShowIndexFromTableRow returns the fields from a 'show index from table'
// command.
// 'table' is the table name.
// 'unique' is true for unique indexes, false for non-unique indexes.
// 'keyName' is 'PRIMARY' for PKs, otherwise the name of the index.
// 'seqInIndex' is starting at 1 for first key in index.
// 'colu... | [
"ShowIndexFromTableRow",
"returns",
"the",
"fields",
"from",
"a",
"show",
"index",
"from",
"table",
"command",
".",
"table",
"is",
"the",
"table",
"name",
".",
"unique",
"is",
"true",
"for",
"unique",
"indexes",
"false",
"for",
"non",
"-",
"unique",
"indexes... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/schema.go#L296-L320 | train |
vitessio/vitess | go/mysql/schema.go | BaseShowTablesRow | func BaseShowTablesRow(tableName string, isView bool, comment string) []sqltypes.Value {
tableType := "BASE TABLE"
if isView {
tableType = "VIEW"
}
return []sqltypes.Value{
sqltypes.MakeTrusted(sqltypes.VarChar, []byte(tableName)),
sqltypes.MakeTrusted(sqltypes.VarChar, []byte(tableType)),
sqltypes.MakeTrus... | go | func BaseShowTablesRow(tableName string, isView bool, comment string) []sqltypes.Value {
tableType := "BASE TABLE"
if isView {
tableType = "VIEW"
}
return []sqltypes.Value{
sqltypes.MakeTrusted(sqltypes.VarChar, []byte(tableName)),
sqltypes.MakeTrusted(sqltypes.VarChar, []byte(tableType)),
sqltypes.MakeTrus... | [
"func",
"BaseShowTablesRow",
"(",
"tableName",
"string",
",",
"isView",
"bool",
",",
"comment",
"string",
")",
"[",
"]",
"sqltypes",
".",
"Value",
"{",
"tableType",
":=",
"\"",
"\"",
"\n",
"if",
"isView",
"{",
"tableType",
"=",
"\"",
"\"",
"\n",
"}",
"... | // BaseShowTablesRow returns the fields from a BaseShowTables or
// BaseShowTablesForTable command. | [
"BaseShowTablesRow",
"returns",
"the",
"fields",
"from",
"a",
"BaseShowTables",
"or",
"BaseShowTablesForTable",
"command",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/schema.go#L433-L449 | train |
vitessio/vitess | go/event/event.go | Dispatch | func Dispatch(ev interface{}) {
listenersMutex.RLock()
defer listenersMutex.RUnlock()
evType := reflect.TypeOf(ev)
vals := []reflect.Value{reflect.ValueOf(ev)}
// call listeners for the actual static type
callListeners(evType, vals)
// also check if the type implements any of the registered interfaces
for _,... | go | func Dispatch(ev interface{}) {
listenersMutex.RLock()
defer listenersMutex.RUnlock()
evType := reflect.TypeOf(ev)
vals := []reflect.Value{reflect.ValueOf(ev)}
// call listeners for the actual static type
callListeners(evType, vals)
// also check if the type implements any of the registered interfaces
for _,... | [
"func",
"Dispatch",
"(",
"ev",
"interface",
"{",
"}",
")",
"{",
"listenersMutex",
".",
"RLock",
"(",
")",
"\n",
"defer",
"listenersMutex",
".",
"RUnlock",
"(",
")",
"\n\n",
"evType",
":=",
"reflect",
".",
"TypeOf",
"(",
"ev",
")",
"\n",
"vals",
":=",
... | // Dispatch sends an event to all registered listeners that were declared
// to accept values of the event's type, or interfaces that the value implements. | [
"Dispatch",
"sends",
"an",
"event",
"to",
"all",
"registered",
"listeners",
"that",
"were",
"declared",
"to",
"accept",
"values",
"of",
"the",
"event",
"s",
"type",
"or",
"interfaces",
"that",
"the",
"value",
"implements",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/event/event.go#L132-L148 | train |
vitessio/vitess | go/vt/vtgate/planbuilder/insert.go | buildInsertPlan | func buildInsertPlan(ins *sqlparser.Insert, vschema ContextVSchema) (*engine.Insert, error) {
pb := newPrimitiveBuilder(vschema, newJointab(sqlparser.GetBindvars(ins)))
exprs := sqlparser.TableExprs{&sqlparser.AliasedTableExpr{Expr: ins.Table}}
ro, err := pb.processDMLTable(exprs)
if err != nil {
return nil, err
... | go | func buildInsertPlan(ins *sqlparser.Insert, vschema ContextVSchema) (*engine.Insert, error) {
pb := newPrimitiveBuilder(vschema, newJointab(sqlparser.GetBindvars(ins)))
exprs := sqlparser.TableExprs{&sqlparser.AliasedTableExpr{Expr: ins.Table}}
ro, err := pb.processDMLTable(exprs)
if err != nil {
return nil, err
... | [
"func",
"buildInsertPlan",
"(",
"ins",
"*",
"sqlparser",
".",
"Insert",
",",
"vschema",
"ContextVSchema",
")",
"(",
"*",
"engine",
".",
"Insert",
",",
"error",
")",
"{",
"pb",
":=",
"newPrimitiveBuilder",
"(",
"vschema",
",",
"newJointab",
"(",
"sqlparser",
... | // buildInsertPlan builds the route for an INSERT statement. | [
"buildInsertPlan",
"builds",
"the",
"route",
"for",
"an",
"INSERT",
"statement",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/planbuilder/insert.go#L32-L54 | train |
vitessio/vitess | go/vt/vtgate/planbuilder/insert.go | modifyForAutoinc | func modifyForAutoinc(ins *sqlparser.Insert, eins *engine.Insert) error {
pos := findOrAddColumn(ins, eins.Table.AutoIncrement.Column)
autoIncValues, err := swapBindVariables(ins.Rows.(sqlparser.Values), pos, ":"+engine.SeqVarName)
if err != nil {
return err
}
eins.Generate = &engine.Generate{
Keyspace: eins.T... | go | func modifyForAutoinc(ins *sqlparser.Insert, eins *engine.Insert) error {
pos := findOrAddColumn(ins, eins.Table.AutoIncrement.Column)
autoIncValues, err := swapBindVariables(ins.Rows.(sqlparser.Values), pos, ":"+engine.SeqVarName)
if err != nil {
return err
}
eins.Generate = &engine.Generate{
Keyspace: eins.T... | [
"func",
"modifyForAutoinc",
"(",
"ins",
"*",
"sqlparser",
".",
"Insert",
",",
"eins",
"*",
"engine",
".",
"Insert",
")",
"error",
"{",
"pos",
":=",
"findOrAddColumn",
"(",
"ins",
",",
"eins",
".",
"Table",
".",
"AutoIncrement",
".",
"Column",
")",
"\n",
... | // modifyForAutoinc modfies the AST and the plan to generate
// necessary autoinc values. It must be called only if eins.Table.AutoIncrement
// is set. | [
"modifyForAutoinc",
"modfies",
"the",
"AST",
"and",
"the",
"plan",
"to",
"generate",
"necessary",
"autoinc",
"values",
".",
"It",
"must",
"be",
"called",
"only",
"if",
"eins",
".",
"Table",
".",
"AutoIncrement",
"is",
"set",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/planbuilder/insert.go#L192-L204 | train |
Subsets and Splits
SQL Console for semeru/code-text-go
Retrieves a limited set of code samples with their languages, with a specific case adjustment for 'Go' language.