Skip to content

Conversation

@Shivs11
Copy link
Member

@Shivs11 Shivs11 commented Mar 17, 2025

What changed?

fixed some code to reduce versioning flakes by making the logger library thread-safe to avoid data race, and one test with a context timeout issue:
TestVersioning3FunctionalSuite/TestUnpinnedWorkflowWithRamp_ToUnversioned (with_logger data-race ✅)

TestWorkerDeploymentSuite/TestSetWorkerDeploymentRampingVersion_Unversioned_VersionedCurrent ( context timeout - maybe fixed by having a separate go-routine ✅ )

TestDeploymentVersionSuite/TestDrainageStatus_SetCurrentVersion_YesOpenWFs (with_logger data-race ✅)

TestVersioningFunctionalSuite/TestDispatchActivityFailCrossTq (retry 2) (with_logger data-race ✅)

Why?

  • To stop these from appearing as flakes in the test reports.

How did you test it?

  • Ran this locally with -race and now see no errors (errored out previously)
  • Ran this on CI a bunch of times without errors/flakes

Potential risks

Documentation

Is hotfix candidate?

@Shivs11 Shivs11 requested a review from a team as a code owner March 17, 2025 15:16
@Shivs11 Shivs11 merged commit 50698f6 into main Mar 17, 2025
50 checks passed
@Shivs11 Shivs11 deleted the ss/versioning_flakes_pt2 branch March 17, 2025 16:38

func (l *withLogger) prependTags(tags []tag.Tag) []tag.Tag {
return append(l.tags, tags...)
allTags := make([]tag.Tag, len(l.tags)+len(tags))
Copy link
Member Author

@Shivs11 Shivs11 Mar 17, 2025

Choose a reason for hiding this comment

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

pasting this for a reader from the future: this function was being accessed by multiple go-routines and was resulting in a race condition. append becomes a read+write operation when the underlying array for the slice has it's length reached the slice's max-capacity. This results in a new slice being made (hence a write operation) leading to potential data-races.

For a better, more detailed explanation: https://medium.com/@cep21/gos-append-is-not-always-thread-safe-a3034db7975

Comment on lines +53 to +54
copy(allTags, l.tags)
copy(allTags[len(l.tags):], tags)
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible that the l.tags changed (like expanded) after allTags is created, will that cause trouble as allTags may not be big enough to hold l.tags?

Copy link
Member Author

Choose a reason for hiding this comment

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

Looking at the code now, I don't think so - the reason being, this change effectively removes appending to l.tags without making a new withLogger instance - in other words, l.tags will grow when someone adds new tags to it which happens in WithLogger.With. However, WithLogger.With returns a new instance of the logger which shall have a new instance of l.tags

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.

4 participants