Skip to content

HDFS-15042 Add more tests for ByteBufferPositionedReadable. #1747

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

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from

Conversation

steveloughran
Copy link
Contributor

Changes

  • Javadocs in ByteBufferPositionedReadable are a bit stricter.
  • switch to parameterized JUnit test runs for on/off heap buffers
  • factor put main assertions into higher level asserts

New tests

  • negative offset for reads of actual/empty buffers
  • read position > EOF.
  • empty files
  • verify that interleaving simple reads/seeks work.

Change-Id: I27294b15f7cad8e1b87150d9e9fac0623fc44c45

@apache apache deleted a comment from hadoop-yetus Jan 3, 2020
@steveloughran
Copy link
Contributor Author

hdfs failures clearly something else

[INFO] 
[INFO] Results:
[INFO] 
[ERROR] Failures: 
[ERROR]   TestMultipleNNPortQOP.testMultipleNNPortOverwriteDownStream:177 expected:<auth> but was:<null>
[ERROR]   TestRedudantBlocks.testProcessOverReplicatedAndRedudantBlock:138 expected:<5> but was:<4>
[ERROR] Errors: 
[ERROR]   TestDeadNodeDetection.testDeadNodeDetectionInBackground:105->waitForDeadNode:321 ? Timeout
[ERROR]   TestUnderReplicatedBlocks.testSetRepIncWithUnderReplicatedBlocks:80 ? TestTimedOut
[INFO] 

will rebase and fix checkstyles anyway

@apache apache deleted a comment from hadoop-yetus Apr 28, 2020
@jojochuang jojochuang added the HDFS label May 1, 2020
@jojochuang
Copy link
Contributor

@sahilTakiar fyi

@steveloughran steveloughran force-pushed the filesystem/HDFS-15042-ByteBufferPositionedReadable branch from 067e0a0 to 79f8583 Compare May 23, 2020 12:22
@steveloughran
Copy link
Contributor Author

Again, hadoop-hdfs test failures must be unrelated: this patch doesn't touch those tests

@steveloughran
Copy link
Contributor Author

./hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FSExceptionMessages.java:42:    "Cannot read from a negative position";: '"Cannot read from a negative position"' has incorrect indentation level 4, expected level should be 6. [Indentation]
./hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FSExceptionMessages.java:44:  /**: First sent

@apache apache deleted a comment from hadoop-yetus Oct 2, 2020
@apache apache deleted a comment from hadoop-yetus Oct 2, 2020
@steveloughran steveloughran force-pushed the filesystem/HDFS-15042-ByteBufferPositionedReadable branch from 79f8583 to 44494c7 Compare November 27, 2020 14:01
@apache apache deleted a comment from hadoop-yetus Oct 15, 2021
@apache apache deleted a comment from hadoop-yetus Oct 15, 2021
@steveloughran steveloughran force-pushed the filesystem/HDFS-15042-ByteBufferPositionedReadable branch from 44494c7 to ab7c180 Compare May 30, 2022 14:31
@steveloughran steveloughran force-pushed the filesystem/HDFS-15042-ByteBufferPositionedReadable branch from ab7c180 to 6e050d9 Compare June 10, 2022 16:09
@hadoop-yetus
Copy link

💔 -1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 1m 6s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 0s No case conflicting files found.
+0 🆗 codespell 0m 1s codespell was not available.
+0 🆗 detsecrets 0m 1s detect-secrets was not available.
+1 💚 @author 0m 0s The patch does not contain any @author tags.
+1 💚 test4tests 0m 0s The patch appears to include 2 new or modified test files.
_ trunk Compile Tests _
+0 🆗 mvndep 14m 35s Maven dependency ordering for branch
+1 💚 mvninstall 24m 49s trunk passed
+1 💚 compile 23m 5s trunk passed with JDK Private Build-11.0.15+10-Ubuntu-0ubuntu0.20.04.1
+1 💚 compile 21m 17s trunk passed with JDK Private Build-1.8.0_312-8u312-b07-0ubuntu1~20.04-b07
+1 💚 checkstyle 4m 48s trunk passed
+1 💚 mvnsite 6m 19s trunk passed
-1 ❌ javadoc 1m 53s /branch-javadoc-hadoop-hdfs-project_hadoop-hdfs-jdkPrivateBuild-11.0.15+10-Ubuntu-0ubuntu0.20.04.1.txt hadoop-hdfs in trunk failed with JDK Private Build-11.0.15+10-Ubuntu-0ubuntu0.20.04.1.
+1 💚 javadoc 4m 59s trunk passed with JDK Private Build-1.8.0_312-8u312-b07-0ubuntu1~20.04-b07
+1 💚 spotbugs 10m 24s trunk passed
+1 💚 shadedclient 24m 10s branch has no errors when building and testing our client artifacts.
_ Patch Compile Tests _
+0 🆗 mvndep 0m 31s Maven dependency ordering for patch
+1 💚 mvninstall 3m 28s the patch passed
+1 💚 compile 22m 12s the patch passed with JDK Private Build-11.0.15+10-Ubuntu-0ubuntu0.20.04.1
+1 💚 javac 22m 12s the patch passed
+1 💚 compile 20m 40s the patch passed with JDK Private Build-1.8.0_312-8u312-b07-0ubuntu1~20.04-b07
+1 💚 javac 20m 40s the patch passed
+1 💚 blanks 0m 0s The patch has no blanks issues.
+1 💚 checkstyle 4m 15s root: The patch generated 0 new + 45 unchanged - 5 fixed = 45 total (was 50)
+1 💚 mvnsite 6m 15s the patch passed
-1 ❌ javadoc 1m 45s /patch-javadoc-hadoop-hdfs-project_hadoop-hdfs-jdkPrivateBuild-11.0.15+10-Ubuntu-0ubuntu0.20.04.1.txt hadoop-hdfs in the patch failed with JDK Private Build-11.0.15+10-Ubuntu-0ubuntu0.20.04.1.
+1 💚 javadoc 5m 0s the patch passed with JDK Private Build-1.8.0_312-8u312-b07-0ubuntu1~20.04-b07
+1 💚 spotbugs 10m 49s the patch passed
+1 💚 shadedclient 24m 40s patch has no errors when building and testing our client artifacts.
_ Other Tests _
+1 💚 unit 18m 48s hadoop-common in the patch passed.
+1 💚 unit 3m 17s hadoop-hdfs-client in the patch passed.
-1 ❌ unit 422m 59s /patch-unit-hadoop-hdfs-project_hadoop-hdfs.txt hadoop-hdfs in the patch passed.
+1 💚 asflicense 1m 58s The patch does not generate ASF License warnings.
691m 22s
Reason Tests
Failed junit tests hadoop.hdfs.TestClientProtocolForPipelineRecovery
Subsystem Report/Notes
Docker ClientAPI=1.41 ServerAPI=1.41 base: https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-1747/3/artifact/out/Dockerfile
GITHUB PR #1747
Optional Tests dupname asflicense compile javac javadoc mvninstall mvnsite unit shadedclient spotbugs checkstyle codespell detsecrets
uname Linux e6aee3cc13cc 4.15.0-65-generic #74-Ubuntu SMP Tue Sep 17 17:06:04 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/bin/hadoop.sh
git revision trunk / 6e050d9a4d60a91c90e91c0e1a5ae3edeb770ddf
Default Java Private Build-1.8.0_312-8u312-b07-0ubuntu1~20.04-b07
Multi-JDK versions /usr/lib/jvm/java-11-openjdk-amd64:Private Build-11.0.15+10-Ubuntu-0ubuntu0.20.04.1 /usr/lib/jvm/java-8-openjdk-amd64:Private Build-1.8.0_312-8u312-b07-0ubuntu1~20.04-b07
Test Results https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-1747/3/testReport/
Max. process+thread count 2699 (vs. ulimit of 5500)
modules C: hadoop-common-project/hadoop-common hadoop-hdfs-project/hadoop-hdfs-client hadoop-hdfs-project/hadoop-hdfs U: .
Console output https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-1747/3/console
versions git=2.25.1 maven=3.6.3 spotbugs=4.2.2
Powered by Apache Yetus 0.14.0 https://yetus.apache.org

This message was automatically generated.

@steveloughran
Copy link
Contributor Author

both failures are unrelated...will rebase.

test failure is in TestClientProtocolForPipelineRecovery;

javadoc failure

[ERROR] /home/jenkins/jenkins-home/workspace/hadoop-multibranch_PR-1747/ubuntu-focal/src/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/startupprogress/package-info.java:20: error: reference not found
[ERROR]  * This package provides a mechanism for tracking {@link NameNode} startup

Changes

* Javadocs in ByteBufferPositionedReadable are a bit stricter.
* switch to parameterized JUnit test runs for on/off heap buffers
* factor put main assertions into higher level asserts

New tests
* negative offset for reads of actual/empty buffers
* read position > EOF.
* empty files
* verify that interleaving simple reads/seeks work.

Change-Id: I27294b15f7cad8e1b87150d9e9fac0623fc44c45
Change-Id: I4c8b17dd897a11d4c8e22b9cbc366455c958242c
@steveloughran steveloughran force-pushed the filesystem/HDFS-15042-ByteBufferPositionedReadable branch from 6e050d9 to ac0bcd8 Compare August 5, 2022 16:29
@hadoop-yetus
Copy link

🎊 +1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 0m 43s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 1s No case conflicting files found.
+0 🆗 codespell 0m 0s codespell was not available.
+0 🆗 detsecrets 0m 0s detect-secrets was not available.
+1 💚 @author 0m 0s The patch does not contain any @author tags.
+1 💚 test4tests 0m 0s The patch appears to include 2 new or modified test files.
_ trunk Compile Tests _
+0 🆗 mvndep 15m 9s Maven dependency ordering for branch
+1 💚 mvninstall 25m 32s trunk passed
+1 💚 compile 23m 5s trunk passed with JDK Private Build-11.0.15+10-Ubuntu-0ubuntu0.20.04.1
+1 💚 compile 20m 53s trunk passed with JDK Private Build-1.8.0_312-8u312-b07-0ubuntu1~20.04-b07
+1 💚 checkstyle 4m 23s trunk passed
+1 💚 mvnsite 6m 14s trunk passed
+1 💚 javadoc 4m 54s trunk passed with JDK Private Build-11.0.15+10-Ubuntu-0ubuntu0.20.04.1
+1 💚 javadoc 5m 2s trunk passed with JDK Private Build-1.8.0_312-8u312-b07-0ubuntu1~20.04-b07
+1 💚 spotbugs 10m 18s trunk passed
+1 💚 shadedclient 24m 24s branch has no errors when building and testing our client artifacts.
_ Patch Compile Tests _
+0 🆗 mvndep 0m 34s Maven dependency ordering for patch
+1 💚 mvninstall 3m 26s the patch passed
+1 💚 compile 22m 22s the patch passed with JDK Private Build-11.0.15+10-Ubuntu-0ubuntu0.20.04.1
+1 💚 javac 22m 22s the patch passed
+1 💚 compile 20m 50s the patch passed with JDK Private Build-1.8.0_312-8u312-b07-0ubuntu1~20.04-b07
+1 💚 javac 20m 50s the patch passed
+1 💚 blanks 0m 0s The patch has no blanks issues.
+1 💚 checkstyle 4m 15s root: The patch generated 0 new + 45 unchanged - 5 fixed = 45 total (was 50)
+1 💚 mvnsite 6m 2s the patch passed
+1 💚 javadoc 4m 55s the patch passed with JDK Private Build-11.0.15+10-Ubuntu-0ubuntu0.20.04.1
+1 💚 javadoc 5m 4s the patch passed with JDK Private Build-1.8.0_312-8u312-b07-0ubuntu1~20.04-b07
+1 💚 spotbugs 10m 47s the patch passed
+1 💚 shadedclient 24m 39s patch has no errors when building and testing our client artifacts.
_ Other Tests _
+1 💚 unit 18m 53s hadoop-common in the patch passed.
+1 💚 unit 3m 16s hadoop-hdfs-client in the patch passed.
+1 💚 unit 236m 38s hadoop-hdfs in the patch passed.
+1 💚 asflicense 1m 58s The patch does not generate ASF License warnings.
505m 42s
Subsystem Report/Notes
Docker ClientAPI=1.41 ServerAPI=1.41 base: https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-1747/4/artifact/out/Dockerfile
GITHUB PR #1747
Optional Tests dupname asflicense compile javac javadoc mvninstall mvnsite unit shadedclient spotbugs checkstyle codespell detsecrets
uname Linux dd0b9f467640 4.15.0-112-generic #113-Ubuntu SMP Thu Jul 9 23:41:39 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/bin/hadoop.sh
git revision trunk / ac0bcd8
Default Java Private Build-1.8.0_312-8u312-b07-0ubuntu1~20.04-b07
Multi-JDK versions /usr/lib/jvm/java-11-openjdk-amd64:Private Build-11.0.15+10-Ubuntu-0ubuntu0.20.04.1 /usr/lib/jvm/java-8-openjdk-amd64:Private Build-1.8.0_312-8u312-b07-0ubuntu1~20.04-b07
Test Results https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-1747/4/testReport/
Max. process+thread count 3489 (vs. ulimit of 5500)
modules C: hadoop-common-project/hadoop-common hadoop-hdfs-project/hadoop-hdfs-client hadoop-hdfs-project/hadoop-hdfs U: .
Console output https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-1747/4/console
versions git=2.25.1 maven=3.6.3 spotbugs=4.2.2
Powered by Apache Yetus 0.14.0 https://yetus.apache.org

This message was automatically generated.

@apache apache deleted a comment from hadoop-yetus Aug 8, 2022
@steveloughran
Copy link
Contributor Author

@mukund-thakur @mehakmeet @virajjasani

could i get a quick review of this? i want these tests in before anyone tries to implement it in s3a/abfs/gcs via vectored io

Copy link
Contributor

@virajjasani virajjasani left a comment

Choose a reason for hiding this comment

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

Left minor comments with Javadocs, the core logic and tests look good.

* <p>
* <b>Thread safety</b>
* <p>
* These operations doe not change the current offset of a stream as returned
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: s/doe/does

Comment on lines +74 to +75
* The {@code position} offset MUST BE zero or positive; if negative
* an EOFException SHALL BE raised.
Copy link
Contributor

Choose a reason for hiding this comment

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

If position is negative, this method seems to be returning -1 instead of throwing EOF with NEGATIVE_POSITION_READ reason. EOF with NEGATIVE_POSITION_READ is being thrown with this patch only with void readFully(long position, ByteBuffer buf) method.

DFSInputStream:

  private int pread(long position, ByteBuffer buffer)
      throws IOException {
    // sanity checks
    dfsClient.checkOpen();
    if (closed.get()) {
      throw new IOException("Stream closed");
    }
    failures = 0;
    long filelen = getFileLength();
    if ((position < 0) || (position >= filelen)) {
      return -1;
    }

Copy link
Member

@ayushtkn ayushtkn Aug 9, 2022

Choose a reason for hiding this comment

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

Just to be clear, we can't change the behaviour of the stream as well, we just need to correct the JavaDoc, changing behaviour to now throw EOF will be incompatible
The below Javadoc also marks -1 as a legitimate return value

   * @return the number of bytes read, possibly zero, or -1 if reached
   *         end-of-stream

Copy link
Contributor Author

Choose a reason for hiding this comment

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

well, i think that's broken. like you say, can't fix though. or we could, but that complicates code written against the eof raising impl running against older/external stuff

Comment on lines +1688 to +1690
if (position < 0) {
throw new EOFException(NEGATIVE_POSITION_READ);
}
Copy link
Member

Choose a reason for hiding this comment

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

The exception message will change now, earlier it would be from below

      if (nbytes < 0) {
        throw new EOFException(FSExceptionMessages.EOF_IN_READ_FULLY);
      }

Someone asserting on the exception message will get issues, not sure if it is something to do in scope of adding new tests

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I would also not want to change this.

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

*/
private void assertStreamPosition(final Seekable in, long pos)
throws IOException {
assertEquals("Buffer position",
Copy link
Member

Choose a reason for hiding this comment

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

This should be Stream Position

Comment on lines +418 to +422
if (buffer.position() > 0) {
// this implementation does not do a range check before the read;
// it got partway through before failing.
// this is not an error -just inefficient.
LOG.warn("Buffer reads began before range checks with {}", in);
Copy link
Member

Choose a reason for hiding this comment

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

What is the benefit of having this, is this log gonna help sometime is debugging?

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 really don't remember. this is a pr from 2019.

@hadoop-yetus
Copy link

🎊 +1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 0m 58s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 0s No case conflicting files found.
+0 🆗 codespell 0m 0s codespell was not available.
+0 🆗 detsecrets 0m 0s detect-secrets was not available.
+1 💚 @author 0m 0s The patch does not contain any @author tags.
+1 💚 test4tests 0m 0s The patch appears to include 2 new or modified test files.
_ trunk Compile Tests _
+0 🆗 mvndep 15m 44s Maven dependency ordering for branch
+1 💚 mvninstall 31m 24s trunk passed
+1 💚 compile 17m 21s trunk passed with JDK Ubuntu-11.0.19+7-post-Ubuntu-0ubuntu120.04.1
+1 💚 compile 16m 2s trunk passed with JDK Private Build-1.8.0_362-8u372-gaus1-0ubuntu120.04-b09
+1 💚 checkstyle 4m 27s trunk passed
+1 💚 mvnsite 4m 57s trunk passed
+1 💚 javadoc 3m 49s trunk passed with JDK Ubuntu-11.0.19+7-post-Ubuntu-0ubuntu120.04.1
+1 💚 javadoc 3m 59s trunk passed with JDK Private Build-1.8.0_362-8u372-gaus1-0ubuntu120.04-b09
+1 💚 spotbugs 9m 0s trunk passed
+1 💚 shadedclient 37m 55s branch has no errors when building and testing our client artifacts.
_ Patch Compile Tests _
+0 🆗 mvndep 0m 33s Maven dependency ordering for patch
+1 💚 mvninstall 3m 5s the patch passed
+1 💚 compile 18m 49s the patch passed with JDK Ubuntu-11.0.19+7-post-Ubuntu-0ubuntu120.04.1
+1 💚 javac 18m 49s the patch passed
+1 💚 compile 18m 14s the patch passed with JDK Private Build-1.8.0_362-8u372-gaus1-0ubuntu120.04-b09
+1 💚 javac 18m 14s the patch passed
+1 💚 blanks 0m 0s The patch has no blanks issues.
+1 💚 checkstyle 4m 16s root: The patch generated 0 new + 45 unchanged - 5 fixed = 45 total (was 50)
+1 💚 mvnsite 4m 46s the patch passed
+1 💚 javadoc 3m 49s the patch passed with JDK Ubuntu-11.0.19+7-post-Ubuntu-0ubuntu120.04.1
+1 💚 javadoc 4m 0s the patch passed with JDK Private Build-1.8.0_362-8u372-gaus1-0ubuntu120.04-b09
+1 💚 spotbugs 9m 47s the patch passed
+1 💚 shadedclient 39m 51s patch has no errors when building and testing our client artifacts.
_ Other Tests _
+1 💚 unit 19m 18s hadoop-common in the patch passed.
+1 💚 unit 2m 53s hadoop-hdfs-client in the patch passed.
+1 💚 unit 254m 44s hadoop-hdfs in the patch passed.
+1 💚 asflicense 1m 25s The patch does not generate ASF License warnings.
533m 51s
Subsystem Report/Notes
Docker ClientAPI=1.43 ServerAPI=1.43 base: https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-1747/1/artifact/out/Dockerfile
GITHUB PR #1747
Optional Tests dupname asflicense compile javac javadoc mvninstall mvnsite unit shadedclient spotbugs checkstyle codespell detsecrets
uname Linux d5d1eca41bff 4.15.0-212-generic #223-Ubuntu SMP Tue May 23 13:09:22 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/bin/hadoop.sh
git revision trunk / ac0bcd8
Default Java Private Build-1.8.0_362-8u372-gaus1-0ubuntu120.04-b09
Multi-JDK versions /usr/lib/jvm/java-11-openjdk-amd64:Ubuntu-11.0.19+7-post-Ubuntu-0ubuntu120.04.1 /usr/lib/jvm/java-8-openjdk-amd64:Private Build-1.8.0_362-8u372-gaus1-0ubuntu120.04-b09
Test Results https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-1747/1/testReport/
Max. process+thread count 3023 (vs. ulimit of 5500)
modules C: hadoop-common-project/hadoop-common hadoop-hdfs-project/hadoop-hdfs-client hadoop-hdfs-project/hadoop-hdfs U: .
Console output https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-1747/1/console
versions git=2.25.1 maven=3.6.3 spotbugs=4.2.2
Powered by Apache Yetus 0.14.0 https://yetus.apache.org

This message was automatically generated.

Copy link
Contributor

@mukund-thakur mukund-thakur left a comment

Choose a reason for hiding this comment

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

seems like my comment was in pending state.

Comment on lines +1688 to +1690
if (position < 0) {
throw new EOFException(NEGATIVE_POSITION_READ);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I would also not want to change this.

@steveloughran
Copy link
Contributor Author

Forgotten about this. #6686 would benefit from this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants