@@ -930,11 +930,11 @@ func RunCommitTrigger(
930930 ctx , errors .Wrap (err , "unable to load replica version" ),
931931 )
932932 }
933- in := splitTriggerHelperInput {
934- leftLease : lhsLease ,
935- gcThreshold : gcThreshold ,
936- gcHint : gcHint ,
937- replicaVersion : replicaVersion ,
933+ in := SplitTriggerHelperInput {
934+ LeftLease : lhsLease ,
935+ GCThreshold : gcThreshold ,
936+ GCHint : gcHint ,
937+ ReplicaVersion : replicaVersion ,
938938 }
939939
940940 newMS , res , err := splitTrigger (
@@ -1164,7 +1164,7 @@ func splitTrigger(
11641164 batch storage.Batch ,
11651165 bothDeltaMS enginepb.MVCCStats ,
11661166 split * roachpb.SplitTrigger ,
1167- in splitTriggerHelperInput ,
1167+ in SplitTriggerHelperInput ,
11681168 ts hlc.Timestamp ,
11691169) (enginepb.MVCCStats , result.Result , error ) {
11701170 desc := rec .Desc ()
@@ -1243,6 +1243,20 @@ func splitTrigger(
12431243 return splitTriggerHelper (ctx , rec , batch , in , h , split , ts )
12441244}
12451245
1246+ // TestingSplitTrigger is a wrapper around splitTrigger that is exported for
1247+ // testing purposes.
1248+ func TestingSplitTrigger (
1249+ ctx context.Context ,
1250+ rec EvalContext ,
1251+ batch storage.Batch ,
1252+ bothDeltaMS enginepb.MVCCStats ,
1253+ split * roachpb.SplitTrigger ,
1254+ in SplitTriggerHelperInput ,
1255+ ts hlc.Timestamp ,
1256+ ) (enginepb.MVCCStats , result.Result , error ) {
1257+ return splitTrigger (ctx , rec , batch , bothDeltaMS , split , in , ts )
1258+ }
1259+
12461260// splitScansRightForStatsFirst controls whether the left hand side or the right
12471261// hand side of the split is scanned first on the leaseholder when evaluating
12481262// the split trigger. In practice, the splitQueue wants to scan the left hand
@@ -1276,13 +1290,13 @@ func makeScanStatsFn(
12761290 }
12771291}
12781292
1279- // splitTriggerHelperInput contains metadata needed by the RHS when running the
1293+ // SplitTriggerHelperInput contains metadata needed by the RHS when running the
12801294// splitTriggerHelper.
1281- type splitTriggerHelperInput struct {
1282- leftLease roachpb.Lease
1283- gcThreshold * hlc.Timestamp
1284- gcHint * roachpb.GCHint
1285- replicaVersion roachpb.Version
1295+ type SplitTriggerHelperInput struct {
1296+ LeftLease roachpb.Lease
1297+ GCThreshold * hlc.Timestamp
1298+ GCHint * roachpb.GCHint
1299+ ReplicaVersion roachpb.Version
12861300}
12871301
12881302// splitTriggerHelper continues the work begun by splitTrigger, but has a
@@ -1292,7 +1306,7 @@ func splitTriggerHelper(
12921306 ctx context.Context ,
12931307 rec EvalContext ,
12941308 batch storage.Batch ,
1295- in splitTriggerHelperInput ,
1309+ in SplitTriggerHelperInput ,
12961310 statsInput splitStatsHelperInput ,
12971311 split * roachpb.SplitTrigger ,
12981312 ts hlc.Timestamp ,
@@ -1434,22 +1448,22 @@ func splitTriggerHelper(
14341448 // - node two becomes the lease holder for [c,e). Its timestamp cache does
14351449 // not know about the read at 'd' which happened at the beginning.
14361450 // - node two can illegally propose a write to 'd' at a lower timestamp.
1437- if in .leftLease .Empty () {
1451+ if in .LeftLease .Empty () {
14381452 log .KvExec .Fatalf (ctx , "LHS of split has no lease" )
14391453 }
14401454
14411455 // Copy the lease from the left-hand side of the split over to the
14421456 // right-hand side so that it can immediately start serving requests.
14431457 // When doing so, we need to make a few modifications.
1444- rightLease := in .leftLease
1458+ rightLease := in .LeftLease
14451459 // Rebind the lease to the existing leaseholder store's replica from the
14461460 // right-hand side's descriptor.
14471461 var ok bool
1448- rightLease .Replica , ok = split .RightDesc .GetReplicaDescriptor (in .leftLease .Replica .StoreID )
1462+ rightLease .Replica , ok = split .RightDesc .GetReplicaDescriptor (in .LeftLease .Replica .StoreID )
14491463 if ! ok {
14501464 return enginepb.MVCCStats {}, result.Result {}, errors .Errorf (
14511465 "pre-split lease holder %+v not found in post-split descriptor %+v" ,
1452- in .leftLease .Replica , split .RightDesc ,
1466+ in .LeftLease .Replica , split .RightDesc ,
14531467 )
14541468 }
14551469 // Convert leader leases into expiration-based leases. A leader lease is
@@ -1464,7 +1478,7 @@ func splitTriggerHelper(
14641478 rightLease .Term = 0
14651479 rightLease .MinExpiration = hlc.Timestamp {}
14661480 }
1467- if in .gcThreshold .IsEmpty () {
1481+ if in .GCThreshold .IsEmpty () {
14681482 log .VEventf (ctx , 1 , "LHS's GCThreshold of split is not set" )
14691483 }
14701484
@@ -1499,7 +1513,7 @@ func splitTriggerHelper(
14991513 // only.
15001514 if * h .AbsPostSplitRight (), err = stateloader .WriteInitialReplicaState (
15011515 ctx , batch , * h .AbsPostSplitRight (), split .RightDesc , rightLease ,
1502- * in .gcThreshold , * in .gcHint , in .replicaVersion ,
1516+ * in .GCThreshold , * in .GCHint , in .ReplicaVersion ,
15031517 ); err != nil {
15041518 return enginepb.MVCCStats {}, result.Result {}, errors .Wrap (err , "unable to write initial Replica state" )
15051519 }
0 commit comments