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

Fix Bug - Handle unsigned long in sorting order assertion of LongHashSet #17207

Conversation

Shailesh-Kumar-Singh
Copy link
Contributor

@Shailesh-Kumar-Singh Shailesh-Kumar-Singh commented Jan 30, 2025

Description

The assertion logic in LongHashSet.java assumes signed long values, which leads to incorrect validation when dealing with unsigned long values. The sorted order check fails because value >= previousValue does not correctly handle unsigned comparisons.
I have described the Bug in detail in the issue - #17206

FIX

  1. Created a new class UnsignedLongHashSet.java which does Long.compareUnsigned(value, previousValue) >= 0 for unsigned long values.
  2. Added Tests for this here - DocValuesUnsignedLongHashSetTests.java
  3. in SortedUnsignedLongDocValuesSetQuery.java - We use new UnsignedLongHashSet instead of new LongHashSet

Related Issues

Resolves #17206

Check List

  • Functionality includes testing.
  • API changes companion pull request created, if applicable.
  • Public documentation issue/PR created, if applicable.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Copy link
Contributor

✅ Gradle check result for 5844005: SUCCESS

Copy link

codecov bot commented Jan 30, 2025

Codecov Report

Attention: Patch coverage is 80.00000% with 11 lines in your changes missing coverage. Please review.

Project coverage is 72.45%. Comparing base (0ffed5e) to head (bededa9).
Report is 16 commits behind head on main.

Files with missing lines Patch % Lines
...rg/opensearch/lucene/util/UnsignedLongHashSet.java 79.62% 4 Missing and 7 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #17207      +/-   ##
============================================
+ Coverage     72.42%   72.45%   +0.02%     
- Complexity    65611    65657      +46     
============================================
  Files          5304     5307       +3     
  Lines        304743   304648      -95     
  Branches      44189    44178      -11     
============================================
+ Hits         220701   220718      +17     
+ Misses        65888    65838      -50     
+ Partials      18154    18092      -62     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Shailesh-Kumar-Singh Shailesh-Kumar-Singh force-pushed the handle-unsigned-long-SEARCH_INDEXING branch from 5844005 to c967d83 Compare February 5, 2025 05:54
@Shailesh-Kumar-Singh Shailesh-Kumar-Singh force-pushed the handle-unsigned-long-SEARCH_INDEXING branch from f5a6b7f to 147ae64 Compare February 24, 2025 07:19
Copy link
Contributor

❌ Gradle check result for 147ae64: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Copy link
Contributor

❌ Gradle check result for 33c3a97: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Signed-off-by: Shailesh Singh <[email protected]>
Signed-off-by: Shailesh Singh <[email protected]>
@Shailesh-Kumar-Singh Shailesh-Kumar-Singh force-pushed the handle-unsigned-long-SEARCH_INDEXING branch from 33c3a97 to 71b251b Compare February 24, 2025 07:46
Copy link
Contributor

❌ Gradle check result for 71b251b: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Copy link
Contributor

❌ Gradle check result for 0da60b1: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@Shailesh-Kumar-Singh Shailesh-Kumar-Singh force-pushed the handle-unsigned-long-SEARCH_INDEXING branch from 7eff33b to f3883d0 Compare February 28, 2025 07:29
Copy link
Contributor

❌ Gradle check result for f3883d0: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Copy link
Contributor

❌ Gradle check result for 2cc8480: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Copy link
Contributor

❌ Gradle check result for 2cc8480: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@reta
Copy link
Collaborator

reta commented Feb 28, 2025

@Shailesh-Kumar-Singh could you rebase please? Thank you

Copy link
Contributor

github-actions bot commented Mar 1, 2025

❕ Gradle check result for 956b615: UNSTABLE

Please review all flaky tests that succeeded after retry and create an issue if one does not already exist to track the flaky failure.

…shSet.java

Co-authored-by: Andriy Redko <[email protected]>
Signed-off-by: Shailesh Singh <[email protected]>
Copy link
Contributor

github-actions bot commented Mar 3, 2025

✅ Gradle check result for bededa9: SUCCESS

@reta reta merged commit 82bbdfb into opensearch-project:main Mar 5, 2025
30 checks passed
@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.x failed:

The process '/usr/bin/git' failed with exit code 128

To backport manually, run these commands in your terminal:

# Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/OpenSearch/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/OpenSearch/backport-2.x
# Create a new branch
git switch --create backport/backport-17207-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 82bbdfb71f127367ba1c6f36d7a1e68f4fa182cd
# Push it to GitHub
git push --set-upstream origin backport/backport-17207-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/OpenSearch/backport-2.x

Then, create a pull request where the base branch is 2.x and the compare/head branch is backport/backport-17207-to-2.x.

mayanksharma27 pushed a commit to mayanksharma27/OpenSearch that referenced this pull request Mar 5, 2025
…Set (opensearch-project#17207)

* Fix Bug - handle unsigned long in assertion of LongHashSet

Signed-off-by: Shailesh Singh <[email protected]>

* renamed TestDocValuesUnsignedLongHashSet.java to DocValuesUnsignedLongHashSetTests.java

Signed-off-by: Shailesh Singh <[email protected]>

* Update server/src/main/java/org/opensearch/lucene/util/UnsignedLongHashSet.java

Co-authored-by: Andriy Redko <[email protected]>
Signed-off-by: Shailesh Singh <[email protected]>

---------

Signed-off-by: Shailesh Singh <[email protected]>
Signed-off-by: Shailesh Singh <[email protected]>
Co-authored-by: Shailesh Singh <[email protected]>
Co-authored-by: Andriy Redko <[email protected]>
@reta
Copy link
Collaborator

reta commented Mar 8, 2025

@Shailesh-Kumar-Singh could you please backport to 2.x branch manually? thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x Backport to 2.x branch backport-failed bug Something isn't working Search Search query, autocomplete ...etc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Sorted Order Assertion in LongHashSet.java is incorrect
5 participants