-
Notifications
You must be signed in to change notification settings - Fork 505
METRON-2061: Solr documents with date fields cannot be updated with Dao classes #1374
Conversation
|
How is this DAO and jsonpatch being used by the meta-alert infrastructure? This manual test is picking a fairly narrow interpretation of all that can be done with JsonPatch, and I'm unclear whether we're introducing a feature regression here or not. I know we're using json patch (separately) for handling Ambari modifications to global config to ensure we don't trample user-added or other type of updates that aren't managed by Ambari. I'm concerned about what's not covered by switching from json patch to our own private version of it, specifically here. Very likely, the existing unit and integration tests are only verifying some basic functionality wrt the jsonpatch library (we are depending on the jsonpatch project to handle the fine grained testing of all the RFC details for us), so if we're going to replace it I think we need to do one of the following:
If we are walking back functionality by choosing option 2, I think this needs to be accompanied with a proper DISCUSS thread and a feature change notice in the release/upgrading notes. In addition, we would need to:
|
|
Looks like this also needs conflict resolution. And can you mark any checklist items currently left empty as "n/a" rather than leaving the brackets |
|
I was under the impression all checkboxes need to be done before a PR is complete. You can assume an empty bracket means it's pending. To be clear, the global config patch is unaffected by this change. The only thing affected is the REST Patch endpoint. I'm assuming you are ok with the solution I chose (number 2 in the PR description)? I agree that your suggestion (number 1) is ideal. Think the only thing missing from https://tools.ietf.org/html/rfc6902 is the "test" operation which is easy enough to add. I will proceed with writing tests for all scenarios in https://tools.ietf.org/html/rfc6902. |
Sort of - sometimes they're not relevant and it helps to remove ambiguity:
|
Yes, I'm clear on this.
Yes, that sounds reasonable to me. |
|
Latest commit adds support for the "test" operation and unit tests for |
|
@merrimanr your updates look pretty good. The only minor test addition I think we need here is for paths nested more than depth 1. e.g. can you add tests to validate something like "/foo/bar/baz/blah" still works? |
|
Latest commit adds a test for nested paths. |
|
Looks good @merrimanr. +1 |
Contributor Comments
The initial purpose of this PR is to explain the cause of the problem described in https://issues.apache.org/jira/browse/METRON-2061 and facilitate discussion on an optimal solution. A solution is presented here but I expect we will explore other solutions as well.
Problem
Date type fields are a problem for our
UpdateDaoclasses because of the logic used to update documents. Currently the process is this:JsonNodeobject using Jackson. This includes serializing/deserializing the objects internally.JsonPatchAPI.JsonNodeback to a document object.The problem is that the date type is lost during serialization. Jackson automatically converts it to epoch long by default: https://fasterxml.github.io/jackson-databind/javadoc/2.7/com/fasterxml/jackson/databind/SerializationFeature.html#WRITE_DATES_AS_TIMESTAMPS. There is also an option of converting the value to a date string. The error happens because the original date field now contains a long when a document is indexed.
Possible Solutions
I think there are several ways to solve this problem and I will present some options here. Others are welcome to propose additional solutions.
JsonNodeobjects and serialization/deserialization, we could apply the patches directly to the objects.I chose option #2 because it is simple and avoids any future document field type issues. I believe we should move away from the
JsonPatchAPI and serialization/deserialization altogether because there is potential for other Jackson issues and it is inefficient. This rules out option #1 for me. Option #3 is attractive for obvious reasons but may require significant changes to our API.Testing
The initial solution included here has been tested in full dev. We can use this test script regardless of the solution we choose.
timestamp_solrvalue:I did this using the "Documents" menu item in the Solr UI at
http://node1:8983.This request should succeed without error and the updated document should be returned with the new field. Before this PR a 500 error was returned with a message similar to:
Outstanding Issues
Once we land on a solution I will add comprehensive tests and proper Java documentation.
Pull Request Checklist
Thank you for submitting a contribution to Apache Metron.
Please refer to our Development Guidelines for the complete guide to follow for contributions.
Please refer also to our Build Verification Guidelines for complete smoke testing guides.
In order to streamline the review of the contribution we ask you follow these guidelines and ask you to double check the following:
For all changes:
For code changes:
Have you included steps to reproduce the behavior or problem that is being changed or addressed?
Have you included steps or a guide to how the change may be verified and tested manually?
Have you ensured that the full suite of tests and checks have been executed in the root metron folder via:
Have you written or updated unit tests and or integration tests to verify your changes?
If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0?
Have you verified the basic functionality of the build by building and running locally with Vagrant full-dev environment or the equivalent?
For documentation related changes:
Have you ensured that format looks appropriate for the output in which it is rendered by building and verifying the site-book? If not then run the following commands and the verify changes via
site-book/target/site/index.html:Note:
Please ensure that once the PR is submitted, you check travis-ci for build issues and submit an update to your PR as soon as possible.
It is also recommended that travis-ci is set up for your personal repository such that your branches are built there before submitting a pull request.