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

Avoid overflow when sorting missing last on epoch_millis datetime field #12676

Merged
merged 1 commit into from Mar 15, 2024

Conversation

msfroh
Copy link
Collaborator

@msfroh msfroh commented Mar 14, 2024

Fixes #10253

Description

When sorting a datetime field with epoch_millis formatting and putting missing values last (with a descending sort) or first (with ascending sort), the datetime value is Long.MIN_VALUE.

When we try to render that, the formatter tries to emit the negative sign, followed by the absolute value of the original value. Since Long.MIN_VALUE = -Long.MAX_VALUE - 1, it is not possible to represent -Long.MIN_VALUE as a long.

To work around this, my proposed fix introduces an off-by-one error by truncating to Long.MAX_VALUE.

Related Issues

Resolves #10253

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Failing checks are inspected and point to the corresponding known issue(s) (See: Troubleshooting Failing Builds)
  • Commits are signed per the DCO using --signoff
  • Commit changes are listed out in CHANGELOG.md file (See: Changelog)
  • Public documentation issue/PR created

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

github-actions bot commented Mar 14, 2024

Compatibility status:

Checks if related components are compatible with change 8187f65

Incompatible components

Skipped components

Compatible components

Compatible components: [https://github.com/opensearch-project/custom-codecs.git, https://github.com/opensearch-project/asynchronous-search.git, https://github.com/opensearch-project/anomaly-detection.git, https://github.com/opensearch-project/flow-framework.git, https://github.com/opensearch-project/cross-cluster-replication.git, https://github.com/opensearch-project/job-scheduler.git, https://github.com/opensearch-project/reporting.git, https://github.com/opensearch-project/opensearch-oci-object-storage.git, https://github.com/opensearch-project/geospatial.git, https://github.com/opensearch-project/k-nn.git, https://github.com/opensearch-project/common-utils.git, https://github.com/opensearch-project/alerting.git, https://github.com/opensearch-project/neural-search.git, https://github.com/opensearch-project/security-analytics.git, https://github.com/opensearch-project/performance-analyzer-rca.git, https://github.com/opensearch-project/notifications.git, https://github.com/opensearch-project/index-management.git, https://github.com/opensearch-project/ml-commons.git, https://github.com/opensearch-project/security.git, https://github.com/opensearch-project/observability.git, https://github.com/opensearch-project/performance-analyzer.git, https://github.com/opensearch-project/sql.git]

Copy link
Contributor

✅ Gradle check result for 8187f65: SUCCESS

Copy link
Contributor

❕ Gradle check result for 2171127: UNSTABLE

  • TEST FAILURES:
      1 org.opensearch.indices.state.CloseWhileRelocatingShardsIT.testCloseWhileRelocatingShards

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

Copy link

codecov bot commented Mar 14, 2024

Codecov Report

Attention: Patch coverage is 75.00000% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 71.43%. Comparing base (b15cb0c) to head (8187f65).
Report is 31 commits behind head on main.

Files Patch % Lines
...ain/java/org/opensearch/common/time/EpochTime.java 75.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #12676      +/-   ##
============================================
+ Coverage     71.42%   71.43%   +0.01%     
- Complexity    59978    60068      +90     
============================================
  Files          4985     4989       +4     
  Lines        282275   282578     +303     
  Branches      40946    40985      +39     
============================================
+ Hits         201603   201866     +263     
- Misses        63999    64021      +22     
- Partials      16673    16691      +18     

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

@andrross andrross added the backport 2.x Backport to 2.x branch label Mar 15, 2024
@andrross andrross merged commit fcecd00 into opensearch-project:main Mar 15, 2024
109 of 110 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Mar 15, 2024
…ld (#12676)

Fixes #10253

Signed-off-by: Michael Froh <froh@amazon.com>
(cherry picked from commit fcecd00)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
msfroh pushed a commit that referenced this pull request Mar 15, 2024
…ld (#12676) (#12681)

Fixes #10253


(cherry picked from commit fcecd00)

Signed-off-by: Michael Froh <froh@amazon.com>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
@msfroh msfroh added the v2.13.0 Issues and PRs related to version 2.13.0 label Mar 15, 2024
rayshrey pushed a commit to rayshrey/OpenSearch that referenced this pull request Mar 18, 2024
ruai0511 pushed a commit to ruai0511/OpenSearch that referenced this pull request Mar 19, 2024
shiv0408 pushed a commit to Gaurav614/OpenSearch that referenced this pull request Apr 25, 2024
…ld (opensearch-project#12676)

Fixes opensearch-project#10253

Signed-off-by: Michael Froh <froh@amazon.com>
Signed-off-by: Shivansh Arora <hishiv@amazon.com>
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 bug Something isn't working good first issue Good for newcomers Search:Query Capabilities Search:Relevance v2.13.0 Issues and PRs related to version 2.13.0
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

[BUG] when use "epoch_millis" format for date, got error when sorting in descending order
4 participants