32
32
import com .google .common .collect .Maps ;
33
33
import com .google .common .collect .MultimapBuilder ;
34
34
import com .google .common .collect .SetMultimap ;
35
- import com .google .common .collect .Sets ;
36
35
import com .google .common .flogger .GoogleLogger ;
37
36
import com .google .devtools .build .lib .actions .Action ;
38
37
import com .google .devtools .build .lib .actions .ActionCacheChecker .Token ;
118
117
import java .util .Map ;
119
118
import java .util .Set ;
120
119
import java .util .concurrent .atomic .AtomicBoolean ;
121
- import java .util .function .Consumer ;
122
120
import java .util .function .IntFunction ;
123
121
import java .util .function .Predicate ;
124
122
import java .util .function .Supplier ;
@@ -302,8 +300,7 @@ private SkyValue computeInternal(ActionLookupData actionLookupData, Environment
302
300
if (previousExecution == null ) {
303
301
// Do we actually need to find our metadata?
304
302
try {
305
- checkedInputs =
306
- checkInputs (env , action , inputDepsResult , allInputs , inputDepKeys , actionLookupData );
303
+ checkedInputs = checkInputs (env , action , inputDepsResult , allInputs , inputDepKeys );
307
304
} catch (ActionExecutionException e ) {
308
305
throw new ActionExecutionFunctionException (e );
309
306
}
@@ -535,7 +532,7 @@ private SkyFunction.Reset handleLostInputs(
535
532
RewindPlan rewindPlan = null ;
536
533
try {
537
534
ActionInputDepOwners inputDepOwners =
538
- createAugmentedInputDepOwners (e , action , inputDepKeys , env , allInputs , actionLookupData );
535
+ createAugmentedInputDepOwners (e , action , inputDepKeys , env , allInputs );
539
536
rewindPlan =
540
537
actionRewindStrategy .getRewindPlan (
541
538
actionLookupData , action , failedActionDeps , e , inputDepOwners , env );
@@ -590,8 +587,7 @@ private ActionInputDepOwners createAugmentedInputDepOwners(
590
587
Action action ,
591
588
ImmutableSet <SkyKey > inputDepKeys ,
592
589
Environment env ,
593
- NestedSet <Artifact > allInputs ,
594
- ActionLookupData actionLookupDataForError )
590
+ NestedSet <Artifact > allInputs )
595
591
throws InterruptedException , UndoneInputsException {
596
592
Set <ActionInput > lostInputsAndOwnersSoFar = new HashSet <>();
597
593
ActionInputDepOwners owners = e .getOwners ();
@@ -603,13 +599,7 @@ private ActionInputDepOwners createAugmentedInputDepOwners(
603
599
ActionInputDepOwnerMap inputDepOwners ;
604
600
try {
605
601
inputDepOwners =
606
- getInputDepOwners (
607
- env ,
608
- action ,
609
- inputDepKeys ,
610
- allInputs ,
611
- lostInputsAndOwnersSoFar ,
612
- actionLookupDataForError );
602
+ getInputDepOwners (env , action , inputDepKeys , allInputs , lostInputsAndOwnersSoFar );
613
603
} catch (ActionExecutionException unexpected ) {
614
604
// getInputDepOwners should not be able to throw, because it does the same work as
615
605
// checkInputs, so if getInputDepOwners throws then checkInputs should have thrown, and if
@@ -1131,8 +1121,7 @@ private CheckInputResults checkInputs(
1131
1121
Action action ,
1132
1122
SkyframeLookupResult inputDepsResult ,
1133
1123
NestedSet <Artifact > allInputs ,
1134
- ImmutableSet <SkyKey > inputDepKeys ,
1135
- ActionLookupData actionLookupDataForError )
1124
+ ImmutableSet <SkyKey > inputDepKeys )
1136
1125
throws ActionExecutionException , InterruptedException , UndoneInputsException {
1137
1126
return accumulateInputs (
1138
1127
env ,
@@ -1142,8 +1131,7 @@ private CheckInputResults checkInputs(
1142
1131
inputDepKeys ,
1143
1132
sizeHint -> new ActionInputMap (bugReporter , sizeHint ),
1144
1133
CheckInputResults ::new ,
1145
- /* returnEarlyIfValuesMissing= */ true ,
1146
- actionLookupDataForError );
1134
+ /* returnEarlyIfValuesMissing= */ true );
1147
1135
}
1148
1136
1149
1137
/**
@@ -1154,8 +1142,7 @@ private ActionInputDepOwnerMap getInputDepOwners(
1154
1142
Action action ,
1155
1143
ImmutableSet <SkyKey > inputDepKeys ,
1156
1144
NestedSet <Artifact > allInputs ,
1157
- Collection <ActionInput > lostInputs ,
1158
- ActionLookupData actionLookupDataForError )
1145
+ Collection <ActionInput > lostInputs )
1159
1146
throws ActionExecutionException , InterruptedException , UndoneInputsException {
1160
1147
return accumulateInputs (
1161
1148
env ,
@@ -1174,8 +1161,7 @@ private ActionInputDepOwnerMap getInputDepOwners(
1174
1161
// returnEarlyIfValuesMissing. Lost inputs coinciding with missing dependencies is
1175
1162
// possible during include scanning, see the test case
1176
1163
// generatedHeaderRequestedWhileDirty_coincidesWithLostInput.
1177
- /* returnEarlyIfValuesMissing= */ false ,
1178
- actionLookupDataForError );
1164
+ /* returnEarlyIfValuesMissing= */ false );
1179
1165
}
1180
1166
1181
1167
private static Predicate <Artifact > makeMandatoryInputPredicate (Action action ) {
@@ -1231,8 +1217,7 @@ private <S extends ActionInputMapSink, R> R accumulateInputs(
1231
1217
ImmutableSet <SkyKey > inputDepKeys ,
1232
1218
IntFunction <S > actionInputMapSinkFactory ,
1233
1219
AccumulateInputResultsFactory <S , R > accumulateInputResultsFactory ,
1234
- boolean returnEarlyIfValuesMissing ,
1235
- ActionLookupData actionLookupDataForError )
1220
+ boolean returnEarlyIfValuesMissing )
1236
1221
throws ActionExecutionException , InterruptedException , UndoneInputsException {
1237
1222
Predicate <Artifact > isMandatoryInput = makeMandatoryInputPredicate (action );
1238
1223
ActionExecutionFunctionExceptionHandler actionExecutionFunctionExceptionHandler = null ;
@@ -1294,8 +1279,7 @@ private <S extends ActionInputMapSink, R> R accumulateInputs(
1294
1279
input ,
1295
1280
inputDepKeys ,
1296
1281
isMandatoryInput ,
1297
- actionExecutionFunctionExceptionHandler ,
1298
- actionLookupDataForError );
1282
+ actionExecutionFunctionExceptionHandler );
1299
1283
1300
1284
if (value != null ) {
1301
1285
ActionInputMapHelper .addToMap (
@@ -1336,8 +1320,7 @@ private <S extends ActionInputMapSink, R> R accumulateInputs(
1336
1320
input ,
1337
1321
inputDepKeys ,
1338
1322
isMandatoryInput ,
1339
- actionExecutionFunctionExceptionHandler ,
1340
- actionLookupDataForError );
1323
+ actionExecutionFunctionExceptionHandler );
1341
1324
}
1342
1325
1343
1326
for (NestedSet <Artifact > nonLeaf : action .getSchedulingDependencies ().getNonLeaves ()) {
@@ -1349,8 +1332,7 @@ private <S extends ActionInputMapSink, R> R accumulateInputs(
1349
1332
input ,
1350
1333
inputDepKeys ,
1351
1334
isMandatoryInput ,
1352
- actionExecutionFunctionExceptionHandler ,
1353
- actionLookupDataForError );
1335
+ actionExecutionFunctionExceptionHandler );
1354
1336
}
1355
1337
}
1356
1338
}
@@ -1378,67 +1360,31 @@ private SkyValue getAndCheckInputSkyValue(
1378
1360
Artifact input ,
1379
1361
ImmutableSet <SkyKey > inputDepKeys ,
1380
1362
Predicate <Artifact > isMandatoryInput ,
1381
- ActionExecutionFunctionExceptionHandler actionExecutionFunctionExceptionHandler ,
1382
- ActionLookupData actionLookupDataForError )
1363
+ @ Nullable ActionExecutionFunctionExceptionHandler actionExecutionFunctionExceptionHandler )
1383
1364
throws InterruptedException {
1384
1365
SkyValue value = lookupInput (input , inputDepKeys , env );
1385
1366
if (value == null ) {
1386
- if (isMandatoryInput .test (input ) && !skyframeActionExecutor .rewindingEnabled ()) {
1387
- StringBuilder errorMessage = new StringBuilder ();
1388
- ImmutableSet <Artifact > outputs = ImmutableSet .copyOf (action .getOutputs ());
1389
- NestedSet <Artifact > nestedInputs = action .getInputs ();
1390
- ImmutableSet <Artifact > inputs = nestedInputs .toSet ();
1391
- if (action .discoversInputs ()) {
1392
- errorMessage .append ("\n Action discovers inputs" );
1393
- } else {
1394
- errorMessage .append ("\n Action does not discover inputs" );
1395
- }
1396
- if (outputs .contains (input )) {
1397
- errorMessage .append ("\n Input is an *output* of action" );
1398
- }
1399
- if (inputs .contains (input )) {
1400
- errorMessage .append ("\n Input is an input of action, bottom-up path:\n " );
1401
- if (!findPathToKey (
1402
- nestedInputs ,
1403
- input ,
1404
- n -> {
1405
- ImmutableList <Artifact > artifacts = n .toList ();
1406
- errorMessage
1407
- .append (" " )
1408
- .append (artifacts .size ())
1409
- .append (", " )
1410
- .append (Iterables .limit (artifacts , 10 ))
1411
- .append ('\n' );
1412
- },
1413
- Sets .newHashSet (nestedInputs .toNode ()))) {
1414
- errorMessage .append ("Could not find input in action's NestedSet inputs" );
1415
- }
1416
- } else {
1417
- errorMessage .append ("\n Input not present in action's inputs" );
1418
- }
1419
- throw new IllegalStateException (
1420
- String .format (
1421
- "Null value for mandatory %s with no errors or values missing: %s %s %s" ,
1422
- input .toDebugString (),
1423
- actionLookupDataForError ,
1424
- action .prettyPrint (),
1425
- errorMessage ));
1426
- }
1367
+ // Undone mandatory inputs are only expected for generated artifacts when rewinding is
1368
+ // enabled. Returning null allows the caller to use UndoneInputsException to recover.
1369
+ checkState (
1370
+ !isMandatoryInput .test (input )
1371
+ || (input .hasKnownGeneratingAction () && skyframeActionExecutor .rewindingEnabled ()),
1372
+ "Unexpected undone mandatory input: %s" ,
1373
+ input );
1427
1374
return null ;
1428
1375
}
1429
1376
if (value instanceof MissingArtifactValue ) {
1430
- if (isMandatoryInput .test (input )) {
1431
- checkNotNull (
1432
- actionExecutionFunctionExceptionHandler ,
1433
- "Missing artifact should have been caught already %s %s %s" ,
1434
- input ,
1435
- value ,
1436
- action )
1437
- .accumulateMissingFileArtifactValue (input , (MissingArtifactValue ) value );
1438
- return null ;
1439
- } else {
1440
- value = FileArtifactValue .MISSING_FILE_MARKER ;
1377
+ if (!isMandatoryInput .test (input )) {
1378
+ return FileArtifactValue .MISSING_FILE_MARKER ;
1441
1379
}
1380
+ checkNotNull (
1381
+ actionExecutionFunctionExceptionHandler ,
1382
+ "Missing artifact should have been caught already %s %s %s" ,
1383
+ input ,
1384
+ value ,
1385
+ action )
1386
+ .accumulateMissingFileArtifactValue (input , (MissingArtifactValue ) value );
1387
+ return null ;
1442
1388
}
1443
1389
return value ;
1444
1390
}
@@ -1469,21 +1415,6 @@ private SkyValue lookupInput(Artifact input, ImmutableSet<SkyKey> inputDepKeys,
1469
1415
return entry .toValue ();
1470
1416
}
1471
1417
1472
- private static <T > boolean findPathToKey (
1473
- NestedSet <T > start , T target , Consumer <NestedSet <T >> receiver , Set <NestedSet .Node > seen ) {
1474
- if (start .getLeaves ().contains (target )) {
1475
- receiver .accept (start );
1476
- return true ;
1477
- }
1478
- for (NestedSet <T > next : start .getNonLeaves ()) {
1479
- if (seen .add (next .toNode ()) && findPathToKey (next , target , receiver , seen )) {
1480
- receiver .accept (start );
1481
- return true ;
1482
- }
1483
- }
1484
- return false ;
1485
- }
1486
-
1487
1418
static LabelCause createLabelCause (
1488
1419
Artifact input ,
1489
1420
DetailedExitCode detailedExitCode ,
0 commit comments