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

Fix DbKvs.getRangeOfTimestamps() only returning the first page #1872

Merged
merged 4 commits into from May 8, 2017

Conversation

gbonik
Copy link
Contributor

@gbonik gbonik commented May 2, 2017

The expectation is to return all results that fall into the range
regardless of the page size. This is how all other KVSs work
at least, and also consistent with getRange().

I'm planning to delete all of this code soon, and just need it to "work" in order
to execute the intermediate steps of my big sweep refactor/rewrite.

Goals (and why):
Fix broken stuff that is blocking my work
Implementation Description (bullets):
Load an extra row. Add a test.
Concerns (what feedback would you like?):
It's still wrong, but that's okay (read above)
Where should we start reviewing?:

Priority (whenever / two weeks / yesterday):


This change is Reviewable

@jeremyk-91 jeremyk-91 self-assigned this May 3, 2017
@gbonik
Copy link
Contributor Author

gbonik commented May 3, 2017

This fix doesn't actually work, please don't merge this yet.

The expectation is to return all results that fall into the range
regardless of the page size. This is how all other KVSs work
at least, and also consistent with getRange().

I'm planning to delete all of this code soon, and just need it to
work in order to execute the intermediate steps of my big sweep
refactor/rewrite.
@codecov-io
Copy link

codecov-io commented May 3, 2017

Codecov Report

Merging #1872 into develop will decrease coverage by 0.03%.
The diff coverage is 95.45%.

Impacted file tree graph

@@              Coverage Diff              @@
##             develop    #1872      +/-   ##
=============================================
- Coverage      61.36%   61.32%   -0.04%     
- Complexity      3972     4317     +345     
=============================================
  Files            740      740              
  Lines          36832    36851      +19     
  Branches        3985     3987       +2     
=============================================
- Hits           22601    22598       -3     
- Misses         12761    12781      +20     
- Partials        1470     1472       +2
Impacted Files Coverage Δ Complexity Δ
...sdb/keyvalue/impl/AbstractKeyValueServiceTest.java 95.66% <100%> (+0.06%) 0 <0> (-120) ⬇️
...om/palantir/atlasdb/keyvalue/dbkvs/impl/DbKvs.java 84.42% <100%> (ø) 119 <0> (ø) ⬇️
...ue/dbkvs/impl/TimestampsByCellResultWithToken.java 96.05% <87.5%> (-1.1%) 27 <1> (+1)
...palantir/atlasdb/keyvalue/cassandra/Heartbeat.java 83.33% <0%> (-8.34%) 7% <0%> (+7%)
...ain/java/com/palantir/paxos/PaxosProposerImpl.java 80.35% <0%> (-7.15%) 0% <0%> (ø)
...r/atlasdb/keyvalue/cassandra/HeartbeatService.java 75.86% <0%> (-6.9%) 6% <0%> (+6%)
...ain/java/com/palantir/paxos/PaxosAcceptorImpl.java 69.64% <0%> (-3.58%) 0% <0%> (ø)
...in/java/com/palantir/paxos/PaxosQuorumChecker.java 71.18% <0%> (-3.39%) 0% <0%> (ø)
...alantir/lock/client/LockRefreshingLockService.java 39.06% <0%> (-3.13%) 7% <0%> (-1%)
.../atlasdb/transaction/impl/SnapshotTransaction.java 72.05% <0%> (-1.66%) 163% <0%> (-6%)
... and 10 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4c6d86b...5b57edf. Read the comment docs.

@gbonik
Copy link
Contributor Author

gbonik commented May 3, 2017

Pushed a proper fix, changed the test, and updated the PR description.

@jeremyk-91
Copy link
Contributor

Right, I was initially a little puzzled as to how adding 1 to the query sizes worked. I'll start reviewing this now.

@gbonik
Copy link
Contributor Author

gbonik commented May 3, 2017

@jeremyk-91 The logic to determine whether we reached the end was to to check if there was a remaining result from the SQL query, so my idea was to load that extra result. A pretty common trick for implementing paging. It didn't work because "range.getBatchHint()" and the "batchSize" are two different numbers.

Copy link
Contributor

@jeremyk-91 jeremyk-91 left a comment

Choose a reason for hiding this comment

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

Looks good. There are a couple minor style suggestions I have, but it makes sense that DbKVS should be consistent with the other key-value services.

Also for some reason the build is failing - will investigate this.

moreResults = true;
token = ImmutableToken.builder().row(nextRow).shouldSkip(false).build();
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We could extract this to buildTokenIfMoreRowsAvailable or something along those lines.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could but I'm planning to delete all of this code soon.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure, no problem.

assertEquals(3, results.size());
assertTrue(Arrays.equals(row0, results.get(0).getRowName()));
assertTrue(Arrays.equals(row1, results.get(1).getRowName()));
assertTrue(Arrays.equals(row2, results.get(2).getRowName()));
Copy link
Contributor

Choose a reason for hiding this comment

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

For these, I'd prefer we use assertArrayEquals(expected, actual) instead. We'll get a more helpful assertion failure message if something breaks 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.

Yep, forgot that it existed. Done.

Cell.create(row0, column0), value0_t0,
Cell.create(row1, column0), value0_t0,
Cell.create(row2, column0), value0_t0),
TEST_TIMESTAMP);
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, the above needs to be indented 4 more spaces in b/c of checkstyle.

[00:02:37] [ant:checkstyle] [ERROR] /home/ubuntu/atlasdb-internal-testing/atlasdb-tests-shared/src/main/java/com/palantir/atlasdb/keyvalue/impl/AbstractKeyValueServiceTest.java:1084: 'ImmutableMap' have incorrect indentation level 12, expected level should be 16. [Indentation]
[00:02:37] [ant:checkstyle] [ERROR] /home/ubuntu/atlasdb-internal-testing/atlasdb-tests-shared/src/main/java/com/palantir/atlasdb/keyvalue/impl/AbstractKeyValueServiceTest.java:1088: 'TEST_TIMESTAMP' have incorrect indentation level 12, expected level should be 16. [Indentation]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are you guys using the "baseline" checkstyle? I feel like at least half of the rules there don't make much sense.

Copy link
Contributor

Choose a reason for hiding this comment

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

For the most part I think so, though we do exclude a couple of rules - @gsheasby would probably know this better!

Copy link
Contributor

Choose a reason for hiding this comment

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

@gbonik yep, we recently upgraded to Baseline 0.13.0.

Copy link
Contributor

@jeremyk-91 jeremyk-91 left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

@jeremyk-91 jeremyk-91 merged commit b258e65 into develop May 8, 2017
@jeremyk-91 jeremyk-91 deleted the fix/dbkvs-tsrange branch May 8, 2017 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants