Skip to content

fix: fix thread safety issue in engine invoke #272

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 3, 2025

Conversation

PeterSchafer
Copy link
Contributor

No description provided.

@PeterSchafer PeterSchafer requested review from a team as code owners October 31, 2024 09:33
Copy link
Member

@thisislawatts thisislawatts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue(blocking): Similar to my comment #271 (comment), can we introduce a test which captures the desired behaviour before merging this item.

@bastiandoetsch
Copy link
Contributor

This is stalled. Are we planning on continuing this PR?

@PeterSchafer PeterSchafer force-pushed the fix/engine_concurrency branch from 7559cd6 to 0319c06 Compare March 18, 2025 08:52
@PeterSchafer PeterSchafer force-pushed the fix/engine_concurrency branch from 0319c06 to 2bd6237 Compare April 2, 2025 19:29
@PeterSchafer PeterSchafer dismissed thisislawatts’s stale review April 2, 2025 19:31

Opening up for others to review

@PeterSchafer
Copy link
Contributor Author

@bastiandoetsch I added a test and adapted the critical section a bit. Could you please re-review? I think it would be good to get this merged.

@@ -247,21 +251,25 @@ func (e *EngineImpl) InvokeWithInputAndConfig(

// prepare logger
prefix := fmt.Sprintf("%s:%d", id.Host, e.invocationCounter)
e.mu.Unlock()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, we'd in general only need a read-lock (and an RWMutex). Nothing blocking though. Should the lock maybe even start earlier, e.g. in L240 to avoid init races?

zlogger := e.logger.With().Str("ext", prefix).Logger()

localConfig := e.config
localNetwork := e.networkAccess
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd find it more intuitive, to have localNetwork never contain e.networkAccess, but the clone directly on assignment - that way it is always local. Same for config.


// create a context object for the invocation
context := NewInvocationContext(id, config, e, networkAccess, zlogger, e.analytics, e.ui)
context := NewInvocationContext(id, config, e, networkAccess, zlogger, localAnalytics, localUi)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why a new network access, if you already have the localNetwork? Confused me briefly, why networkAccess is passed instead of localNetwork

networkAccess.SetConfiguration(config)
e.mu.Unlock()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need the additional networkAccess variable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we need it, since we set the given configuration, which should have a side effect on the engine networkAccess.

@PeterSchafer PeterSchafer force-pushed the fix/engine_concurrency branch from 2bd6237 to a5b2a0a Compare April 3, 2025 08:11
@PeterSchafer PeterSchafer merged commit 80a6150 into main Apr 3, 2025
9 checks passed
@PeterSchafer PeterSchafer deleted the fix/engine_concurrency branch April 3, 2025 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants