Skip to content
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

Make CreateWithRemoteFilesOrderedMembersActor thread safe #3477

Merged
merged 1 commit into from Feb 5, 2019

Conversation

mbklein
Copy link
Member

@mbklein mbklein commented Jan 22, 2019

Summary: Prevents instance variable collisions in the CreateWithRemoteFilesOrderedMembersActor

Detailed Description: Since ActionDispatch::MiddlewareStack reuses specific middlewares from a pool at runtime, individual middlewares (such as actors) should not count on having mutable instance variables. In this case, that manifested through the @ordered_members accumulator on the CreateWithRemoteFilesOrderedMembersActor actor, which ended up with a jumble of unrelated file sets under heavy ingest load (such as a batch ingest operation).

Changes proposed in this pull request:

  • Add thread-safe store and retrieve methods to the environment that gets passed around among actors.
  • Use environment storage instead of instance variables in the CreateWithRemoteFilesOrderedMembersActor actor.

Guidance for testing, such as acceptance criteria or new user interface behaviors:

  • There isn't a great way to test this live without throwing a few hundred multi-fileset works at it in a single batch. I did add a threaded spec test that fails on the existing master branch and passes on this commit.

@samvera/hyrax-code-reviewers

Add re-entry test for CreateWithRemoteFilesOrderedMembersActor
@mbklein mbklein requested a review from a user January 22, 2019 19:22
@no-reply
Copy link
Member

no-reply commented Feb 5, 2019

@mbklein this looks good to me. I'm frustrated that we need to store so much state in the env, and expand its interface to do so, but I'm not inclined to spend much time engineering a better solution. I think our energy is better spent on deprecating the stack. :|

Is this going to be an issue for other actors that use instance variables? e.g. https://github.com/samvera/hyrax/blob/master/app/actors/hyrax/actors/interpret_visibility_actor.rb#L6

Copy link
Member

@no-reply no-reply left a comment

Choose a reason for hiding this comment

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

👍

@no-reply
Copy link
Member

no-reply commented Feb 5, 2019

Do we want a backport to 2.x?

@mbklein
Copy link
Member Author

mbklein commented Feb 5, 2019

I'm frustrated that we need to store so much state in the env, and expand its interface to do so, but I'm not inclined to spend much time engineering a better solution.

Likewise.

Do we want a backport to 2.x?

Yes, I think so.

@mbklein
Copy link
Member Author

mbklein commented Feb 5, 2019

Is this going to be an issue for other actors that use instance variables?

Only if 1) the instance variables are part of the Actor class itself (not a contained class, as in the example you provided), and 2) the instance variables are expected to be mutable within the scope of the create/update/delete methods. I couldn't find any other examples of vulnerable instance vars in the existing actor stack.

@no-reply no-reply merged commit b775c5b into master Feb 5, 2019
@no-reply
Copy link
Member

no-reply commented Feb 5, 2019

Thanks!

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.

None yet

3 participants