Skip to content

Updated Visitor function to avoid modifying config as it needs to remain #3086

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
Aug 8, 2025

Conversation

ivakegg
Copy link
Collaborator

@ivakegg ivakegg commented Aug 5, 2025

thread safe

Copy link
Collaborator

@FineAndDandy FineAndDandy left a comment

Choose a reason for hiding this comment

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

can you please add a unit test that covers this case?

@ivakegg
Copy link
Collaborator Author

ivakegg commented Aug 5, 2025

can you please add a unit test that covers this case?

Since this is fixing a thread safety issue, I am not sure how to actually do that. There are already tests for the large list visitor and the visitor function. What exactly are you thinking here?

@FineAndDandy
Copy link
Collaborator

Maybe I should restate that. We should either add some tests that prove the code is thread safe, or update the code to make it more difficult to do thread unsafe activities like modifying the config inside the VisitorFunction. We could prevent changes to the config via an immutable copy being made inside the VisitorFunction, or alternatively, creating a new interface on the config which is read only and then using that inside the VisitorFunction? Either way we create a programmatic barrier to a regression if we aren't going to create tests that validate the bug/assumption?

@ivakegg
Copy link
Collaborator Author

ivakegg commented Aug 6, 2025

Maybe I should restate that. We should either add some tests that prove the code is thread safe, or update the code to make it more difficult to do thread unsafe activities like modifying the config inside the VisitorFunction. We could prevent changes to the config via an immutable copy being made inside the VisitorFunction, or alternatively, creating a new interface on the config which is read only and then using that inside the VisitorFunction? Either way we create a programmatic barrier to a regression if we aren't going to create tests that validate the bug/assumption?

Ah, an immutable config is a great idea. I will go ahead and work through that. Making everything underneath of the config immutable will be an effort and I am sure this will not introduce any other bugs ;)

@ivakegg
Copy link
Collaborator Author

ivakegg commented Aug 6, 2025

I renig on my statement. An immutable config is NOT a great idea. The amount of code and the maintenance on that is huge. Also trying to ensure that the config is not held onto in the VisitorFunction is not doable as we use a good number of the items in the various visitors being used therein. I am not finding a good way to ensure thread safety except for using good programming practices and NOT modifying anything in the config. As it turns out there is an FSTcount AtomicBoolean which needs to be modified. So I am not all to sure where to go from here.

@ivakegg
Copy link
Collaborator Author

ivakegg commented Aug 7, 2025

OK, decided on making a imutable ShardQueryConfiguration interface that can be passed through. This will at least make the programmer aware that mutating is bad.

@ivakegg
Copy link
Collaborator Author

ivakegg commented Aug 7, 2025

Given the ImmutableShardQueryConfiguration interface results in so many changes, I am separating that off into a separate PR. Please see #3091 . Requesting approval of this one for expedience sake with the other one soon to follow.

@alerman alerman merged commit 31f6492 into integration Aug 8, 2025
5 checks passed
ivakegg added a commit that referenced this pull request Aug 11, 2025
ivakegg added a commit that referenced this pull request Aug 11, 2025
ivakegg added a commit that referenced this pull request Aug 11, 2025
ivakegg added a commit that referenced this pull request Aug 11, 2025
ivakegg added a commit that referenced this pull request Aug 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants