Skip to content

HBASE-22890 Verify the file integrity in persistent IOEngine - #633

Merged
Reidddddd merged 1 commit into
apache:branch-1from
ZhaoBQ:HBASE-22890
Sep 20, 2019
Merged

HBASE-22890 Verify the file integrity in persistent IOEngine#633
Reidddddd merged 1 commit into
apache:branch-1from
ZhaoBQ:HBASE-22890

Conversation

@ZhaoBQ

Copy link
Copy Markdown
Contributor

ois = new ObjectInputStream(fis);
ois = new ObjectInputStream(new FileInputStream(persistencePath));
// there are two situations that can cause verification to fail
if (!((FileIOEngine) ioEngine).verifyFileIntegrity(persistencePath, ois)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ioEngine can directly cast to FileIOEngine? It's already guarded by !ioEngine.isPersistent().

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

My fault, it's should be PersistentIOEngine.

@Apache-HBase

Copy link
Copy Markdown

💔 -1 overall

VoteSubsystemRuntimeComment
💙reexec1m 29sDocker mode activated.
_ Prechecks _
💚dupname0m 0sNo case conflicting files found.
💚hbaseanti0m 0sPatch does not have any anti-patterns.
💚@author0m 0sThe patch does not contain any @author tags.
💚test4tests0m 0sThe patch appears to include 2 new or modified test files.
_ branch-1 Compile Tests _
💚mvninstall8m 7sbranch-1 passed
💚compile1m 59sbranch-1 passed with JDK v1.8.0_222
💔compile0m 21shbase-server in branch-1 failed with JDK v1.7.0_232.
💚checkstyle1m 33sbranch-1 passed
💚shadedjars2m 46sbranch has no errors when building our shaded downstream artifacts.
💚javadoc0m 36sbranch-1 passed with JDK v1.8.0_222
💚javadoc0m 39sbranch-1 passed with JDK v1.7.0_232
💙spotbugs2m 47sUsed deprecated FindBugs config; considering switching to SpotBugs.
💚findbugs2m 43sbranch-1 passed
_ Patch Compile Tests _
💚mvninstall2m 1sthe patch passed
💚compile1m 49sthe patch passed with JDK v1.8.0_222
💚javac1m 49sthe patch passed
💔compile0m 22shbase-server in the patch failed with JDK v1.7.0_232.
💔javac0m 22shbase-server in the patch failed with JDK v1.7.0_232.
💔checkstyle1m 32shbase-server: The patch generated 4 new + 46 unchanged - 6 fixed = 50 total (was 52)
💚whitespace0m 0sThe patch has no whitespace issues.
💚shadedjars2m 58spatch has no errors when building our shaded downstream artifacts.
💚hadoopcheck5m 15sPatch does not cause any errors with Hadoop 2.8.5 2.9.2.
💚javadoc0m 32sthe patch passed with JDK v1.8.0_222
💚javadoc0m 43sthe patch passed with JDK v1.7.0_232
💔findbugs3m 3shbase-server generated 1 new + 0 unchanged - 0 fixed = 1 total (was 0)
_ Other Tests _
💔unit34m 41shbase-server in the patch failed.
💚asflicense0m 24sThe patch does not generate ASF License warnings.
77m 26s
ReasonTests
FindBugsmodule:hbase-server
org.apache.hadoop.hbase.io.hfile.bucket.FileIOEngine.verifyFileIntegrity(String, ObjectInputStream) ignores result of java.io.ObjectInputStream.read(byte[]) At FileIOEngine.java:java.io.ObjectInputStream.read(byte[]) At FileIOEngine.java:[line 95]
Failed junit testshadoop.hbase.io.hfile.bucket.TestBucketCache
SubsystemReport/Notes
DockerClient=19.03.2 Server=19.03.2 base: https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-633/1/artifact/out/Dockerfile
GITHUB PR#633
Optional Testsdupname asflicense javac javadoc unit spotbugs findbugs shadedjars hadoopcheck hbaseanti checkstyle compile
unameLinux 2a13dce83b51 4.15.0-60-generic #67-Ubuntu SMP Thu Aug 22 16:55:30 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Build toolmaven
Personality/home/jenkins/jenkins-slave/workspace/HBase-PreCommit-GitHub-PR_PR-633/out/precommit/personality/provided.sh
git revisionbranch-1 / 5c4d8e0
Default Java1.7.0_232
Multi-JDK versions/usr/lib/jvm/zulu-8-amd64:1.8.0_222 /usr/lib/jvm/zulu-7-amd64:1.7.0_232
compilehttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-633/1/artifact/out/branch-compile-hbase-server-jdk1.7.0_232.txt
compilehttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-633/1/artifact/out/patch-compile-hbase-server-jdk1.7.0_232.txt
javachttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-633/1/artifact/out/patch-compile-hbase-server-jdk1.7.0_232.txt
checkstylehttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-633/1/artifact/out/diff-checkstyle-hbase-server.txt
findbugshttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-633/1/artifact/out/new-findbugs-hbase-server.html
unithttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-633/1/artifact/out/patch-unit-hbase-server.txt
Test Resultshttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-633/1/testReport/
Max. process+thread count733 (vs. ulimit of 10000)
modulesC: hbase-server U: hbase-server
Console outputhttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-633/1/console
versionsgit=1.9.1 maven=3.0.5 findbugs=3.0.1
Powered byApache Yetus 0.11.0 https://yetus.apache.org

This message was automatically generated.

@Apache-HBase

Copy link
Copy Markdown

💔 -1 overall

VoteSubsystemRuntimeComment
💙reexec0m 50sDocker mode activated.
_ Prechecks _
💚dupname0m 0sNo case conflicting files found.
💚hbaseanti0m 0sPatch does not have any anti-patterns.
💚@author0m 0sThe patch does not contain any @author tags.
💚test4tests0m 0sThe patch appears to include 2 new or modified test files.
_ branch-1 Compile Tests _
💚mvninstall8m 10sbranch-1 passed
💚compile1m 57sbranch-1 passed with JDK v1.8.0_222
💔compile0m 22shbase-server in branch-1 failed with JDK v1.7.0_232.
💚checkstyle1m 32sbranch-1 passed
💚shadedjars2m 41sbranch has no errors when building our shaded downstream artifacts.
💚javadoc0m 37sbranch-1 passed with JDK v1.8.0_222
💚javadoc0m 41sbranch-1 passed with JDK v1.7.0_232
💙spotbugs2m 48sUsed deprecated FindBugs config; considering switching to SpotBugs.
💚findbugs2m 44sbranch-1 passed
_ Patch Compile Tests _
💚mvninstall1m 59sthe patch passed
💚compile1m 43sthe patch passed with JDK v1.8.0_222
💚javac1m 43sthe patch passed
💔compile0m 22shbase-server in the patch failed with JDK v1.7.0_232.
💔javac0m 22shbase-server in the patch failed with JDK v1.7.0_232.
💔checkstyle1m 31shbase-server: The patch generated 2 new + 46 unchanged - 6 fixed = 48 total (was 52)
💚whitespace0m 0sThe patch has no whitespace issues.
💚shadedjars2m 45spatch has no errors when building our shaded downstream artifacts.
💚hadoopcheck4m 59sPatch does not cause any errors with Hadoop 2.8.5 2.9.2.
💚javadoc0m 32sthe patch passed with JDK v1.8.0_222
💚javadoc0m 42sthe patch passed with JDK v1.7.0_232
💔findbugs2m 59shbase-server generated 1 new + 0 unchanged - 0 fixed = 1 total (was 0)
_ Other Tests _
💚unit118m 28shbase-server in the patch passed.
💚asflicense0m 34sThe patch does not generate ASF License warnings.
159m 49s
ReasonTests
FindBugsmodule:hbase-server
org.apache.hadoop.hbase.io.hfile.bucket.FileIOEngine.verifyFileIntegrity(String, ObjectInputStream) ignores result of java.io.ObjectInputStream.read(byte[]) At FileIOEngine.java:java.io.ObjectInputStream.read(byte[]) At FileIOEngine.java:[line 96]
SubsystemReport/Notes
DockerClient=19.03.1 Server=19.03.1 base: https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-633/2/artifact/out/Dockerfile
GITHUB PR#633
Optional Testsdupname asflicense javac javadoc unit spotbugs findbugs shadedjars hadoopcheck hbaseanti checkstyle compile
unameLinux b2834568b00c 4.15.0-60-generic #67-Ubuntu SMP Thu Aug 22 16:55:30 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Build toolmaven
Personality/home/jenkins/jenkins-slave/workspace/HBase-PreCommit-GitHub-PR_PR-633/out/precommit/personality/provided.sh
git revisionbranch-1 / 5c4d8e0
Default Java1.7.0_232
Multi-JDK versions/usr/lib/jvm/zulu-8-amd64:1.8.0_222 /usr/lib/jvm/zulu-7-amd64:1.7.0_232
compilehttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-633/2/artifact/out/branch-compile-hbase-server-jdk1.7.0_232.txt
compilehttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-633/2/artifact/out/patch-compile-hbase-server-jdk1.7.0_232.txt
javachttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-633/2/artifact/out/patch-compile-hbase-server-jdk1.7.0_232.txt
checkstylehttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-633/2/artifact/out/diff-checkstyle-hbase-server.txt
findbugshttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-633/2/artifact/out/new-findbugs-hbase-server.html
Test Resultshttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-633/2/testReport/
Max. process+thread count4320 (vs. ulimit of 10000)
modulesC: hbase-server U: hbase-server
Console outputhttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-633/2/console
versionsgit=1.9.1 maven=3.0.5 findbugs=3.0.1
Powered byApache Yetus 0.11.0 https://yetus.apache.org

This message was automatically generated.

this.channelLocks = new ReentrantLock[filePaths.length];
this.algorithmName = algorithmName;
// not configure persistent path
if (persistentPath == null) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is some thing new we are doing now. Previously this delete step was not there if the files exists, and no persistentPath been configured.
In fact am wondering why we need to pass the persistentPath and algo here now? We call the verify method and there pass the persistentPath and can pass algo or so also.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I like this idea, codes look cleaner.

* @throws IOException
*/
private IOEngine getIOEngineFromName(String ioEngineName, long capacity)
private IOEngine getIOEngineFromName()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

See below comment also. Actually there is no need to have any change here now. We do not need to pass any extra args to FileIOE constructor now. No need to even change the order of call to getIOEngineFromName() above right. Better keep only the req change IMHO.

* @return true if verify successfully
*/
@Override
public boolean verifyFileIntegrity(String persistentPath, ObjectInputStream ois)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ah.. Can we pass the stored checksum only here? Actually the write of the checksum was done by BucketCache right? So expecting the FileIOE to know that looks bit ugly. I mean its like PBMagic and then an int for checkusm length and so on.

return true;
} else {
// if the persistent file is not start with PB_MAGIC, it's an old version file
oldVersion = true;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we still need this oldVersion state here in FileIOE?

}

@Override
public boolean isOldVersion() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I see now this is been used. So my point was like read the checksum in BucketCache only. And let IT decide whether to do the checksum verify or not based on PBMagic.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

I got your point.

@ZhaoBQ

Copy link
Copy Markdown
ContributorAuthor

Hi, @anoopsjohn, I have modified.

@Apache-HBase

Copy link
Copy Markdown

💔 -1 overall

VoteSubsystemRuntimeComment
💙reexec0m 42sDocker mode activated.
_ Prechecks _
💚dupname0m 0sNo case conflicting files found.
💚hbaseanti0m 0sPatch does not have any anti-patterns.
💚@author0m 0sThe patch does not contain any @author tags.
💚test4tests0m 0sThe patch appears to include 2 new or modified test files.
_ branch-1 Compile Tests _
💚mvninstall8m 4sbranch-1 passed
💚compile1m 58sbranch-1 passed with JDK v1.8.0_222
💔compile0m 22shbase-server in branch-1 failed with JDK v1.7.0_232.
💚checkstyle1m 33sbranch-1 passed
💚shadedjars2m 46sbranch has no errors when building our shaded downstream artifacts.
💚javadoc0m 37sbranch-1 passed with JDK v1.8.0_222
💚javadoc0m 42sbranch-1 passed with JDK v1.7.0_232
💙spotbugs3m 11sUsed deprecated FindBugs config; considering switching to SpotBugs.
💚findbugs3m 9sbranch-1 passed
_ Patch Compile Tests _
💚mvninstall0m 56sthe patch passed
💚compile1m 46sthe patch passed with JDK v1.8.0_222
💚javac1m 46sthe patch passed
💔compile0m 21shbase-server in the patch failed with JDK v1.7.0_232.
💔javac0m 21shbase-server in the patch failed with JDK v1.7.0_232.
💔checkstyle1m 29shbase-server: The patch generated 2 new + 48 unchanged - 4 fixed = 50 total (was 52)
💚whitespace0m 0sThe patch has no whitespace issues.
💚shadedjars2m 45spatch has no errors when building our shaded downstream artifacts.
💚hadoopcheck5m 3sPatch does not cause any errors with Hadoop 2.8.5 2.9.2.
💚javadoc0m 34sthe patch passed with JDK v1.8.0_222
💚javadoc0m 41sthe patch passed with JDK v1.7.0_232
💔findbugs3m 5shbase-server generated 1 new + 0 unchanged - 0 fixed = 1 total (was 0)
_ Other Tests _
💔unit32m 4shbase-server in the patch failed.
💚asflicense0m 22sThe patch does not generate ASF License warnings.
72m 27s
ReasonTests
FindBugsmodule:hbase-server
org.apache.hadoop.hbase.io.hfile.bucket.BucketCache.retrieveFromFile(int[]) ignores result of java.io.ObjectInputStream.read(byte[]) At BucketCache.java: At BucketCache.java:[line 1084]
Failed junit testshadoop.hbase.io.hfile.bucket.TestVerifyBucketCacheFile
SubsystemReport/Notes
DockerClient=19.03.1 Server=19.03.1 base: https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-633/3/artifact/out/Dockerfile
GITHUB PR#633
Optional Testsdupname asflicense javac javadoc unit spotbugs findbugs shadedjars hadoopcheck hbaseanti checkstyle compile
unameLinux 3a9df52e28e5 4.15.0-58-generic #64-Ubuntu SMP Tue Aug 6 11:12:41 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Build toolmaven
Personality/home/jenkins/jenkins-slave/workspace/HBase-PreCommit-GitHub-PR_PR-633/out/precommit/personality/provided.sh
git revisionbranch-1 / 5c4d8e0
Default Java1.7.0_232
Multi-JDK versions/usr/lib/jvm/zulu-8-amd64:1.8.0_222 /usr/lib/jvm/zulu-7-amd64:1.7.0_232
compilehttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-633/3/artifact/out/branch-compile-hbase-server-jdk1.7.0_232.txt
compilehttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-633/3/artifact/out/patch-compile-hbase-server-jdk1.7.0_232.txt
javachttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-633/3/artifact/out/patch-compile-hbase-server-jdk1.7.0_232.txt
checkstylehttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-633/3/artifact/out/diff-checkstyle-hbase-server.txt
findbugshttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-633/3/artifact/out/new-findbugs-hbase-server.html
unithttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-633/3/artifact/out/patch-unit-hbase-server.txt
Test Resultshttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-633/3/testReport/
Max. process+thread count758 (vs. ulimit of 10000)
modulesC: hbase-server U: hbase-server
Console outputhttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-633/3/console
versionsgit=1.9.1 maven=3.0.5 findbugs=3.0.1
Powered byApache Yetus 0.11.0 https://yetus.apache.org

This message was automatically generated.

@Apache-HBase

Copy link
Copy Markdown

💔 -1 overall

VoteSubsystemRuntimeComment
💙reexec0m 46sDocker mode activated.
_ Prechecks _
💚dupname0m 0sNo case conflicting files found.
💚hbaseanti0m 0sPatch does not have any anti-patterns.
💚@author0m 0sThe patch does not contain any @author tags.
💚test4tests0m 0sThe patch appears to include 2 new or modified test files.
_ branch-1 Compile Tests _
💚mvninstall8m 9sbranch-1 passed
💚compile1m 53sbranch-1 passed with JDK v1.8.0_222
💔compile0m 21shbase-server in branch-1 failed with JDK v1.7.0_232.
💚checkstyle1m 34sbranch-1 passed
💚shadedjars2m 46sbranch has no errors when building our shaded downstream artifacts.
💚javadoc0m 37sbranch-1 passed with JDK v1.8.0_222
💚javadoc0m 41sbranch-1 passed with JDK v1.7.0_232
💙spotbugs2m 52sUsed deprecated FindBugs config; considering switching to SpotBugs.
💚findbugs2m 49sbranch-1 passed
_ Patch Compile Tests _
💚mvninstall1m 55sthe patch passed
💚compile1m 42sthe patch passed with JDK v1.8.0_222
💚javac1m 42sthe patch passed
💔compile0m 23shbase-server in the patch failed with JDK v1.7.0_232.
💔javac0m 23shbase-server in the patch failed with JDK v1.7.0_232.
💔checkstyle1m 31shbase-server: The patch generated 2 new + 48 unchanged - 4 fixed = 50 total (was 52)
💚whitespace0m 0sThe patch has no whitespace issues.
💚shadedjars2m 42spatch has no errors when building our shaded downstream artifacts.
💚hadoopcheck4m 52sPatch does not cause any errors with Hadoop 2.8.5 2.9.2.
💚javadoc0m 30sthe patch passed with JDK v1.8.0_222
💚javadoc0m 43sthe patch passed with JDK v1.7.0_232
💚findbugs2m 49sthe patch passed
_ Other Tests _
💔unit31m 2shbase-server in the patch failed.
💚asflicense0m 21sThe patch does not generate ASF License warnings.
71m 38s
ReasonTests
Failed junit testshadoop.hbase.io.hfile.bucket.TestVerifyBucketCacheFile
SubsystemReport/Notes
DockerClient=19.03.1 Server=19.03.1 base: https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-633/4/artifact/out/Dockerfile
GITHUB PR#633
Optional Testsdupname asflicense javac javadoc unit spotbugs findbugs shadedjars hadoopcheck hbaseanti checkstyle compile
unameLinux 004a9f2bb8e2 4.15.0-58-generic #64-Ubuntu SMP Tue Aug 6 11:12:41 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Build toolmaven
Personality/home/jenkins/jenkins-slave/workspace/HBase-PreCommit-GitHub-PR_PR-633/out/precommit/personality/provided.sh
git revisionbranch-1 / 5c4d8e0
Default Java1.7.0_232
Multi-JDK versions/usr/lib/jvm/zulu-8-amd64:1.8.0_222 /usr/lib/jvm/zulu-7-amd64:1.7.0_232
compilehttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-633/4/artifact/out/branch-compile-hbase-server-jdk1.7.0_232.txt
compilehttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-633/4/artifact/out/patch-compile-hbase-server-jdk1.7.0_232.txt
javachttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-633/4/artifact/out/patch-compile-hbase-server-jdk1.7.0_232.txt
checkstylehttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-633/4/artifact/out/diff-checkstyle-hbase-server.txt
unithttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-633/4/artifact/out/patch-unit-hbase-server.txt
Test Resultshttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-633/4/testReport/
Max. process+thread count741 (vs. ulimit of 10000)
modulesC: hbase-server U: hbase-server
Console outputhttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-633/4/console
versionsgit=1.9.1 maven=3.0.5 findbugs=3.0.1
Powered byApache Yetus 0.11.0 https://yetus.apache.org

This message was automatically generated.

int readLen = ois.read(persistentChecksum);
if (readLen != length || !((PersistentIOEngine) ioEngine).verifyFileIntegrity(
persistentChecksum, algorithm)) {
return;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We can add an INFO log here? Or we have the log saying the verify fail in FileIOE?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

We have log if verify fail in FileIOE.

if (persistencePath != null) {
retrieveFromFile(bucketSizes);
} else {
((PersistentIOEngine) ioEngine).deleteCacheDataFile();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If we delete data file here not, there wont be any functional diff I believe. We were not doing it before. Any reason to do so now? Or we do this delete in master branch now? Not remembering exactly.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Do not delete data file does not affect the function, but it will occupy storage space.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Data file can be large, since it is out-of-date and can't be restore, i'm fine with the deletion. Being kept is also good to me, only a matter of overwrite again.

try {
byte[] calculateChecksum = calculateChecksum(algorithm);
if (!Bytes.equals(persistentChecksum, calculateChecksum)) {
throw new IOException("The persistent checksum is " + Bytes.toString(persistentChecksum) +

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The response from this method is in 2 ways for IOE or mismatch of checksum. In caller place we check for boolean return value basically. Can we just log the issue here and return boolean in any case?

return false;
} catch (NoSuchAlgorithmException nsae) {
LOG.error("No such algorithm " + algorithm, nsae);
throw new RuntimeException(nsae);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What will happen if we throw RTE here? The FileIOE create itself will get failed or even more? Retrieve from persistent cached fail need not be a reason for the FileIOE to be failed. But here we have configured this to be a persistent FileIOE. Later when we try persist during RS shutdown, we will get failure any way (?). Are u considering that here for this RTE? Am not really sure this throw RTE is correct here. Thoughts

return true;
} catch (IOException ioex) {
LOG.error("File verification failed because of ", ioex);
reinit();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why this reinit only in this case? In case of checksum mismatch no such thing happening no?

+ StringUtils.byteDesc(sizePerFile);
LOG.warn(msg);
}
rafs[i].setLength(sizePerFile);

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

setLength() can change the last modified time of the file, so the persistent checksum and calculate checksum are not equal and the unit test failed. But I don't know why my local test can pass...... Anyway, I will fix this.

int readLen = ois.read(persistentChecksum);
if (readLen != length || !((PersistentIOEngine) ioEngine).verifyFileIntegrity(
persistentChecksum, algorithm)) {
LOG.warn("Can't restore from file because of verification failed.");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Separate the if branch? readLen != length doesn't mean Can't restore from file because of verification failed

File file = new File(filePath);
if (file.length() != sizePerFile) {
rafs[i].setLength(sizePerFile);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why this change?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

setLength() method will change file's last modified time. So if don't change this, the wrong time will be used to calculate checksum.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please add a comment block // to clarify the purpose.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ya some fat comments here would be nice. Got why u have this check now.. I can think of a case though. Say we have a file based cache with one file and size was 10 GB. Now the restart of the RS happening. The cache is persisted also. Before restart the size is been increased to 20 GB. There is no truncate and ideally the cache get rebuilt. Only thing is after the restart the cache capacity is increased. But now as per the code, the length is changed here and so the last modified time and which will fail the verify phase. Is it some thing to be considered? Dont want much complex handling for this. Might not be a common case for persisted cache. Max what happening is we not able to retrieve persisted cache. But welcoming thinking/suggestion.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

If I understand you correctly, you mean change the bucket cache size before restart RS. Actually, in retrieveFromFile() method will check the bucket cache size:
if (capacitySize != cacheCapacity) throw new IOException("Mismatched cache capacity:" + StringUtils.byteDesc(capacitySize) + ", expected: " + StringUtils.byteDesc(cacheCapacity));
So change the bucket cache size will no longer retrieve from file.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yaya that was my Q.. Oh great.. I did not read whole the code.. Then its perfect. Pls add enough comments around to know why this check and set length is so imp. Great.

* @throws IOException the IOException
*/
private void reinit() throws IOException {
LOG.info("Delete the cache data file and Reinitialize the FileIOEngine.");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reinitialize lower case for R?

sb.append(getFileSize(filePath));
sb.append(file.lastModified());
} else {
throw new IOException("Cache file: " + filePath + " is not exists.");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In fact, after FileIOE inited, the file path must be exist anyway. I know's it's the complaining in code check, so can we just swallow this IOE in this method, instead of throw to upper caller?

@Apache-HBase

Copy link
Copy Markdown

💔 -1 overall

VoteSubsystemRuntimeComment
💙reexec0m 41sDocker mode activated.
_ Prechecks _
💚dupname0m 0sNo case conflicting files found.
💚hbaseanti0m 0sPatch does not have any anti-patterns.
💚@author0m 0sThe patch does not contain any @author tags.
💚test4tests0m 0sThe patch appears to include 2 new or modified test files.
_ branch-1 Compile Tests _
💚mvninstall8m 0sbranch-1 passed
💚compile1m 51sbranch-1 passed with JDK v1.8.0_222
💔compile0m 22shbase-server in branch-1 failed with JDK v1.7.0_232.
💚checkstyle1m 34sbranch-1 passed
💚shadedjars3m 7sbranch has no errors when building our shaded downstream artifacts.
💚javadoc0m 41sbranch-1 passed with JDK v1.8.0_222
💚javadoc0m 45sbranch-1 passed with JDK v1.7.0_232
💙spotbugs3m 5sUsed deprecated FindBugs config; considering switching to SpotBugs.
💚findbugs3m 1sbranch-1 passed
_ Patch Compile Tests _
💚mvninstall2m 8sthe patch passed
💚compile1m 44sthe patch passed with JDK v1.8.0_222
💚javac1m 44sthe patch passed
💔compile0m 22shbase-server in the patch failed with JDK v1.7.0_232.
💔javac0m 22shbase-server in the patch failed with JDK v1.7.0_232.
💔checkstyle1m 29shbase-server: The patch generated 1 new + 48 unchanged - 4 fixed = 49 total (was 52)
💚whitespace0m 0sThe patch has no whitespace issues.
💚shadedjars2m 41spatch has no errors when building our shaded downstream artifacts.
💚hadoopcheck5m 11sPatch does not cause any errors with Hadoop 2.8.5 2.9.2.
💚javadoc0m 30sthe patch passed with JDK v1.8.0_222
💚javadoc0m 40sthe patch passed with JDK v1.7.0_232
💚findbugs2m 49sthe patch passed
_ Other Tests _
💔unit118m 26shbase-server in the patch failed.
💚asflicense0m 34sThe patch does not generate ASF License warnings.
160m 17s
ReasonTests
Failed junit testshadoop.hbase.replication.TestReplicationChangingPeerRegionservers
SubsystemReport/Notes
DockerClient=19.03.1 Server=19.03.1 base: https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-633/5/artifact/out/Dockerfile
GITHUB PR#633
Optional Testsdupname asflicense javac javadoc unit spotbugs findbugs shadedjars hadoopcheck hbaseanti checkstyle compile
unameLinux 914bf8976aeb 4.15.0-60-generic #67-Ubuntu SMP Thu Aug 22 16:55:30 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Build toolmaven
Personality/home/jenkins/jenkins-slave/workspace/HBase-PreCommit-GitHub-PR_PR-633/out/precommit/personality/provided.sh
git revisionbranch-1 / 5c4d8e0
Default Java1.7.0_232
Multi-JDK versions/usr/lib/jvm/zulu-8-amd64:1.8.0_222 /usr/lib/jvm/zulu-7-amd64:1.7.0_232
compilehttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-633/5/artifact/out/branch-compile-hbase-server-jdk1.7.0_232.txt
compilehttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-633/5/artifact/out/patch-compile-hbase-server-jdk1.7.0_232.txt
javachttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-633/5/artifact/out/patch-compile-hbase-server-jdk1.7.0_232.txt
checkstylehttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-633/5/artifact/out/diff-checkstyle-hbase-server.txt
unithttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-633/5/artifact/out/patch-unit-hbase-server.txt
Test Resultshttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-633/5/testReport/
Max. process+thread count4236 (vs. ulimit of 10000)
modulesC: hbase-server U: hbase-server
Console outputhttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-633/5/console
versionsgit=1.9.1 maven=3.0.5 findbugs=3.0.1
Powered byApache Yetus 0.11.0 https://yetus.apache.org

This message was automatically generated.

@Reidddddd

Copy link
Copy Markdown
Contributor

Ping @anoopsjohn, when you have time. I think it cleaner than before.

@Apache-HBase

Copy link
Copy Markdown

💔 -1 overall

VoteSubsystemRuntimeComment
💙reexec0m 43sDocker mode activated.
_ Prechecks _
💚dupname0m 0sNo case conflicting files found.
💚hbaseanti0m 0sPatch does not have any anti-patterns.
💚@author0m 0sThe patch does not contain any @author tags.
💚test4tests0m 0sThe patch appears to include 2 new or modified test files.
_ branch-1 Compile Tests _
💚mvninstall8m 7sbranch-1 passed
💚compile2m 7sbranch-1 passed with JDK v1.8.0_222
💔compile0m 23shbase-server in branch-1 failed with JDK v1.7.0_232.
💚checkstyle1m 35sbranch-1 passed
💚shadedjars2m 51sbranch has no errors when building our shaded downstream artifacts.
💚javadoc0m 36sbranch-1 passed with JDK v1.8.0_222
💚javadoc0m 40sbranch-1 passed with JDK v1.7.0_232
💙spotbugs2m 46sUsed deprecated FindBugs config; considering switching to SpotBugs.
💚findbugs2m 43sbranch-1 passed
_ Patch Compile Tests _
💚mvninstall1m 53sthe patch passed
💚compile1m 42sthe patch passed with JDK v1.8.0_222
💚javac1m 42sthe patch passed
💔compile0m 23shbase-server in the patch failed with JDK v1.7.0_232.
💔javac0m 23shbase-server in the patch failed with JDK v1.7.0_232.
💔checkstyle1m 33shbase-server: The patch generated 1 new + 48 unchanged - 4 fixed = 49 total (was 52)
💚whitespace0m 0sThe patch has no whitespace issues.
💚shadedjars2m 46spatch has no errors when building our shaded downstream artifacts.
💚hadoopcheck4m 59sPatch does not cause any errors with Hadoop 2.8.5 2.9.2.
💚javadoc0m 31sthe patch passed with JDK v1.8.0_222
💚javadoc0m 40sthe patch passed with JDK v1.7.0_232
💚findbugs2m 50sthe patch passed
_ Other Tests _
💚unit116m 56shbase-server in the patch passed.
💚asflicense0m 35sThe patch does not generate ASF License warnings.
158m 2s
SubsystemReport/Notes
DockerClient=19.03.1 Server=19.03.1 base: https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-633/6/artifact/out/Dockerfile
GITHUB PR#633
Optional Testsdupname asflicense javac javadoc unit spotbugs findbugs shadedjars hadoopcheck hbaseanti checkstyle compile
unameLinux 07fdd55ccb3f 4.15.0-60-generic #67-Ubuntu SMP Thu Aug 22 16:55:30 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Build toolmaven
Personality/home/jenkins/jenkins-slave/workspace/HBase-PreCommit-GitHub-PR_PR-633/out/precommit/personality/provided.sh
git revisionbranch-1 / 5c4d8e0
Default Java1.7.0_232
Multi-JDK versions/usr/lib/jvm/zulu-8-amd64:1.8.0_222 /usr/lib/jvm/zulu-7-amd64:1.7.0_232
compilehttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-633/6/artifact/out/branch-compile-hbase-server-jdk1.7.0_232.txt
compilehttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-633/6/artifact/out/patch-compile-hbase-server-jdk1.7.0_232.txt
javachttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-633/6/artifact/out/patch-compile-hbase-server-jdk1.7.0_232.txt
checkstylehttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-633/6/artifact/out/diff-checkstyle-hbase-server.txt
Test Resultshttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-633/6/testReport/
Max. process+thread count4321 (vs. ulimit of 10000)
modulesC: hbase-server U: hbase-server
Console outputhttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-633/6/console
versionsgit=1.9.1 maven=3.0.5 findbugs=3.0.1
Powered byApache Yetus 0.11.0 https://yetus.apache.org

This message was automatically generated.

@anoopsjohnanoopsjohn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

+1
Great work.. Thanks for the perseverance

@ZhaoBQ

Copy link
Copy Markdown
ContributorAuthor

@Reidddddd@anoopsjohn Thank you for your patience and advice!

@Reidddddd
Reidddddd merged commit b5b871c into apache:branch-1Sep 20, 2019
@Apache-HBase

Copy link
Copy Markdown

💔 -1 overall

VoteSubsystemRuntimeComment
💙reexec0m 44sDocker mode activated.
_ Prechecks _
💚dupname0m 0sNo case conflicting files found.
💚hbaseanti0m 0sPatch does not have any anti-patterns.
💚@author0m 0sThe patch does not contain any @author tags.
💚test4tests0m 0sThe patch appears to include 1 new or modified test files.
_ branch-1 Compile Tests _
💚mvninstall8m 22sbranch-1 passed
💚compile2m 7sbranch-1 passed with JDK v1.8.0_222
💔compile0m 21shbase-server in branch-1 failed with JDK v1.7.0_232.
💚checkstyle1m 39sbranch-1 passed
💚shadedjars2m 57sbranch has no errors when building our shaded downstream artifacts.
💚javadoc0m 39sbranch-1 passed with JDK v1.8.0_222
💚javadoc0m 44sbranch-1 passed with JDK v1.7.0_232
💙spotbugs2m 58sUsed deprecated FindBugs config; considering switching to SpotBugs.
💚findbugs2m 54sbranch-1 passed
_ Patch Compile Tests _
💚mvninstall2m 2sthe patch passed
💚compile1m 49sthe patch passed with JDK v1.8.0_222
💚javac1m 49sthe patch passed
💔compile0m 23shbase-server in the patch failed with JDK v1.7.0_232.
💔javac0m 23shbase-server in the patch failed with JDK v1.7.0_232.
💚checkstyle1m 34shbase-server: The patch generated 0 new + 47 unchanged - 4 fixed = 47 total (was 51)
💚whitespace0m 0sThe patch has no whitespace issues.
💚shadedjars2m 54spatch has no errors when building our shaded downstream artifacts.
💚hadoopcheck5m 14sPatch does not cause any errors with Hadoop 2.8.5 2.9.2.
💚javadoc0m 33sthe patch passed with JDK v1.8.0_222
💚javadoc0m 44sthe patch passed with JDK v1.7.0_232
💚findbugs3m 1sthe patch passed
_ Other Tests _
💚unit128m 18shbase-server in the patch passed.
💚asflicense0m 32sThe patch does not generate ASF License warnings.
171m 25s
SubsystemReport/Notes
DockerClient=19.03.1 Server=19.03.1 base: https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-633/7/artifact/out/Dockerfile
GITHUB PR#633
Optional Testsdupname asflicense javac javadoc unit spotbugs findbugs shadedjars hadoopcheck hbaseanti checkstyle compile
unameLinux 7acc4c60335c 4.15.0-60-generic #67-Ubuntu SMP Thu Aug 22 16:55:30 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Build toolmaven
Personality/home/jenkins/jenkins-slave/workspace/HBase-PreCommit-GitHub-PR_PR-633/out/precommit/personality/provided.sh
git revisionbranch-1 / 5c4d8e0
Default Java1.7.0_232
Multi-JDK versions/usr/lib/jvm/zulu-8-amd64:1.8.0_222 /usr/lib/jvm/zulu-7-amd64:1.7.0_232
compilehttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-633/7/artifact/out/branch-compile-hbase-server-jdk1.7.0_232.txt
compilehttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-633/7/artifact/out/patch-compile-hbase-server-jdk1.7.0_232.txt
javachttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-633/7/artifact/out/patch-compile-hbase-server-jdk1.7.0_232.txt
Test Resultshttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-633/7/testReport/
Max. process+thread count4318 (vs. ulimit of 10000)
modulesC: hbase-server U: hbase-server
Console outputhttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-633/7/console
versionsgit=1.9.1 maven=3.0.5 findbugs=3.0.1
Powered byApache Yetus 0.11.0 https://yetus.apache.org

This message was automatically generated.

stoty pushed a commit to stoty/hbase that referenced this pull request Nov 22, 2025
Sign up for freeto 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.

4 participants

@ZhaoBQ@Apache-HBase@Reidddddd@anoopsjohn