Skip to content

Commit

Permalink
fix reachable bug
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Vaillancourt <[email protected]>
  • Loading branch information
timvaillancourt committed Jan 23, 2025
1 parent b3c43e5 commit a83afbf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions go/vt/vttablet/tabletserver/health/primary_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,13 @@ func (pm *TMClientPrimaryMonitor) ping(tmc *grpctmclient.Client, primary *topoda

ctx, cancel := context.WithTimeout(pm.ctx, PrimaryPingTimeout)
defer cancel()
var reachable uint32
if err := tmc.Ping(ctx, primary); err != nil {
log.Errorf("Failed to ping primary %s: %+v", topoproto.TabletAliasString(primary.Alias), err)
return
} else {
reachable = 1
}
atomic.StoreUint32(&pm.reachable, 1)
atomic.StoreUint32(&pm.reachable, reachable)
}

// poll pings the primary periodically and on-demand when the address changes.
Expand Down
2 changes: 1 addition & 1 deletion go/vt/vttablet/tabletserver/health/primary_monitor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (

"github.com/stretchr/testify/require"
"google.golang.org/grpc"
topodatapb "vitess.io/vitess/go/vt/proto/topodata"

topodatapb "vitess.io/vitess/go/vt/proto/topodata"
"vitess.io/vitess/go/vt/vttablet/grpctmserver"
"vitess.io/vitess/go/vt/vttablet/tmrpctest"
)
Expand Down

0 comments on commit a83afbf

Please sign in to comment.