Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1710095

Summary: SessionId.hashCode generates too many collisions
Product: Red Hat Enterprise Linux 7 Reporter: Aaron Ogburn <aogburn>
Component: java-1.8.0-openjdkAssignee: Andrew John Hughes <ahughes>
Status: CLOSED ERRATA QA Contact: OpenJDK QA <java-qa>
Severity: urgent Docs Contact:
Priority: urgent    
Version: 7.7CC: ahughes, cww, dbhole, jdoyle, jvanek, sgehwolf, zzambers
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: java-1.8.0-openjdk-1.8.0.222.b04-1.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-03-31 19:51:33 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1725255    

Description Aaron Ogburn 2019-05-14 20:58:11 UTC
Description of problem:

The implementation of hashCode() in sun.security.ssl.SessionId generates many collisions.
The SslEngine has a HashMap of SessionIds, and because the hashCode generates many collisions the HashMap gets really slow due to the conversion from List to a Tree of a bucket.

This issue was discovered by studying the following stacktrace:
   java.lang.Thread.State: RUNNABLE
at java.util.HashMap$TreeNode.find(HashMap.java:1878)
at java.util.HashMap$TreeNode.find(HashMap.java:1874)
at java.util.HashMap$TreeNode.find(HashMap.java:1874)
at java.util.HashMap$TreeNode.find(HashMap.java:1874)
at java.util.HashMap$TreeNode.find(HashMap.java:1874)
at java.util.HashMap$TreeNode.find(HashMap.java:1874)
at java.util.HashMap$TreeNode.getTreeNode(HashMap.java:1886)
at java.util.HashMap.removeNode(HashMap.java:824)
at java.util.HashMap.remove(HashMap.java:799)
at sun.security.util.MemoryCache.emptyQueue(Cache.java:299)
at sun.security.util.MemoryCache.get(Cache.java:386)

The MemoryCache class is synchronised and because the HashMap gets really inefficient, many threads were blocked waiting for this class.

The current hashCode implementation is very inefficient, If you generates 10M random SessionId of 32bytes, you can have more than 10K elements with the same hashCode.
The current implementation sum an array of 32 bytes (maximum), which is very similar to the concept of the "probability of 2 dice": http://statweb.stanford.edu/~susan/courses/s60/split/node65.html
Current SessionId.hashCode() implementation:
        for (byte element : a)
            result +=element;

A better implementation of the hashCode for a byte array is the one in Arrays.hashCode(byte[]), that for 10M random SessionId of 32byte collides only 2/3 times maximum for the same hashCode. 

https://bugs.openjdk.java.net/browse/JDK-8203190

Version-Release number of selected component (if applicable):

java-1.8.0-openjdk-1.8.0.212.b04-0.el7_6

How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Comment 1 Andrew John Hughes 2019-05-23 03:37:36 UTC
Part of jdk8u222-b04: https://mail.openjdk.java.net/pipermail/jdk8u-dev/2019-May/009388.html

Comment 6 errata-xmlrpc 2020-03-31 19:51:33 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2020:1071