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

Implement serialization for LinearRing. #12831

Closed
wants to merge 3 commits into from

Conversation

dblock
Copy link
Member

@dblock dblock commented Mar 21, 2024

Description

A user that enables trace-level logging with OpenSearch will run into a serialization error on geo tasks that they otherwise would not run into. It comes from here. This also happens in a test, and #12783 attempts to ignore the failed serialization error. This PR implements JSON serialization for LinearRing.

Reproduce with

./gradlew ':server:test' --tests "org.opensearch.search.geo.GeoPointShapeQueryTests.testQueryLinearRing" -Dtests.opensearch.logger.level=TRACE

Related Issues

Closes #11688.

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.

@dblock dblock force-pushed the task-description branch from 098c81e to 7fc4fb0 Compare March 21, 2024 14:15
@github-actions github-actions bot added bug Something isn't working flaky-test Random test failure that succeeds on second run Geospatial Search Search query, autocomplete ...etc labels Mar 21, 2024
@dblock
Copy link
Member Author

dblock commented Mar 21, 2024

LMK if you think it's better @shwetathareja @reta.

Copy link
Contributor

❌ Gradle check result for 098c81e: 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?

@dblock dblock marked this pull request as draft March 21, 2024 14:30
Copy link
Contributor

github-actions bot commented Mar 21, 2024

Compatibility status:

Checks if related components are compatible with change 2271a3a

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/performance-analyzer-rca.git, https://github.com/opensearch-project/flow-framework.git, https://github.com/opensearch-project/cross-cluster-replication.git, https://github.com/opensearch-project/reporting.git, https://github.com/opensearch-project/job-scheduler.git, https://github.com/opensearch-project/security.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/neural-search.git, https://github.com/opensearch-project/security-analytics.git, https://github.com/opensearch-project/anomaly-detection.git, https://github.com/opensearch-project/performance-analyzer.git, https://github.com/opensearch-project/notifications.git, https://github.com/opensearch-project/ml-commons.git, https://github.com/opensearch-project/index-management.git, https://github.com/opensearch-project/observability.git, https://github.com/opensearch-project/alerting.git, https://github.com/opensearch-project/sql.git]

Copy link
Contributor

❌ Gradle check result for 7fc4fb0: 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?

@dblock dblock changed the title Always return a task description even when it cannot be serialized. Implement serialization for LinearRing. Mar 21, 2024
@@ -80,7 +80,11 @@ public SearchTask(

@Override
public final String getDescription() {
return descriptionSupplier.get();
try {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dblock so I've check the codebase and it seems like we have at least 4 consolidated places where UnsupportedOperationException is thrown all over the place:

  • GeoJson (JSON serialization)
  • GeometryIO (native stream serialization)
  • GeoShapeIndexer (indexer)
  • LegacyGeoShapeQueryProcessor / VectorGeoPointShapeQueryProcessor / LuceneGeometryCollector

It seems like LinearRing is special case and should not be used as a top level geometry primitive, looking a bit more on how we could fix that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I implemented serialization for LinearRing, so that fixes (1).

@andrross
Copy link
Member

I'll start with the caveat that I know nothing about GeoJson, but does this serialization conform with the GeoJSON specification? I spent a few minutes looking at this and I couldn't quite figure it out (again, I know nothing about this domain), but which of the seven allowed geometries does a linear ring serialize itself as since "linear ring" isn't one of the allowed geometries?

@reta
Copy link
Collaborator

reta commented Mar 21, 2024

but which of the seven allowed geometries does a linear ring serialize itself as since "linear ring" isn't one of the allowed geometries?

Thanks @andrross , I was looking for a reasons why it was not serializable in first place but it looks like this is exactly the one (https://macwright.com/2015/03/23/geojson-second-bite gives a sneak peek what a linear rings)

@dblock
Copy link
Member Author

dblock commented Mar 21, 2024

Maybe @nknize can take a look at this? I approached this problem from a very practical point of view: task description wants to serialize the linear ring so that the user can see what's going on in the trace, and serialization was missing. I don't know if there are negative consequences of introducing this implementation that does not confirm with the GeoJSON spec.

@dblock dblock marked this pull request as ready for review March 21, 2024 15:24
Copy link
Contributor

❌ Gradle check result for 2271a3a: 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?

@dblock
Copy link
Member Author

dblock commented Mar 21, 2024

❌ Gradle check result for 2271a3a: 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?

org.opensearch.indices.IndicesRequestCacheIT.testCacheWithInvalidation {p0={"opensearch.experimental.feature.pluggable.caching.enabled":"false"}} #12308

@andrross
Copy link
Member

I approached this problem from a very practical point of view:

This approach is completely fine for the "convert this structure to text to write into a log message" use case. The problem is the serialization is also used to create what I assume must be conforming GeoJSON potentially for communicating with other systems that expect conforming GeoJSON. Unfortunately I don't see any easy way to tease apart these use cases because the logging happens way up in the call stack while operating on very generic objects.

@dblock dblock mentioned this pull request Mar 21, 2024
8 tasks
@dblock
Copy link
Member Author

dblock commented Mar 21, 2024

@andrross @reta LMK if you prefer #12834

Copy link
Contributor

❌ Gradle check result for 2271a3a: 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 d08003d: TIMEOUT

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?

@kkmr
Copy link
Contributor

kkmr commented Mar 21, 2024

Looks like @rishabhmaurya also posted a solution to the issue: #12844. :-)

@dblock
Copy link
Member Author

dblock commented Mar 22, 2024

I'd like to leave this open for a bit, hoping someone (@nknize?) will have a strong opinion of why we should not have this serialization implementation for LinearRing.

@dblock
Copy link
Member Author

dblock commented Mar 22, 2024

@shwetathareja in #12834 (comment) is saying this is dead code and we should delete it.

@reta
Copy link
Collaborator

reta commented Mar 22, 2024

@shwetathareja in #12834 (comment) is saying this is dead code and we should delete it.

Definitely let's delete it if it is dead (but I see it being used), may be what exactly is "dead" would good to clarify

@dblock
Copy link
Member Author

dblock commented Mar 29, 2024

Closing in favor of #12910.

@dblock dblock closed this Mar 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working flaky-test Random test failure that succeeds on second run Geospatial Search Search query, autocomplete ...etc skip-changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] GeoPointShapeQueryTests.testQueryLinearRing fails with UnsupportedOperationException
4 participants