Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

sweep full table #2409

Merged
merged 15 commits into from
Oct 17, 2017
Merged

sweep full table #2409

merged 15 commits into from
Oct 17, 2017

Conversation

nziebart
Copy link
Contributor

@nziebart nziebart commented Sep 30, 2017

Goals (and why):
Fixes #2370

Implementation Description (bullets):

  • Allow specifying whether a sweep should sweep the full table (true by default)
  • Sweep the full table by running batches in a loop
  • Some refactors

Concerns (what feedback would you like?):

Where should we start reviewing?:

Priority (whenever / two weeks / yesterday):
whenever


This change is Reviewable

@JsonDeserialize(as=ImmutableSweepTableResponse.class)
public interface SweepTableResponse {

//Optional<String> nextStartRow();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

DropwizardClientRule does not use an object mapper that supports optionals so this makes all the tests fails... need to fix this

return ImmutableSweepTableResponse.builder()
.numCellTsPairsExamined(results.getCellTsPairsExamined())
.staleValuesDeleted(results.getStaleValuesDeleted())
// .nextStartRow(results.getNextStartRow().map(BaseEncoding.base16()::encode))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

should extract the base16 encoding to a utility

@Nullable @QueryParam("candidateBatchSize") Integer candidateBatchSize,
@Nullable @QueryParam("deleteBatchSize") Integer deleteBatchSize);
@QueryParam("startRow") Optional<String> startRow,
@QueryParam("fullSweep") @DefaultValue("true") Optional<Boolean> fullSweep,
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be just Boolean now that we have a default value

@QueryParam("fullSweep") @DefaultValue("true") Optional<Boolean> fullSweep,
@QueryParam("maxCellTsPairsToExamine") Optional<Integer> maxCellTsPairsToExamine,
@QueryParam("candidateBatchSize") Optional<Integer> candidateBatchSize,
@QueryParam("deleteBatchSize") Optional<Integer> deleteBatchSize);
Copy link
Contributor

Choose a reason for hiding this comment

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

Also, while we are here, can we marke these params etc. @safe for logging purposes?

@codecov-io
Copy link

codecov-io commented Oct 3, 2017

Codecov Report

Merging #2409 into develop will increase coverage by 0.04%.
The diff coverage is 95.58%.

Impacted file tree graph

@@              Coverage Diff              @@
##             develop    #2409      +/-   ##
=============================================
+ Coverage      60.11%   60.15%   +0.04%     
- Complexity      3383     4650    +1267     
=============================================
  Files            857      859       +2     
  Lines          40037    40031       -6     
  Branches        4079     4076       -3     
=============================================
+ Hits           24067    24081      +14     
+ Misses         14500    14482      -18     
+ Partials        1470     1468       -2
Impacted Files Coverage Δ Complexity Δ
...lasdb/sweep/SweeperServiceImplIntegrationTest.java 0% <0%> (ø) 0 <0> (ø) ⬇️
...com/palantir/atlasdb/sweep/SweepTableResponse.java 100% <100%> (ø) 0 <0> (?)
...va/com/palantir/atlasdb/sweep/SweepTaskRunner.java 92.39% <100%> (+0.25%) 19 <3> (+19) ⬆️
...ava/com/palantir/atlasdb/sweep/SweeperService.java 100% <100%> (ø) 0 <0> (?)
.../java/com/palantir/atlasdb/sweep/TableToSweep.java 100% <100%> (ø) 7 <6> (+7) ⬆️
...a/com/palantir/atlasdb/sweep/SweepBatchConfig.java 100% <100%> (ø) 3 <2> (+3) ⬆️
.../palantir/atlasdb/sweep/BackgroundSweeperImpl.java 80.19% <100%> (-2.11%) 16 <0> (+16)
...om/palantir/atlasdb/keyvalue/api/SweepResults.java 100% <100%> (ø) 7 <2> (+2) ⬆️
...m/palantir/atlasdb/sweep/SpecificTableSweeper.java 91.2% <100%> (-1.05%) 23 <1> (+23)
...com/palantir/atlasdb/sweep/SweeperServiceImpl.java 100% <100%> (+14%) 1 <0> (+1) ⬆️
... and 17 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 259290b...9bd49fa. Read the comment docs.

Copy link
Contributor

@hsaraogi hsaraogi left a comment

Choose a reason for hiding this comment

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

Few small comments, approving to allow merging after fixing them!

try {
log.info("Beginning");
Copy link
Contributor

Choose a reason for hiding this comment

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

We can add more info here.. lets have beggining sweep on table x with startrow x and batchConfig x

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i added logging for this in SweepTaskRunner.java

Copy link
Contributor

Choose a reason for hiding this comment

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

Ohh, we will get the info from there. This line then seems a bit unnecessary.


sweeperService.sweepTable(TABLE_REF.getQualifiedName());

startRows.forEach(row -> verify(sweepTaskRunner).run(any(), any(), eq(row)));
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: We should verify the results are not recorded here as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

sweeperService.sweepTable(TABLE_REF.getQualifiedName(), Optional.empty(), Optional.of(false),
Optional.empty(), Optional.empty(), Optional.empty());

verify(sweepTaskRunner, times(1)).run(any(), any(), any());
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: We should verify the results are not recorded here as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done


@Override
public void initialize(Bootstrap<Configuration> bootstrap) {
bootstrap.getObjectMapper().registerModule(new Jdk8Module());
Copy link
Contributor

Choose a reason for hiding this comment

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

This is non-ideal, but I couldn't think of a better way here.

@nziebart nziebart force-pushed the nziebart/sweep-full-table branch from 08c89ed to e40704c Compare October 6, 2017 02:18
void sweepTableFromStartRow(
@QueryParam("tablename") String tableName,
@Nonnull @QueryParam("startRow") String startRow);
default SweepTableResponse sweepTable(String tableName) {
Copy link
Contributor

Choose a reason for hiding this comment

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

should we get rid of these APIs as we are no longer exposing the endpoints. This is technically a break, but probably noone will be affected.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i mainly just added these for easier usage in java (otherwise you have to pass in 5 Optional.empty()s

@@ -140,6 +142,10 @@ private SweepResults doRun(TableReference tableRef,
byte[] startRow,
RunType runType,
Sweeper sweeper) {
log.info("Beginning iteration of sweep for table {} starting at row {}",
Copy link
Contributor

Choose a reason for hiding this comment

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

If we have this logging, do we want to remove the loggings on BackgroundSweeperImpl - the ones on getTableToSweep? Otherwise we'd log the same thing twice (that we're starting to sweep table {} on row {}).

You also probably want to update the sweep-logs.rst document to keep track of where we log this line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh i see, we already having logging there. ok, i'll just move this to the SweeperService

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, going to leave this and delete the other, as otherwise we'd have to log in multiple places

Mockito.verify(priorityStore, never()).update(Mockito.any(), Mockito.any(), Mockito.any());
Mockito.verify(progressStore, never()).saveProgress(Mockito.any(), Mockito.any());
sweeperService.sweepTableFrom(TABLE_REF.getQualifiedName(), encodeStartRow(new byte[] {1, 2, 3}));
verify(priorityStore, never()).update(any(), any(), any());
Copy link
Contributor

@hsaraogi hsaraogi Oct 10, 2017

Choose a reason for hiding this comment

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

We can also delete this test as we are verifying no metrics for all tests, but will not block on this.

Copy link
Contributor

@fsamuel-bs fsamuel-bs left a comment

Choose a reason for hiding this comment

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

Pinging @nziebart to update the sweep-logs.rst docs before merging this. If not on this PR, you can also do it shortly after, and you can dismiss this review.

@nziebart
Copy link
Contributor Author

@fsamuel-bs already done :)

* Sweep a particular table from specified startRow with specified {@link SweepBatchConfig} parameters.
* Sweeps a particular table.
*
* @param tableName the table to sweep
Copy link
Contributor Author

Choose a reason for hiding this comment

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

add docs for format of table and row

@nziebart
Copy link
Contributor Author

@fsamuel-bs are you good with the docs changes here?

@nziebart nziebart assigned fsamuel-bs and unassigned nziebart Oct 16, 2017
Copy link
Contributor

@fsamuel-bs fsamuel-bs left a comment

Choose a reason for hiding this comment

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

LGTM.

@fsamuel-bs fsamuel-bs merged commit 13a2b81 into develop Oct 17, 2017
@fsamuel-bs fsamuel-bs deleted the nziebart/sweep-full-table branch October 17, 2017 16:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants