Skip to content

8323659: LinkedTransferQueue add and put methods call overridable offer #17393

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

Closed
wants to merge 8 commits into from

Conversation

ChrisHegarty
Copy link
Member

@ChrisHegarty ChrisHegarty commented Jan 12, 2024

Update LinkedTransferQueue add and put methods to not call overridable offer.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8323659: LinkedTransferQueue add and put methods call overridable offer (Bug - P2)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/17393/head:pull/17393
$ git checkout pull/17393

Update a local copy of the PR:
$ git checkout pull/17393
$ git pull https://git.openjdk.org/jdk.git pull/17393/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 17393

View PR using the GUI difftool:
$ git pr show -t 17393

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/17393.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jan 12, 2024

👋 Welcome back chegar! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Jan 12, 2024

@ChrisHegarty The following label will be automatically applied to this pull request:

  • core-libs

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the core-libs core-libs-dev@openjdk.org label Jan 12, 2024
@ChrisHegarty
Copy link
Member Author

/issue add JDK-8323659

@openjdk openjdk bot changed the title Update LinkedTransferQueue add and put methods to not call overridable 8323659: LinkedTransferQueue add and put methods call overridable offer Jan 12, 2024
@openjdk
Copy link

openjdk bot commented Jan 12, 2024

@ChrisHegarty The primary solved issue for a PR is set through the PR title. Since the current title does not contain an issue reference, it will now be updated.

@ChrisHegarty ChrisHegarty marked this pull request as ready for review January 12, 2024 10:54
@openjdk openjdk bot added the rfr Pull request is ready for review label Jan 12, 2024
@mlbridge
Copy link

mlbridge bot commented Jan 12, 2024

@AlanBateman
Copy link
Contributor

This feels more like a hazard when extending to override behavior. I think it would be useful to provide a summary on what the override wants to do, maybe there are better ways to customise by wrapping the LTQ rather than subclassing.

@pavelrappo
Copy link
Member

A process-related comment: this PR is against mainline, but the issue's Fix Version/s is 22. This will create a bit of a mess if integrated.

@ChrisHegarty
Copy link
Member Author

ChrisHegarty commented Jan 12, 2024

This feels more like a hazard when extending to override behavior.

Yeah, this is certainly a potential issue with any subclass-able class. I remember seeing similar before in other areas too.

I think it would be useful to provide a summary on what the override wants to do, maybe there are better ways to customise by wrapping the LTQ rather than subclassing.

Yeah, and we can likely refactor our code to workaround this change in JDK 22. I added a summary and reproducer in the JIRA, which should help. I'll try to explain a little here. The crux of what the code is attempting to do is to scale the executor to max pool size by refusing tasks if there the pool is less than the max, then later intercepting rejections and putting the task on the queue.

@ChrisHegarty
Copy link
Member Author

A process-related comment: this PR is against mainline, but the issue's Fix Version/s is 22. This will create a bit of a mess if integrated.

Thanks for the reminder Pavel. If accepted, then the change will be applicable to 23, 22, and 21. 0.2. I'll fix up and retarget the appropriate branches, repos, once we agree a way forward.

@ChrisHegarty
Copy link
Member Author

this PR is against mainline, but the issue's Fix Version/s is 22.

I updated the fix version in JIRA, and followed the process as outlined in https://mail.openjdk.org/pipermail/jdk-dev/2023-December/008560.html

@viktorklang-ora
Copy link
Contributor

@ChrisHegarty My 2¢—this change could impact existing classes which have extended LTQ and knowingly, or unknowingly, presume that add and put delegate to offer, which would (silently) break those classes when running on a newer JDK (presuming this change gets merged).

I think the change is in principle correct, with that said, I want to make sure that the change is worth the potential compatibility risk (if any).

@ChrisHegarty
Copy link
Member Author

ChrisHegarty commented Jan 12, 2024

@ChrisHegarty My 2¢—this change could impact existing classes which have extended LTQ and knowingly, or unknowingly, presume that add and put delegate to offer, which would (silently) break those classes when running on a newer JDK (presuming this change gets merged).

I think the change is in principle correct, with that said, I want to make sure that the change is worth the potential compatibility risk (if any).

Hi @viktorklang-ora , I agree with your comment regarding the potential impact, and the assumption of the implementation, however, you got it the wrong way round! ;-) The change I am proposing restores previous behaviour to pre-JDK 22. It is JDK 22 that has changed this. This is exactly why I am proposing the change

@viktorklang-ora
Copy link
Contributor

@ChrisHegarty 😅 Well then I agree

@ChrisHegarty
Copy link
Member Author

ChrisHegarty commented Jan 12, 2024

FTR - I agree that it's kinda annoying to be proposing this change and it is true that the consuming user code is making an assumption, but the impact of this is significant - leads to apparently vanishing tasks when Elasticsearch runs on JDK 22 EA. The proposed changes are extremely minimal.

If @DougLea agrees, then I'll add a minimal test case and get the PR into a clean state.

@ChrisHegarty
Copy link
Member Author

Additionally, we absolutely need to fix this in JDK 21.0.2 - since a patch release should not change behaviour (from 21.0.1), in this way.

@dholmes-ora
Copy link
Member

dholmes-ora commented Jan 15, 2024

With my CSR hat on, JDK-8301341 should never have made the changes it did without going through a CSR request. We have been bitten by this kind of problem many times. Unless a public method is specified to utilise another public method, we should never implement one public method in terms of another (non-final one) due to the overriding problem. Backporting such a change to 21u is then potentially very damaging.

…rQueue.java

Co-authored-by: Andrey Turbanov <turbanoff@gmail.com>
@AlanBateman
Copy link
Contributor

With my CSR hat on, JDK-8301341 should never have made the changes it did without going through a CSR request. We have been bitten by this kind of problem many times. Unless a public method is specified to utilise another public method, we should never implement one public method in terms of another (non-final one) due to the overriding problem.

JDK-8301341 was a big update, a lot of refactoring to hollow out SQ and it was just an oversight that we didn't spot the methods now use an overridable method. It's something to always look out for in the collections area, just missed here.

@ChrisHegarty
Copy link
Member Author

ChrisHegarty commented Jan 15, 2024

It's unfortunate that we're only discovering this now, since 21.0.2 is scheduled to release tomorrow, Jan 16th, and we've not yet gotten this reviewed and merged into master or jdk22 yet. We can decided how to proceed with the backports once this PR has agreed the approach and is reviewed.

@DougLea
Copy link
Contributor

DougLea commented Jan 15, 2024

Sorry for needlessly calling overridable versions in these two cases. I should have caught that.

@ChrisHegarty
Copy link
Member Author

Sorry for needlessly calling overridable versions in these two cases. I should have caught that.

No problem, easy to overlook. I assume you are ok with the changes? If so, could I please ask you to add your review. Otherwise, is there another way that we should proceed?

@openjdk
Copy link

openjdk bot commented Jan 15, 2024

@ChrisHegarty This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8323659: LinkedTransferQueue add and put methods call overridable offer

Reviewed-by: alanb

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been no new commits pushed to the master branch. If another commit should be pushed before you perform the /integrate command, your PR will be automatically rebased. If you prefer to avoid any potential automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jan 15, 2024
@DougLea
Copy link
Contributor

DougLea commented Jan 15, 2024

Yes, the change looks right to me -- changing the only two calls that could matter here.

@ChrisHegarty
Copy link
Member Author

Thanks for the reviews @AlanBateman and @DougLea

@ChrisHegarty
Copy link
Member Author

/integrate

@openjdk
Copy link

openjdk bot commented Jan 16, 2024

Going to push as commit ee4d9aa.
Since your change was applied there have been 4 commits pushed to the master branch:

  • 5045839: 8323635: Test gc/g1/TestHumongousAllocConcurrentStart.java fails with -XX:TieredStopAtLevel=3
  • 44a9392: 8323780: Serial: Remove unused _full_collections_completed
  • 5906240: 8323716: Only print ZGC Phase Switch events in hs_err files when running with ZGC
  • e01f6da: 8320175: [BACKOUT] 8316533: C2 compilation fails with assert(verify(phase)) failed: missing Value() optimization

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Jan 16, 2024
@openjdk openjdk bot closed this Jan 16, 2024
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jan 16, 2024
@openjdk
Copy link

openjdk bot commented Jan 16, 2024

@ChrisHegarty Pushed as commit ee4d9aa.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@jddarcy
Copy link
Member

jddarcy commented Jan 16, 2024

With my CSR hat on, JDK-8301341 should never have made the changes it did without going through a CSR request. We have been bitten by this kind of problem many times. Unless a public method is specified to utilise another public method, we should never implement one public method in terms of another (non-final one) due to the overriding problem.

JDK-8301341 was a big update, a lot of refactoring to hollow out SQ and it was just an oversight that we didn't spot the methods now use an overridable method. It's something to always look out for in the collections area, just missed here.

We can and have run retroactive CSRs in cases like this before; I recommend we do one now.

@AlanBateman
Copy link
Contributor

We can and have run retroactive CSRs in cases like this before; I recommend we do one now.

Yes although the issue will be mute once JDK-8323659 is integrated into jdk22.

@ChrisHegarty
Copy link
Member Author

I just integrated the fix into jdk 22, so we’re good there now.

The final piece of the puzzle is jdk 21.0.2, which we’re too late to fix. We can add a release note, and fix it in 21.0.3. Any objections or alternative suggestions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core-libs core-libs-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

8 participants