Skip to content

Commit

Permalink
show vitess_tablets should show new master's timestamp after reparenting
Browse files Browse the repository at this point in the history
Signed-off-by: deepthi <deepthi@planetscale.com>
  • Loading branch information
deepthi committed Jun 10, 2020
1 parent 2036988 commit 17ef346
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
1 change: 0 additions & 1 deletion examples/local/scripts/vtgate-up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ vtgate \
-cell $cell \
-cells_to_watch $cell \
-tablet_types_to_wait MASTER,REPLICA \
-gateway_implementation discoverygateway \
-service_map 'grpc-vtgateservice' \
-pid_file $VTDATAROOT/tmp/vtgate.pid \
-mysql_auth_server_impl none \
Expand Down
1 change: 0 additions & 1 deletion examples/region_sharding/scripts/vtgate-up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ vtgate \
-cell $cell \
-cells_to_watch $cell \
-tablet_types_to_wait MASTER,REPLICA \
-gateway_implementation discoverygateway \
-service_map 'grpc-vtgateservice' \
-pid_file $VTDATAROOT/tmp/vtgate.pid \
-mysql_auth_server_impl none \
Expand Down
18 changes: 10 additions & 8 deletions go/vt/vtgate/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ import (
"sync"
"time"

"vitess.io/vitess/go/vt/logutil"

"vitess.io/vitess/go/vt/log"
vtgatepb "vitess.io/vitess/go/vt/proto/vtgate"

Expand Down Expand Up @@ -991,10 +989,11 @@ func (e *Executor) showTablets() (*sqltypes.Result, error) {
if !ts.Serving {
state = "NOT_SERVING"
}
mtst := ts.Tablet.MasterTermStartTime
mtst := ts.TabletExternallyReparentedTimestamp
mtstStr := ""
if mtst != nil && mtst.Seconds > 0 {
mtstStr = logutil.ProtoToTime(ts.Tablet.MasterTermStartTime).Format(time.RFC3339)
if mtst > 0 {
// this code depends on the fact that TabletExternallyReparentedTimestamp is the seconds since epoch start
mtstStr = time.Unix(mtst, 0).UTC().Format(time.RFC3339)
}
rows = append(rows, buildVarCharRow(
s.Cell,
Expand All @@ -1009,17 +1008,20 @@ func (e *Executor) showTablets() (*sqltypes.Result, error) {
}
}
} else {
log.Info("DEBUG: in showTablets")
status := e.scatterConn.GetHealthCheckCacheStatus()
for _, s := range status {
for _, ts := range s.TabletsStats {
state := "SERVING"
if !ts.Serving {
state = "NOT_SERVING"
}
mtst := ts.Tablet.MasterTermStartTime
mtst := ts.MasterTermStartTime
mtstStr := ""
if mtst != nil && mtst.Seconds > 0 {
mtstStr = logutil.ProtoToTime(ts.Tablet.MasterTermStartTime).Format(time.RFC3339)
if mtst > 0 {
// this code depends on the fact that MasterTermStartTime is the seconds since epoch start
mtstStr = time.Unix(mtst, 0).UTC().Format(time.RFC3339)
log.Infof("DEBUG: MasterTermStartTime: %v", mtstStr)
}
rows = append(rows, buildVarCharRow(
s.Cell,
Expand Down
2 changes: 1 addition & 1 deletion go/vt/vttablet/tabletmanager/rpc_replication.go
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ func (agent *ActionAgent) setMasterLocked(ctx context.Context, parentAlias *topo
tablet := agent.Tablet()
if tablet.Type == topodatapb.TabletType_MASTER {
tablet.Type = topodatapb.TabletType_REPLICA
tablet.MasterTermStartTime = nil
agent.setMasterTermStartTime(time.Time{})
agent.updateState(ctx, tablet, "setMasterLocked")
}

Expand Down

0 comments on commit 17ef346

Please sign in to comment.