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

PHOENIX-5564 Restructure read repair to improve readability and corre… #624

Closed
wants to merge 1 commit into from

Conversation

kadirozde
Copy link
Contributor

…ctness

Copy link
Contributor

@gjacoby126 gjacoby126 left a comment

Choose a reason for hiding this comment

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

New comments are great, and this is much clearer. One question on correctness and another on style.

*/
public class GlobalIndexChecker implements RegionCoprocessor, RegionObserver {
private static final Log LOG = LogFactory.getLog(GlobalIndexChecker.class);
private GlobalIndexCheckerSource metricsSource;
public static final int NO_DATA_ROW = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be an enum, esp since it's used in the Unaggregated coproc as well?

Copy link
Contributor

Choose a reason for hiding this comment

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

(Note that this is a genuine question, not just requesting a change politely. :-) )

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

// so that it can be repaired
scanner.close();
scanner = region.getScanner(indexScan);
row.clear();
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we not need to return here? We're clearing the scanned row but in the very next block we're checking if it still exists after a new rebuild (and I think the next block is assuming that it's an else{} to this one). Otherwise I don't see where the rebuild of the "new" unverified different-keyed-row is happening.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great catch!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason this missing return did not cause any issue is because the row is cleared and the next block of code returns when the row is empty (i.e., verifyRowAndRemoveEmptyColumn(row) returns true when the row is empty):
if (verifyRowAndRemoveEmptyColumn(row)) {
// The index row status is "verified". This row is good to return to the client. We are done here.
return;
}

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

Copy link
Contributor

@gjacoby126 gjacoby126 left a comment

Choose a reason for hiding this comment

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

Just some nits and then I think this is good to go.

long rowCount = PLong.INSTANCE.getCodec().decodeLong(new ImmutableBytesWritable(value), SortOrder.getDefault());
if (rowCount == 0) {
// This means there does not exist a data table row for this unverified index row
long code = PLong.INSTANCE.getCodec().decodeLong(new ImmutableBytesWritable(value), SortOrder.getDefault());
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather than doing getValue a bunch, probably better to translate code into the enum once and then refer to it directly.

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 appreciate if you give me an example here to follow.

Copy link
Contributor

Choose a reason for hiding this comment

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

So, it turns out it's messier to translate a long to an enum than an int, so I leave it up to you. But something like:

long result = PLong.INSTANCE.getCodec().decodeLong(new ImmutableBytesWritable(value), SortOrder.getDefault());
RebuildReturnCode returnCode = RebuildReturnCode.values[(Integer) result];

The idea was that you'd have a variable of type RebuildReturnCode, so you wouldn't have to keep converting enum values to longs in multiple places in the code and could just compare the result against the enum values directly. But the narrowing cast makes it a bit messy.

indexRowKey, 0, indexRowKey.length) == 0);
// This should not happen at all
Cell cell = row.get(0);
byte[] rowKey = new byte[cell.getRowLength()];
Copy link
Contributor

Choose a reason for hiding this comment

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

Can use CellUtil.cloneRow()

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 will use it

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

@kadirozde kadirozde closed this Nov 15, 2019
@kadirozde kadirozde deleted the 5564 branch November 15, 2019 23:04
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