Skip to content

Commit

Permalink
Fix nondeterministic output in genquery "somepath" by using a single …
Browse files Browse the repository at this point in the history
…thread.

RELNOTES: Makes genquery somepath output deterministic.
PiperOrigin-RevId: 237080643
  • Loading branch information
Googler authored and copybara-github committed Mar 6, 2019
1 parent 5dce83c commit 566040e
Showing 1 changed file with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
import com.google.devtools.build.lib.query2.BlazeQueryEnvironment;
import com.google.devtools.build.lib.query2.QueryEnvironmentFactory;
import com.google.devtools.build.lib.query2.engine.DigraphQueryEvalResult;
import com.google.devtools.build.lib.query2.engine.QueryEnvironment.QueryFunction;
import com.google.devtools.build.lib.query2.engine.QueryEnvironment.Setting;
import com.google.devtools.build.lib.query2.engine.QueryException;
import com.google.devtools.build.lib.query2.engine.QueryExpression;
Expand Down Expand Up @@ -313,9 +312,6 @@ private ByteString doQuery(
OutputFormatter.formatterNames(OutputFormatter.getDefaultFormatters())));
return null;
}
// All the packages are already loaded at this point, so there is no need
// to start up many threads. 4 are started up to make good use of multiple
// cores.
BlazeQueryEnvironment queryEnvironment =
(BlazeQueryEnvironment)
QUERY_ENVIRONMENT_FACTORY.create(
Expand All @@ -329,12 +325,15 @@ private ByteString doQuery(
ruleContext.attributes().get("strict", Type.BOOLEAN),
/*orderedResults=*/ !QueryOutputUtils.shouldStreamResults(
queryOptions, formatter),
/*universeScope=*/ ImmutableList.<String>of(),
/*loadingPhaseThreads=*/ 4,
/*universeScope=*/ ImmutableList.of(),
// Use a single thread to prevent race conditions causing nondeterministic output
// (b/127644784). All the packages are already loaded at this point, so there is
// no need to start up multiple threads anyway.
/*loadingPhaseThreads=*/ 1,
labelFilter,
getEventHandler(ruleContext),
settings,
ImmutableList.<QueryFunction>of(),
/*extraFunctions=*/ ImmutableList.of(),
/*packagePath=*/ null,
/*blockUniverseEvaluationErrors=*/ false);
QueryExpression expr = QueryExpression.parse(query, queryEnvironment);
Expand Down

0 comments on commit 566040e

Please sign in to comment.