Skip to content

fix: use proto.Equal to compare protobuf messages#125

Merged
kruskall merged 1 commit intomainfrom
fix/race-condition-proto-equal
Nov 26, 2024
Merged

fix: use proto.Equal to compare protobuf messages#125
kruskall merged 1 commit intomainfrom
fix/race-condition-proto-equal

Conversation

@kruskall
Copy link
Copy Markdown
Member

replace reflect deepequal with proto.Equal

reflection is comparing some internal fields used during marshaling, causing race conditions in the beats reloader code.
the race condition causes APM Server tests to fail with the race detector enabled

replace reflect deepequal with proto.Equal

reflection is comparing some internal fields used during marshaling, causing race
conditions in the beats reloader code.
the race condition causes APM Server tests to fail with the race detector enabled
@kruskall kruskall requested a review from a team as a code owner November 26, 2024 20:14
@kruskall kruskall requested review from kaanyalti and michalpristas and removed request for a team November 26, 2024 20:14
@elasticmachine
Copy link
Copy Markdown

💚 Build Succeeded

@cmacknz
Copy link
Copy Markdown
Member

cmacknz commented Nov 26, 2024

I don't think this code is used anymore, but it was wrong before regardless.

@cmacknz
Copy link
Copy Markdown
Member

cmacknz commented Nov 26, 2024

Nevermind, this is in unit.go not the v1 client.

@cmacknz
Copy link
Copy Markdown
Member

cmacknz commented Nov 26, 2024

reflection is comparing some internal fields used during marshaling, causing race conditions in the beats reloader code.

A test to catch this would look like marshalling and then unmarshalling one of the messages under test before using it in the test to populate all the internal fields to get the comparison to fail. Hard to know to do this until you have been burned by this at least once.

@kruskall
Copy link
Copy Markdown
Member Author

fwiw APM Server beats tests fail consistently without this fix: https://github.com/elastic/apm-server/actions/runs/12037657802/job/33561591630?pr=13827

@kruskall kruskall merged commit e5ee8f8 into main Nov 26, 2024
@kruskall kruskall deleted the fix/race-condition-proto-equal branch November 26, 2024 22: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