Skip to content

Commit 79fb085

Browse files
committed
more debug
1 parent 7335c67 commit 79fb085

File tree

2 files changed

+23
-15
lines changed

2 files changed

+23
-15
lines changed

go/vt/vttablet/tabletmanager/replmanager.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"sync"
2424
"time"
2525

26+
"github.com/davecgh/go-spew/spew"
2627
"vitess.io/vitess/go/mysql"
2728
"vitess.io/vitess/go/timer"
2829
"vitess.io/vitess/go/vt/log"
@@ -119,6 +120,7 @@ func (rm *replManager) checkActionLocked() {
119120
}
120121
}
121122

123+
log.Infof("vm-debug: replManager=%s", spew.Sdump(rm))
122124
if !rm.failed {
123125
log.Infof("Replication is stopped, reconnecting to primary.")
124126
}

go/vt/vttablet/tabletmanager/rpc_replication.go

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ limitations under the License.
1717
package tabletmanager
1818

1919
import (
20+
"context"
2021
"flag"
2122
"fmt"
2223
"strconv"
2324
"strings"
2425
"time"
2526

27+
"github.com/davecgh/go-spew/spew"
2628
"vitess.io/vitess/go/vt/proto/vtrpc"
2729

28-
"context"
29-
3030
"vitess.io/vitess/go/mysql"
3131
"vitess.io/vitess/go/vt/log"
3232
"vitess.io/vitess/go/vt/logutil"
@@ -476,10 +476,10 @@ func (tm *TabletManager) InitReplica(ctx context.Context, parent *topodatapb.Tab
476476
//
477477
// It attemps to idempotently ensure the following guarantees upon returning
478478
// successfully:
479-
// * No future writes will be accepted.
480-
// * No writes are in-flight.
481-
// * MySQL is in read-only mode.
482-
// * Semi-sync settings are consistent with a REPLICA tablet.
479+
// - No future writes will be accepted.
480+
// - No writes are in-flight.
481+
// - MySQL is in read-only mode.
482+
// - Semi-sync settings are consistent with a REPLICA tablet.
483483
//
484484
// If necessary, it waits for all in-flight writes to complete or time out.
485485
//
@@ -703,6 +703,7 @@ func (tm *TabletManager) setReplicationSourceRepairReplication(ctx context.Conte
703703
return err
704704
}
705705

706+
log.Infof("vm-debug: calling tm.TopoServer.LockShard ctx=%s", spew.Sdump(ctx))
706707
ctx, unlock, lockErr := tm.TopoServer.LockShard(ctx, parent.Tablet.GetKeyspace(), parent.Tablet.GetShard(), fmt.Sprintf("repairReplication to %v as parent)", topoproto.TabletAliasString(parentAlias)))
707708
if lockErr != nil {
708709
return lockErr
@@ -745,6 +746,7 @@ func (tm *TabletManager) setReplicationSourceLocked(ctx context.Context, parentA
745746
// unintentionally change the type of RDONLY tablets
746747
tablet := tm.Tablet()
747748
if tablet.Type == topodatapb.TabletType_PRIMARY {
749+
log.Infof("vm-debug: calling tm.tmState.ChangeTabletType")
748750
if err := tm.tmState.ChangeTabletType(ctx, topodatapb.TabletType_REPLICA, DBActionNone); err != nil {
749751
return err
750752
}
@@ -755,6 +757,7 @@ func (tm *TabletManager) setReplicationSourceLocked(ctx context.Context, parentA
755757
shouldbeReplicating := false
756758
status, err := tm.MysqlDaemon.ReplicationStatus()
757759
if err == mysql.ErrNotReplica {
760+
log.Infof("vm-debug: err == mysql.ErrNotReplica")
758761
// This is a special error that means we actually succeeded in reading
759762
// the status, but the status is empty because replication is not
760763
// configured. We assume this means we used to be a primary, so we always
@@ -781,6 +784,7 @@ func (tm *TabletManager) setReplicationSourceLocked(ctx context.Context, parentA
781784
if tabletType == topodatapb.TabletType_PRIMARY {
782785
tabletType = topodatapb.TabletType_REPLICA
783786
}
787+
log.Infof("vm-debug: calling tm.fixSemiSync")
784788
if err := tm.fixSemiSync(tabletType, semiSync); err != nil {
785789
return err
786790
}
@@ -797,6 +801,7 @@ func (tm *TabletManager) setReplicationSourceLocked(ctx context.Context, parentA
797801
host := parent.Tablet.MysqlHostname
798802
port := int(parent.Tablet.MysqlPort)
799803
if status.SourceHost != host || status.SourcePort != port {
804+
log.Infof("vm-debug: calling tm.MysqlDaemon.SetReplicationSource")
800805
// This handles both changing the address and starting replication.
801806
if err := tm.MysqlDaemon.SetReplicationSource(ctx, host, port, wasReplicating, shouldbeReplicating); err != nil {
802807
if err := tm.handleRelayLogError(err); err != nil {
@@ -1053,18 +1058,18 @@ func (tm *TabletManager) fixSemiSync(tabletType topodatapb.TabletType, semiSync
10531058
// This following code will be uncommented and the above deleted when we are ready to use the
10541059
// durability policies for setting the semi_sync information
10551060

1056-
//switch semiSync {
1057-
//case SemiSyncActionNone:
1061+
// switch semiSync {
1062+
// case SemiSyncActionNone:
10581063
// return nil
1059-
//case SemiSyncActionSet:
1064+
// case SemiSyncActionSet:
10601065
// // Always enable replica-side since it doesn't hurt to keep it on for a primary.
10611066
// // The primary-side needs to be off for a replica, or else it will get stuck.
10621067
// return tm.MysqlDaemon.SetSemiSyncEnabled(tabletType == topodatapb.TabletType_PRIMARY, true)
1063-
//case SemiSyncActionUnset:
1068+
// case SemiSyncActionUnset:
10641069
// return tm.MysqlDaemon.SetSemiSyncEnabled(false, false)
1065-
//default:
1070+
// default:
10661071
// return vterrors.Errorf(vtrpc.Code_INTERNAL, "Unknown SemiSyncAction - %v", semiSync)
1067-
//}
1072+
// }
10681073
}
10691074

10701075
func (tm *TabletManager) isPrimarySideSemiSyncEnabled() bool {
@@ -1077,10 +1082,10 @@ func (tm *TabletManager) fixSemiSyncAndReplication(tabletType topodatapb.TabletT
10771082
// Semi-sync handling is not enabled.
10781083
return nil
10791084
}
1080-
//if semiSync == SemiSyncActionNone {
1085+
// if semiSync == SemiSyncActionNone {
10811086
// // Semi-sync handling is not required.
10821087
// return nil
1083-
//}
1088+
// }
10841089

10851090
if tabletType == topodatapb.TabletType_PRIMARY {
10861091
// Primary is special. It is always handled at the
@@ -1106,7 +1111,7 @@ func (tm *TabletManager) fixSemiSyncAndReplication(tabletType topodatapb.TabletT
11061111
return nil
11071112
}
11081113

1109-
//shouldAck := semiSync == SemiSyncActionSet
1114+
// shouldAck := semiSync == SemiSyncActionSet
11101115
shouldAck := isPrimaryEligible(tabletType)
11111116
acking, err := tm.MysqlDaemon.SemiSyncReplicationStatus()
11121117
if err != nil {
@@ -1164,6 +1169,7 @@ func (tm *TabletManager) repairReplication(ctx context.Context) error {
11641169

11651170
// If Orchestrator is configured and if Orchestrator is actively reparenting, we should not repairReplication
11661171
if tm.orc != nil {
1172+
log.Infof("vm-debug: tm.orc != nil")
11671173
re, err := tm.orc.InActiveShardRecovery(tablet)
11681174
if err != nil {
11691175
return err

0 commit comments

Comments
 (0)