-
Notifications
You must be signed in to change notification settings - Fork 155
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
2.7.8/3.0.1: BatchFetchType.IN causes IndexOutOfBoundsException in ForeignReferenceMapping.extractResultsFromBatchQuery #1148
Comments
Updated the linked project to use Eclipselink 3.1.0-M1 and the issue is still present. So I assume it is also still present in latest 2.7.x release. Would be great if anybody could take a look at it. |
rfelcman
added a commit
to rfelcman/eclipselink
that referenced
this issue
Feb 10, 2022
…reignReferenceMapping.extractResultsFromBatchQuery Fixes eclipse-ee4j#1148 (bugfix + unit test) Signed-off-by: Radek Felcman <radek.felcman@oracle.com>
rfelcman
added a commit
to rfelcman/eclipselink
that referenced
this issue
Feb 11, 2022
…eMapping.extractResultsFromBatchQuery (eclipse-ee4j#1426) Fixes eclipse-ee4j#1148 (bugfix + unit test) Signed-off-by: Radek Felcman <radek.felcman@oracle.com>
rfelcman
added a commit
to rfelcman/eclipselink
that referenced
this issue
Feb 11, 2022
…eMapping.extractResultsFromBatchQuery (eclipse-ee4j#1426) Fixes eclipse-ee4j#1148 (bugfix + unit test) Signed-off-by: Radek Felcman <radek.felcman@oracle.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have found https://bugs.eclipse.org/bugs/show_bug.cgi?id=412056 which describes the same issue, but even though it is marked as fixed for 2.6.x I can still reproduce the
IndexOutOfBoundsException
. The only workaround is to either set batch size very large so that a second batch query never has to be executed or using left fetch instead of batch fetch.The main difference between the bug mentioned above and the code I used to reproduce the bug is a second level of batch fetches.
So instead of
I use
with batch fetch hint
assessment.answers.tags
for a querySELECT assessment FROM Assessment assessment where assessment.id IN(...)
. The code then iterates in a randomized order through the result list of the query and first triggers batch fetch forassessment.answers
and then batch fetch foranswers.tags
(which is the one that fails).The concrete code can be seen in an example project that reproduces the issue:
Repo: https://github.com/CareCloud-GmbH/eclipselink-batch-fetch-bug
Main Class: https://github.com/CareCloud-GmbH/eclipselink-batch-fetch-bug/blob/main/src/main/java/eclipselink/bugs/batchfetch/App.java
When you use
./gradlew run
it should launch the main class and you should see anIndexOutOfBoundsException
. The code tries to produce the exception within 100 rounds of execution. It usually fails within the first few rounds but in the very rare case the code completes without exception, re-run the code. It sometimes succeeds becauseCollections.shuffle()
does not guarantee to rearrange the iteration order in a way that causes the issue.The output should look like
The root cause is the same as in the issue mentioned above: The
AbstractRecord
(sourceRow
) for theAnswer
that triggered the batch fetch usingtags.size()
is not available inBatchFetchPolicy.dataResults
(originalPolicy
). Thus the index searchparentRows.indexOf(sourceRow)
returns-1
and finally causes the exception in the first for loop (offset = -1, i = 0
).eclipselink/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/mappings/ForeignReferenceMapping.java
Lines 566 to 592 in 77a8c76
The text was updated successfully, but these errors were encountered: