@@ -17,16 +17,16 @@ limitations under the License.
17
17
package tabletmanager
18
18
19
19
import (
20
+ "context"
20
21
"flag"
21
22
"fmt"
22
23
"strconv"
23
24
"strings"
24
25
"time"
25
26
27
+ "github.com/davecgh/go-spew/spew"
26
28
"vitess.io/vitess/go/vt/proto/vtrpc"
27
29
28
- "context"
29
-
30
30
"vitess.io/vitess/go/mysql"
31
31
"vitess.io/vitess/go/vt/log"
32
32
"vitess.io/vitess/go/vt/logutil"
@@ -476,10 +476,10 @@ func (tm *TabletManager) InitReplica(ctx context.Context, parent *topodatapb.Tab
476
476
//
477
477
// It attemps to idempotently ensure the following guarantees upon returning
478
478
// 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.
483
483
//
484
484
// If necessary, it waits for all in-flight writes to complete or time out.
485
485
//
@@ -703,6 +703,7 @@ func (tm *TabletManager) setReplicationSourceRepairReplication(ctx context.Conte
703
703
return err
704
704
}
705
705
706
+ log .Infof ("vm-debug: calling tm.TopoServer.LockShard ctx=%s" , spew .Sdump (ctx ))
706
707
ctx , unlock , lockErr := tm .TopoServer .LockShard (ctx , parent .Tablet .GetKeyspace (), parent .Tablet .GetShard (), fmt .Sprintf ("repairReplication to %v as parent)" , topoproto .TabletAliasString (parentAlias )))
707
708
if lockErr != nil {
708
709
return lockErr
@@ -745,6 +746,7 @@ func (tm *TabletManager) setReplicationSourceLocked(ctx context.Context, parentA
745
746
// unintentionally change the type of RDONLY tablets
746
747
tablet := tm .Tablet ()
747
748
if tablet .Type == topodatapb .TabletType_PRIMARY {
749
+ log .Infof ("vm-debug: calling tm.tmState.ChangeTabletType" )
748
750
if err := tm .tmState .ChangeTabletType (ctx , topodatapb .TabletType_REPLICA , DBActionNone ); err != nil {
749
751
return err
750
752
}
@@ -755,6 +757,7 @@ func (tm *TabletManager) setReplicationSourceLocked(ctx context.Context, parentA
755
757
shouldbeReplicating := false
756
758
status , err := tm .MysqlDaemon .ReplicationStatus ()
757
759
if err == mysql .ErrNotReplica {
760
+ log .Infof ("vm-debug: err == mysql.ErrNotReplica" )
758
761
// This is a special error that means we actually succeeded in reading
759
762
// the status, but the status is empty because replication is not
760
763
// 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
781
784
if tabletType == topodatapb .TabletType_PRIMARY {
782
785
tabletType = topodatapb .TabletType_REPLICA
783
786
}
787
+ log .Infof ("vm-debug: calling tm.fixSemiSync" )
784
788
if err := tm .fixSemiSync (tabletType , semiSync ); err != nil {
785
789
return err
786
790
}
@@ -797,6 +801,7 @@ func (tm *TabletManager) setReplicationSourceLocked(ctx context.Context, parentA
797
801
host := parent .Tablet .MysqlHostname
798
802
port := int (parent .Tablet .MysqlPort )
799
803
if status .SourceHost != host || status .SourcePort != port {
804
+ log .Infof ("vm-debug: calling tm.MysqlDaemon.SetReplicationSource" )
800
805
// This handles both changing the address and starting replication.
801
806
if err := tm .MysqlDaemon .SetReplicationSource (ctx , host , port , wasReplicating , shouldbeReplicating ); err != nil {
802
807
if err := tm .handleRelayLogError (err ); err != nil {
@@ -1053,18 +1058,18 @@ func (tm *TabletManager) fixSemiSync(tabletType topodatapb.TabletType, semiSync
1053
1058
// This following code will be uncommented and the above deleted when we are ready to use the
1054
1059
// durability policies for setting the semi_sync information
1055
1060
1056
- //switch semiSync {
1057
- //case SemiSyncActionNone:
1061
+ // switch semiSync {
1062
+ // case SemiSyncActionNone:
1058
1063
// return nil
1059
- //case SemiSyncActionSet:
1064
+ // case SemiSyncActionSet:
1060
1065
// // Always enable replica-side since it doesn't hurt to keep it on for a primary.
1061
1066
// // The primary-side needs to be off for a replica, or else it will get stuck.
1062
1067
// return tm.MysqlDaemon.SetSemiSyncEnabled(tabletType == topodatapb.TabletType_PRIMARY, true)
1063
- //case SemiSyncActionUnset:
1068
+ // case SemiSyncActionUnset:
1064
1069
// return tm.MysqlDaemon.SetSemiSyncEnabled(false, false)
1065
- //default:
1070
+ // default:
1066
1071
// return vterrors.Errorf(vtrpc.Code_INTERNAL, "Unknown SemiSyncAction - %v", semiSync)
1067
- //}
1072
+ // }
1068
1073
}
1069
1074
1070
1075
func (tm * TabletManager ) isPrimarySideSemiSyncEnabled () bool {
@@ -1077,10 +1082,10 @@ func (tm *TabletManager) fixSemiSyncAndReplication(tabletType topodatapb.TabletT
1077
1082
// Semi-sync handling is not enabled.
1078
1083
return nil
1079
1084
}
1080
- //if semiSync == SemiSyncActionNone {
1085
+ // if semiSync == SemiSyncActionNone {
1081
1086
// // Semi-sync handling is not required.
1082
1087
// return nil
1083
- //}
1088
+ // }
1084
1089
1085
1090
if tabletType == topodatapb .TabletType_PRIMARY {
1086
1091
// Primary is special. It is always handled at the
@@ -1106,7 +1111,7 @@ func (tm *TabletManager) fixSemiSyncAndReplication(tabletType topodatapb.TabletT
1106
1111
return nil
1107
1112
}
1108
1113
1109
- //shouldAck := semiSync == SemiSyncActionSet
1114
+ // shouldAck := semiSync == SemiSyncActionSet
1110
1115
shouldAck := isPrimaryEligible (tabletType )
1111
1116
acking , err := tm .MysqlDaemon .SemiSyncReplicationStatus ()
1112
1117
if err != nil {
@@ -1164,6 +1169,7 @@ func (tm *TabletManager) repairReplication(ctx context.Context) error {
1164
1169
1165
1170
// If Orchestrator is configured and if Orchestrator is actively reparenting, we should not repairReplication
1166
1171
if tm .orc != nil {
1172
+ log .Infof ("vm-debug: tm.orc != nil" )
1167
1173
re , err := tm .orc .InActiveShardRecovery (tablet )
1168
1174
if err != nil {
1169
1175
return err
0 commit comments