Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Makes ReplicationStatus.IOThreadRunning more strict #234

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,6 @@ releases
venv

.scannerwork
report
report

vendor
8 changes: 5 additions & 3 deletions go/mysql/flavor.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@ limitations under the License.
package mysql

import (
"context"
"errors"
"fmt"
"strconv"
"strings"

"context"

"vitess.io/vitess/go/sqltypes"
"vitess.io/vitess/go/vt/proto/vtrpc"
"vitess.io/vitess/go/vt/vterrors"
Expand Down Expand Up @@ -306,7 +305,10 @@ func parseReplicationStatus(fields map[string]string) ReplicationStatus {
status := ReplicationStatus{
MasterHost: fields["Master_Host"],
// These fields are returned from the underlying DB and cannot be renamed
IOThreadRunning: fields["Slave_IO_Running"] == "Yes" || fields["Slave_IO_Running"] == "Connecting",
// Removing an OR for `Slave_IO_Running=Connecting` since a replica can be stuck in this state
// for many days, up to `MASTER_RETRY_COUNT*MASTER_CONNECT_RETRY`, with Seconds_Behind_Master=0
// thus making a replica serve stale data to consumers ...
IOThreadRunning: fields["Slave_IO_Running"] == "Yes",
SQLThreadRunning: fields["Slave_SQL_Running"] == "Yes",
}
parseInt, _ := strconv.ParseInt(fields["Master_Port"], 10, 0)
Expand Down
9 changes: 7 additions & 2 deletions go/mysql/flavor_mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ limitations under the License.
package mysql

import (
"context"
"fmt"
"io"
"time"

"context"

"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/proto/vtrpc"
"vitess.io/vitess/go/vt/vterrors"
)
Expand Down Expand Up @@ -135,6 +135,11 @@ func (mysqlFlavor) status(c *Conn) (ReplicationStatus, error) {
return ReplicationStatus{}, err
}

if log.V(1) {
for k, v := range resultMap {
log.Infof("debug: SHOW SLAVE STATUS resultMap.%s: %s", k, v)
}
}
return parseMysqlReplicationStatus(resultMap)
}

Expand Down
2 changes: 2 additions & 0 deletions go/mysql/replication_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package mysql
import (
"fmt"

"vitess.io/vitess/go/vt/log"
replicationdatapb "vitess.io/vitess/go/vt/proto/replicationdata"
"vitess.io/vitess/go/vt/vterrors"
)
Expand Down Expand Up @@ -46,6 +47,7 @@ type ReplicationStatus struct {
// ReplicationRunning returns true iff both the IO and SQL threads are
// running.
func (s *ReplicationStatus) ReplicationRunning() bool {
log.V(1).Infof("debug: ReplicationStatus=%+v", s)
return s.IOThreadRunning && s.SQLThreadRunning
}

Expand Down