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

GEODE-9018: Fix ExtendedNumericComparator for NULL and UNDEFINED comp… #6110

Merged
merged 3 commits into from Mar 23, 2021

Conversation

albertogpz
Copy link
Contributor

…arison

Thank you for submitting a contribution to Apache Geode.

In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:

For all changes:

  • Is there a JIRA ticket associated with this PR? Is it referenced in the commit message?

  • Has your PR been rebased against the latest commit within the target branch (typically develop)?

  • Is your initial contribution a single, squashed commit?

  • Does gradlew build run cleanly?

  • Have you written or updated unit 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?

Note:

Please ensure that once the PR is submitted, check Concourse for build issues and
submit an update to your PR as soon as possible. If you need help, please send an
email to dev@geode.apache.org.

p1.positions.put("SUN", "yes");
region.put("KEY-" + 1, p1);

// null value for positions['SUN']
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment (and some others in this test) are inaccurate

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

import org.apache.geode.cache.query.internal.index.IndexManager;

public class ExtendedNumericComparatorTest {
Comparator comparator = TypeUtils.getExtendedNumericComparator();
Copy link
Contributor

Choose a reason for hiding this comment

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

Warnings in this class can be fixed by using Comparator<Object> comparator = uncheckedCast(TypeUtils.getExtendedNumericComparator()); here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

* for the key
*/
@Test
public void testNullAndUndefinedValuesForMapKeyInCompactRangeIndex() throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

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

This test passes even with the changes in ExtendedNumericComparator reverted. Would it be possible to write a test that exercises the new behaviour?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, the test without the changes is flaky. If you run it several times you will see it failing a certain percentage of times.

Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be possible to write a test that wasn't flaky when it failed? If something changed in future that made this test fail, it would be best if it failed immediately rather than randomly some time after the breaking change was made.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately, I have not found a way.
The flakyness has to do with some randomness in the implementation of the ConcurrentSkipListMap::putIfAbsent() method invoked from MemoryIndexStore::updateMapping() on the valueToEntriesMap member that seems to traverse the Map in different order in different executions.
With the bug in the Comparator, when adding an entry with UNDEFINED key to the valueToEntriesMap, when there was already an entry with that key in the Map, sometimes that was not detected (an entry with NullToken was found first and that prevented looking for the UNDEFINED key in another entry) and several entries with the UNDEFINED key ended up in the Map.

@albertogpz albertogpz merged commit 863243a into apache:develop Mar 23, 2021
@albertogpz albertogpz deleted the feature/GEODE-9018 branch March 23, 2021 18:52
pivotal-eshu pushed a commit to agingade/geode that referenced this pull request Mar 30, 2021
apache#6110)

* GEODE-9018: Fix ExtendedNumericComparator for NULL and UNDEFINED comparison

* GEODE-9018: Changes after review

* GEODE-9018: Added checks in test case after review
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants