-
Notifications
You must be signed in to change notification settings - Fork 4.1k
bazel: log spam from metamorphic constants during code generations #76363
Description
We have code generators that pull in go packages that have metamorphic constants. For example, execgen and roachpb/gen both pull in tracing:
> go list -f '{{ join .Deps "\n" }}' ./pkg/sql/colexec/execgen/ | grep tracing | head -1
github.com/cockroachdb/cockroach/pkg/util/tracing
> go list -f '{{ join .Deps "\n" }}' ./pkg/roachpb/gen | grep tracing | head -1
github.com/cockroachdb/cockroach/pkg/util/tracing
which defines a metamorphic constant. When these packages are built with the crdb_test tag, there is a chance that on invocation they will initialize these metamorphic constants to random values and will print log message such as:
initialized metamorphic constant "span-reuse-rate" with value 10
As far as I know, this problem doesn't happen with the Make-based build because we do not set any tags when building utility binaries:
Line 1820 in d10188f
| $(GO_INSTALL) -ldflags '$(LINKFLAGS)' -v $(if $($*-package),$($*-package),./pkg/cmd/$*) |
In #76309 we took care of one of the larger offenders here by setting an environment variable that disables metamorphic constants at runtime. It would be nice to do this for all generators or find a way to build those generators without the crdb_test tag set to avoid this log output.
Epic CRDB-8036
Jira issue: CRDB-13084