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

Race condition fix for datetime optimization #10385

Conversation

CaptainDredge
Copy link
Contributor

@CaptainDredge CaptainDredge commented Oct 5, 2023

Description

This PR fixes a race condition in datetime optimization done under PR #9567
It addresses the case where dateTimeFormatter parser list can be partially read by threads when another thread is modifying it

Related Issues

Resolves #4558

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed per the DCO using --signoff
  • Commit changes are listed out in CHANGELOG.md file (See: Changelog)
  • GitHub issue/PR created in OpenSearch documentation repo for the required public documentation changes (#[Issue/PR number])

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.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 5, 2023

Compatibility status:

Checks if related components are compatible with change cbc2780

Incompatible components

Skipped components

Compatible components

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

@github-actions
Copy link
Contributor

github-actions bot commented Oct 5, 2023

Gradle Check (Jenkins) Run Completed with:

  • RESULT: UNSTABLE ❕
  • TEST FAILURES:
      1 org.opensearch.search.SearchWeightedRoutingIT.testShardRoutingWithNetworkDisruption_FailOpenEnabled

@CaptainDredge CaptainDredge force-pushed the datetime-optimization-concurrency-fix branch from 9c7d3ae to e12af8d Compare October 5, 2023 17:33
@CaptainDredge
Copy link
Contributor Author

Sorry, I didn't get the chance to take a look at the comments early but now I've incorporated the above suggestion. @reta / @dblock can we go ahead and merge it now?

@reta
Copy link
Collaborator

reta commented Oct 5, 2023

@reta / @dblock can we go ahead and merge it now?

Once we get green builds, thanks @CaptainDredge

@github-actions
Copy link
Contributor

github-actions bot commented Oct 5, 2023

Gradle Check (Jenkins) Run Completed with:

  • RESULT: UNSTABLE ❕
  • TEST FAILURES:
      1 org.opensearch.cluster.allocation.ClusterRerouteIT.testDelayWithALargeAmountOfShards

…y used) to a simple last used formatter

Signed-off-by: Prabhat Sharma <[email protected]>
@CaptainDredge CaptainDredge force-pushed the datetime-optimization-concurrency-fix branch from e12af8d to cbc2780 Compare October 5, 2023 18:58
@CaptainDredge
Copy link
Contributor Author

Trigerring build again in the hope that flaky test passes

@dblock
Copy link
Member

dblock commented Oct 5, 2023

I’m good merging this if gradle check passes and preconmit fails because of infra

@github-actions
Copy link
Contributor

github-actions bot commented Oct 5, 2023

Gradle Check (Jenkins) Run Completed with:

  • RESULT: UNSTABLE ❕
  • TEST FAILURES:
      1 org.opensearch.repositories.azure.AzureBlobContainerRetriesTests.testWriteLargeBlob

@reta
Copy link
Collaborator

reta commented Oct 5, 2023

Merging it with failing pre-commit checks to fix issue in main

@reta reta merged commit 0facd50 into opensearch-project:main Oct 5, 2023
11 of 13 checks passed
CaptainDredge added a commit to CaptainDredge/OpenSearch that referenced this pull request Oct 6, 2023
* Race condition fix for datetime optimization

Signed-off-by: Prabhat Sharma <[email protected]>

* Changed JavaDateTimeFormatter caching of parser from MRU(most recently used) to a simple last used formatter

Signed-off-by: Prabhat Sharma <[email protected]>

---------

Signed-off-by: Prabhat Sharma <[email protected]>
Co-authored-by: Prabhat Sharma <[email protected]>
Signed-off-by: Prabhat Sharma <[email protected]>
CaptainDredge added a commit to CaptainDredge/OpenSearch that referenced this pull request Oct 6, 2023
* Race condition fix for datetime optimization

Signed-off-by: Prabhat Sharma <[email protected]>

* Changed JavaDateTimeFormatter caching of parser from MRU(most recently used) to a simple last used formatter

Signed-off-by: Prabhat Sharma <[email protected]>

---------

Signed-off-by: Prabhat Sharma <[email protected]>
Co-authored-by: Prabhat Sharma <[email protected]>
Signed-off-by: Prabhat Sharma <[email protected]>
CaptainDredge added a commit to CaptainDredge/OpenSearch that referenced this pull request Oct 6, 2023
* Race condition fix for datetime optimization

Signed-off-by: Prabhat Sharma <[email protected]>

* Changed JavaDateTimeFormatter caching of parser from MRU(most recently used) to a simple last used formatter

Signed-off-by: Prabhat Sharma <[email protected]>

---------

Signed-off-by: Prabhat Sharma <[email protected]>
Co-authored-by: Prabhat Sharma <[email protected]>
Signed-off-by: Prabhat Sharma <[email protected]>
CaptainDredge added a commit to CaptainDredge/OpenSearch that referenced this pull request Oct 6, 2023
* Race condition fix for datetime optimization

Signed-off-by: Prabhat Sharma <[email protected]>

* Changed JavaDateTimeFormatter caching of parser from MRU(most recently used) to a simple last used formatter

Signed-off-by: Prabhat Sharma <[email protected]>

---------

Signed-off-by: Prabhat Sharma <[email protected]>
Co-authored-by: Prabhat Sharma <[email protected]>
Signed-off-by: Prabhat Sharma <[email protected]>
CaptainDredge added a commit to CaptainDredge/OpenSearch that referenced this pull request Oct 6, 2023
* Race condition fix for datetime optimization

Signed-off-by: Prabhat Sharma <[email protected]>

* Changed JavaDateTimeFormatter caching of parser from MRU(most recently used) to a simple last used formatter

Signed-off-by: Prabhat Sharma <[email protected]>

---------

Signed-off-by: Prabhat Sharma <[email protected]>
Co-authored-by: Prabhat Sharma <[email protected]>
Signed-off-by: Prabhat Sharma <[email protected]>
(cherry picked from commit ad17b38)
CaptainDredge added a commit to CaptainDredge/OpenSearch that referenced this pull request Oct 6, 2023
* Race condition fix for datetime optimization

Signed-off-by: Prabhat Sharma <[email protected]>

* Changed JavaDateTimeFormatter caching of parser from MRU(most recently used) to a simple last used formatter

Signed-off-by: Prabhat Sharma <[email protected]>

---------

Signed-off-by: Prabhat Sharma <[email protected]>
Co-authored-by: Prabhat Sharma <[email protected]>
Signed-off-by: Prabhat Sharma <[email protected]>
(cherry picked from commit ad17b38)
Signed-off-by: Prabhat Sharma <[email protected]>
CaptainDredge added a commit to CaptainDredge/OpenSearch that referenced this pull request Oct 6, 2023
* Race condition fix for datetime optimization

Signed-off-by: Prabhat Sharma <[email protected]>

* Changed JavaDateTimeFormatter caching of parser from MRU(most recently used) to a simple last used formatter

Signed-off-by: Prabhat Sharma <[email protected]>

---------

Signed-off-by: Prabhat Sharma <[email protected]>
Co-authored-by: Prabhat Sharma <[email protected]>
Signed-off-by: Prabhat Sharma <[email protected]>
CaptainDredge added a commit to CaptainDredge/OpenSearch that referenced this pull request Oct 6, 2023
* Race condition fix for datetime optimization

Signed-off-by: Prabhat Sharma <[email protected]>

* Changed JavaDateTimeFormatter caching of parser from MRU(most recently used) to a simple last used formatter

Signed-off-by: Prabhat Sharma <[email protected]>

---------

Signed-off-by: Prabhat Sharma <[email protected]>
Co-authored-by: Prabhat Sharma <[email protected]>
Signed-off-by: Prabhat Sharma <[email protected]>
kaushalmahi12 pushed a commit to kaushalmahi12/OpenSearch that referenced this pull request Oct 6, 2023
* Race condition fix for datetime optimization

Signed-off-by: Prabhat Sharma <[email protected]>

* Changed JavaDateTimeFormatter caching of parser from MRU(most recently used) to a simple last used formatter

Signed-off-by: Prabhat Sharma <[email protected]>

---------

Signed-off-by: Prabhat Sharma <[email protected]>
Co-authored-by: Prabhat Sharma <[email protected]>
deshsidd pushed a commit to deshsidd/OpenSearch that referenced this pull request Oct 9, 2023
* Race condition fix for datetime optimization

Signed-off-by: Prabhat Sharma <[email protected]>

* Changed JavaDateTimeFormatter caching of parser from MRU(most recently used) to a simple last used formatter

Signed-off-by: Prabhat Sharma <[email protected]>

---------

Signed-off-by: Prabhat Sharma <[email protected]>
Co-authored-by: Prabhat Sharma <[email protected]>
CaptainDredge added a commit to CaptainDredge/OpenSearch that referenced this pull request Oct 16, 2023
* Race condition fix for datetime optimization

Signed-off-by: Prabhat Sharma <[email protected]>

* Changed JavaDateTimeFormatter caching of parser from MRU(most recently used) to a simple last used formatter

Signed-off-by: Prabhat Sharma <[email protected]>

---------

Signed-off-by: Prabhat Sharma <[email protected]>
Co-authored-by: Prabhat Sharma <[email protected]>
Signed-off-by: Prabhat Sharma <[email protected]>
CaptainDredge added a commit to CaptainDredge/OpenSearch that referenced this pull request Oct 19, 2023
* Race condition fix for datetime optimization

Signed-off-by: Prabhat Sharma <[email protected]>

* Changed JavaDateTimeFormatter caching of parser from MRU(most recently used) to a simple last used formatter

Signed-off-by: Prabhat Sharma <[email protected]>

---------

Signed-off-by: Prabhat Sharma <[email protected]>
Co-authored-by: Prabhat Sharma <[email protected]>
Signed-off-by: Prabhat Sharma <[email protected]>
reta pushed a commit that referenced this pull request Oct 19, 2023
…10448)

* Added performance improvement for datetime field parsing (#9567)

* Added performance improvement for datetime field parsing

This adds caching of formatters in case of no explicit format specified for the datetime field in mapping.
This also adds `strict_date_time_no_millis` as additional formatter in default date time formats

Signed-off-by: Prabhat Sharma <[email protected]>

* Refactor DateTimeFormatter Access under featireflag

Signed-off-by: Prabhat Sharma <[email protected]>

---------

Signed-off-by: Prabhat Sharma <[email protected]>
Co-authored-by: Prabhat Sharma <[email protected]>
(cherry picked from commit 2965e69)
Signed-off-by: Prabhat Sharma <[email protected]>

* Race condition fix for datetime optimization (#10385)

* Race condition fix for datetime optimization

Signed-off-by: Prabhat Sharma <[email protected]>

* Changed JavaDateTimeFormatter caching of parser from MRU(most recently used) to a simple last used formatter

Signed-off-by: Prabhat Sharma <[email protected]>

---------

Signed-off-by: Prabhat Sharma <[email protected]>
Co-authored-by: Prabhat Sharma <[email protected]>
Signed-off-by: Prabhat Sharma <[email protected]>

---------

Signed-off-by: Prabhat Sharma <[email protected]>
Co-authored-by: Prabhat Sharma <[email protected]>
austintlee pushed a commit to austintlee/OpenSearch that referenced this pull request Oct 23, 2023
* Race condition fix for datetime optimization

Signed-off-by: Prabhat Sharma <[email protected]>

* Changed JavaDateTimeFormatter caching of parser from MRU(most recently used) to a simple last used formatter

Signed-off-by: Prabhat Sharma <[email protected]>

---------

Signed-off-by: Prabhat Sharma <[email protected]>
Co-authored-by: Prabhat Sharma <[email protected]>
CaptainDredge added a commit to CaptainDredge/OpenSearch that referenced this pull request Jan 31, 2024
* Race condition fix for datetime optimization

Signed-off-by: Prabhat Sharma <[email protected]>

* Changed JavaDateTimeFormatter caching of parser from MRU(most recently used) to a simple last used formatter

Signed-off-by: Prabhat Sharma <[email protected]>

---------

Signed-off-by: Prabhat Sharma <[email protected]>
Co-authored-by: Prabhat Sharma <[email protected]>
Signed-off-by: Prabhat Sharma <[email protected]>
shiv0408 pushed a commit to Gaurav614/OpenSearch that referenced this pull request Apr 25, 2024
* Race condition fix for datetime optimization

Signed-off-by: Prabhat Sharma <[email protected]>

* Changed JavaDateTimeFormatter caching of parser from MRU(most recently used) to a simple last used formatter

Signed-off-by: Prabhat Sharma <[email protected]>

---------

Signed-off-by: Prabhat Sharma <[email protected]>
Co-authored-by: Prabhat Sharma <[email protected]>
Signed-off-by: Shivansh Arora <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement or improvement to existing feature or request skip-changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Infer and cache date field format instead of re-parsing it for every document
3 participants