Skip to content

Remove the require lock on LoadError#7074

Merged
headius merged 1 commit intojruby:jruby-9.3from
headius:always_remove_require_lock
Feb 8, 2022
Merged

Remove the require lock on LoadError#7074
headius merged 1 commit intojruby:jruby-9.3from
headius:always_remove_require_lock

Conversation

@headius
Copy link
Member

@headius headius commented Feb 7, 2022

Leaving this lock in place indicates to later feature tests that
the file was never loaded, incorrectly causing autoload constant
lookups to fail to load the file a second time. Instead, we
always remove any lock set up for the require so the feature does
not look like it is still in the process of loading.

See #7070

This is a WIP and we will see how it handles tests. I believe I originally added the destroyLock logic to form fit behavior to some spec, but I cannot remember which spec behavior led me to doing this. It seems wrong now to leave the lock in place under any circumstances, since it will interfere with future attempts to load that file (the case in #7070).

LoadError should be treated as a completed load for locking
locking purposes, since it means an attempt was made to load the
file and that load completed with an error condition. This appears
to be different than the behavior for other errors that are raised
which should leave the require as being in-progress.
@headius headius force-pushed the always_remove_require_lock branch from b3da014 to 822f6ff Compare February 7, 2022 17:26
@headius
Copy link
Member Author

headius commented Feb 7, 2022

Specs did not like the first attempt here to clear locks no matter what!

When an error is raised from a loading file, we should allow any other concurrent require to proceed in its attempt to load the file. The LoadError case should clear the lock so that the file does not appear to have successfully loaded.

This logic around the lock may need some extra bits, like detecting if there are others waiting on this require. I believe the cases are as follows:

  • LoadError raised when attempting to load the file, assume other threads would also error and remove the lock.
  • Any other StandardEror, allow other threads to attempt the load with the same lock.

@headius headius changed the title Always remove the require lock Remove the require lock on LoadError Feb 7, 2022
@headius headius merged commit ced1962 into jruby:jruby-9.3 Feb 8, 2022
@headius headius deleted the always_remove_require_lock branch February 8, 2022 22:58
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.

1 participant