You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by sh...@apache.org on 2025/09/18 18:52:17 UTC
(beam) branch master updated: Only report timeout duration parsing error during harness start. (#36194)
This is an automated email from the ASF dual-hosted git repository.
shunping pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/beam.git
The following commit(s) were added to refs/heads/master by this push:
new a0d5c87ec75 Only report timeout duration parsing error during harness start. (#36194)
a0d5c87ec75 is described below
commit a0d5c87ec757529e8a903abd38897f43bc89b936
Author: Shunping Huang <sh...@google.com>
AuthorDate: Thu Sep 18 14:52:10 2025 -0400
Only report timeout duration parsing error during harness start. (#36194)
* Only report timeout duration parsing error during harness start.
* Lower that message log level to info.
* Add elmTimeout in control struct.
---
sdks/go/pkg/beam/core/runtime/harness/harness.go | 17 +++++----
.../pkg/beam/core/runtime/harness/harness_test.go | 40 ++++++++++++----------
2 files changed, 32 insertions(+), 25 deletions(-)
diff --git a/sdks/go/pkg/beam/core/runtime/harness/harness.go b/sdks/go/pkg/beam/core/runtime/harness/harness.go
index cc1e53d02d2..d75ae37c610 100644
--- a/sdks/go/pkg/beam/core/runtime/harness/harness.go
+++ b/sdks/go/pkg/beam/core/runtime/harness/harness.go
@@ -99,6 +99,11 @@ func MainWithOptions(ctx context.Context, loggingEndpoint, controlEndpoint strin
go diagnostics.SampleForHeapProfile(ctx, samplingFrequencySeconds, maxTimeBetweenDumpsSeconds)
}
+ elmTimeout, err := parseTimeoutDurationFlag(ctx, beam.PipelineOptions.Get("element_processing_timeout"))
+ if err != nil {
+ log.Infof(ctx, "Failed to parse element_processing_timeout: %v, there will be no timeout for processing an element in a PTransform operation", err)
+ }
+
// Connect to FnAPI control server. Receive and execute work.
conn, err := dial(ctx, controlEndpoint, "control", 60*time.Second)
if err != nil {
@@ -157,6 +162,7 @@ func MainWithOptions(ctx context.Context, loggingEndpoint, controlEndpoint strin
state: &StateChannelManager{},
cache: &sideCache,
runnerCapabilities: rcMap,
+ elmTimeout: elmTimeout,
}
if enabled, ok := rcMap[graphx.URNDataSampling]; ok && enabled {
@@ -312,6 +318,7 @@ type control struct {
cache *statecache.SideInputCache
runnerCapabilities map[string]bool
dataSampler *exec.DataSampler
+ elmTimeout time.Duration
}
func (c *control) metStoreToString(statusInfo *strings.Builder) {
@@ -410,9 +417,8 @@ func (c *control) handleInstruction(ctx context.Context, req *fnpb.InstructionRe
data := NewScopedDataManager(c.data, instID)
state := NewScopedStateReaderWithCache(c.state, instID, c.cache)
- timeoutDuration := parseTimeoutDurationFlag(ctx, beam.PipelineOptions.Get("element_processing_timeout"))
- sampler := newSampler(store, timeoutDuration)
+ sampler := newSampler(store, c.elmTimeout)
go func() {
samplerErr := sampler.start(ctx, samplePeriod)
if samplerErr != nil {
@@ -701,13 +707,12 @@ func (c *control) handleInstruction(ctx context.Context, req *fnpb.InstructionRe
// Parses the element_processing_timeout flag and returns the corresponding time.Duration.
// The element_processing_timeout flag is expected to be a duration string (e.g., "5m", "1h", etc.)or -1.
// Otherwise, it defaults to no timeout (0 minutes).
-func parseTimeoutDurationFlag(ctx context.Context, elementProcessingTimeout string) time.Duration {
+func parseTimeoutDurationFlag(ctx context.Context, elementProcessingTimeout string) (time.Duration, error) {
userSpecifiedTimeout, err := time.ParseDuration(elementProcessingTimeout)
if err != nil {
- log.Warnf(ctx, "Failed to parse element_processing_timeout: %v, there will be no timeout for processing an element in a PTransform operation", err)
- return 0 * time.Minute
+ return 0 * time.Minute, err
}
- return userSpecifiedTimeout
+ return userSpecifiedTimeout, nil
}
// getPlanOrResponse returns the plan for the given instruction id.
diff --git a/sdks/go/pkg/beam/core/runtime/harness/harness_test.go b/sdks/go/pkg/beam/core/runtime/harness/harness_test.go
index 79ca26e3d2a..96e09d226f5 100644
--- a/sdks/go/pkg/beam/core/runtime/harness/harness_test.go
+++ b/sdks/go/pkg/beam/core/runtime/harness/harness_test.go
@@ -234,25 +234,27 @@ func TestCircleBuffer(t *testing.T) {
func TestElementProcessingTimeoutParsing(t *testing.T) {
ctx := context.Background()
- if got, want := parseTimeoutDurationFlag(ctx, "5m"), 5*time.Minute; got != want {
- t.Errorf("parseTimeoutDurationFlag() = %v, want %v", got, want)
- }
- if got, want := parseTimeoutDurationFlag(ctx, "1h"), 1*time.Hour; got != want {
- t.Errorf("parseTimeoutDurationFlag() = %v, want %v", got, want)
- }
- if got, want := parseTimeoutDurationFlag(ctx, "1m5s"), 1*time.Minute+5*time.Second; got != want {
- t.Errorf("parseTimeoutDurationFlag() = %v, want %v", got, want)
- }
- if got, want := parseTimeoutDurationFlag(ctx, "5s1m"), 5*time.Second+1*time.Minute; got != want {
- t.Errorf("parseTimeoutDurationFlag() = %v, want %v", got, want)
- }
- if got, want := parseTimeoutDurationFlag(ctx, "-1"), 0*time.Minute; got != want {
- t.Errorf("parseTimeoutDurationFlag() = %v, want %v", got, want)
- }
- if got, want := parseTimeoutDurationFlag(ctx, ""), 0*time.Minute; got != want {
- t.Errorf("parseTimeoutDurationFlag() = %v, want %v", got, want)
+ tests := []struct {
+ in string
+ want time.Duration
+ err bool
+ }{
+ {"5m", 5 * time.Minute, false},
+ {"1h", 1 * time.Hour, false},
+ {"1m5s", 1*time.Minute + 5*time.Second, false},
+ {"5s1m", 5*time.Second + 1*time.Minute, false},
+ {"-1", 0, true},
+ {"", 0, true},
+ {"5mmm", 0, true},
}
- if got, want := parseTimeoutDurationFlag(ctx, "5mmm"), 0*time.Minute; got != want {
- t.Errorf("parseTimeoutDurationFlag() = %v, want %v", got, want)
+
+ for _, test := range tests {
+ got, err := parseTimeoutDurationFlag(ctx, test.in)
+ if (err != nil) != test.err {
+ t.Errorf("parseTimeoutDurationFlag(ctx, %q) err = %v, want err? %v", test.in, err, test.err)
+ }
+ if got != test.want {
+ t.Errorf("parseTimeoutDurationFlag(ctx, %q) = %v, want %v", test.in, got, test.want)
+ }
}
}