Skip to content

HADOOP-16785: wasb to raise IOE if write() invoked on a closed stream #1791

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

Conversation

steveloughran
Copy link
Contributor

adds

  • fix for problem
  • test for fix
  • an extra assert to help debug abfs test config
  • and LTU.intercept to declare class of expected exception when none
    was raised.

Change-Id: I37951f0a3881d9b9849c4a51159d6670583f65c1

with
* test
* bit of extra asserts to help debug config
* and LTU.intercept to declare class of expected exception when none
was raised.

Change-Id: I37951f0a3881d9b9849c4a51159d6670583f65c1
@steveloughran
Copy link
Contributor Author

Tested: azure wales

@bgaborg , @ThomasMarquardt -fancy a quick look at this?

@hadoop-yetus
Copy link

🎊 +1 overall

Vote Subsystem Runtime Comment
+0 🆗 reexec 1m 13s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 0s No case conflicting files found.
+1 💚 @author 0m 0s The patch does not contain any @author tags.
+1 💚 test4tests 0m 0s The patch appears to include 3 new or modified test files.
_ trunk Compile Tests _
+0 🆗 mvndep 0m 25s Maven dependency ordering for branch
+1 💚 mvninstall 21m 40s trunk passed
+1 💚 compile 16m 42s trunk passed
+1 💚 checkstyle 2m 38s trunk passed
+1 💚 mvnsite 2m 14s trunk passed
+1 💚 shadedclient 18m 56s branch has no errors when building and testing our client artifacts.
+1 💚 javadoc 2m 13s trunk passed
+0 🆗 spotbugs 1m 2s Used deprecated FindBugs config; considering switching to SpotBugs.
+1 💚 findbugs 3m 3s trunk passed
_ Patch Compile Tests _
+0 🆗 mvndep 0m 25s Maven dependency ordering for patch
+1 💚 mvninstall 1m 15s the patch passed
+1 💚 compile 15m 48s the patch passed
+1 💚 javac 15m 48s the patch passed
+1 💚 checkstyle 2m 37s the patch passed
+1 💚 mvnsite 2m 11s the patch passed
+1 💚 whitespace 0m 0s The patch has no whitespace issues.
+1 💚 shadedclient 12m 53s patch has no errors when building and testing our client artifacts.
+1 💚 javadoc 2m 11s the patch passed
+1 💚 findbugs 3m 24s the patch passed
_ Other Tests _
+1 💚 unit 9m 13s hadoop-common in the patch passed.
+1 💚 unit 1m 38s hadoop-azure in the patch passed.
+1 💚 asflicense 0m 54s The patch does not generate ASF License warnings.
121m 55s
Subsystem Report/Notes
Docker Client=19.03.5 Server=19.03.5 base: https://builds.apache.org/job/hadoop-multibranch/job/PR-1791/1/artifact/out/Dockerfile
GITHUB PR #1791
JIRA Issue HADOOP-16785
Optional Tests dupname asflicense compile javac javadoc mvninstall mvnsite unit shadedclient findbugs checkstyle
uname Linux d3a2744d8dab 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 personality/hadoop.sh
git revision trunk / 037ec8c
Default Java 1.8.0_232
Test Results https://builds.apache.org/job/hadoop-multibranch/job/PR-1791/1/testReport/
Max. process+thread count 1367 (vs. ulimit of 5500)
modules C: hadoop-common-project/hadoop-common hadoop-tools/hadoop-azure U: .
Console output https://builds.apache.org/job/hadoop-multibranch/job/PR-1791/1/console
versions git=2.7.4 maven=3.3.9 findbugs=3.1.0-RC1
Powered by Apache Yetus 0.11.1 https://yetus.apache.org

This message was automatically generated.

It is, but hsync() fails on a closed file. Commented out that
operation.

It does handle flush(), which is good as some apps do call it on closed files.

Change-Id: I25414cc500feb9391dc520e5292250945d6576e6
Change-Id: I26af214bd40b28aa006d27e6ef22b8cefb39a799
@steveloughran
Copy link
Contributor Author

I can't replicate that in the test -but can see how it does surface...it's in the close() of a try-with-resources

  • If a call like out.flush() raises an IOE, try-with-resources tries to close the stream
  • and an exception from close() is added to the first IOE via addSuppressed
  • which doesn't let you add the caught exception to itself.
  • So if the ABFS stream close() always rethrows the same exception, you get a failure.
  • This could happen if there had been some previous failure and maybeRethrowException() was throwing it - the final
    flushInternal() call will throw the same exception, so addSuppressed will fail.

I'm patching flushInternal() so that if it rethrows an exception in close, it wraps that with a covering IOE. (it still nests the inner, so there is a loop in the chain).

Change-Id: I5ffa417219249e102bf7e861d357b57af3b780f0
@steveloughran
Copy link
Contributor Author

tested -azure wales. All good except for HADOOP-16706 and org.apache.hadoop.fs.azurebfs.ITestClientUrlScheme

@hadoop-yetus
Copy link

💔 -1 overall

Vote Subsystem Runtime Comment
+0 🆗 reexec 1m 12s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 0s No case conflicting files found.
+1 💚 @author 0m 0s The patch does not contain any @author tags.
+1 💚 test4tests 0m 0s The patch appears to include 4 new or modified test files.
_ trunk Compile Tests _
+0 🆗 mvndep 1m 18s Maven dependency ordering for branch
+1 💚 mvninstall 20m 49s trunk passed
+1 💚 compile 17m 29s trunk passed
+1 💚 checkstyle 2m 49s trunk passed
+1 💚 mvnsite 2m 0s trunk passed
+1 💚 shadedclient 19m 41s branch has no errors when building and testing our client artifacts.
+1 💚 javadoc 1m 55s trunk passed
+0 🆗 spotbugs 0m 58s Used deprecated FindBugs config; considering switching to SpotBugs.
+1 💚 findbugs 3m 1s trunk passed
_ Patch Compile Tests _
+0 🆗 mvndep 0m 21s Maven dependency ordering for patch
+1 💚 mvninstall 1m 13s the patch passed
+1 💚 compile 16m 51s the patch passed
+1 💚 javac 16m 51s the patch passed
-0 ⚠️ checkstyle 2m 58s root: The patch generated 1 new + 29 unchanged - 0 fixed = 30 total (was 29)
+1 💚 mvnsite 2m 13s the patch passed
+1 💚 whitespace 0m 0s The patch has no whitespace issues.
+1 💚 shadedclient 14m 13s patch has no errors when building and testing our client artifacts.
+1 💚 javadoc 2m 2s the patch passed
+1 💚 findbugs 3m 38s the patch passed
_ Other Tests _
-1 ❌ unit 8m 56s hadoop-common in the patch failed.
+1 💚 unit 1m 32s hadoop-azure in the patch passed.
+1 💚 asflicense 0m 45s The patch does not generate ASF License warnings.
124m 39s
Reason Tests
Failed junit tests hadoop.security.TestFixKerberosTicketOrder
Subsystem Report/Notes
Docker Client=19.03.5 Server=19.03.5 base: https://builds.apache.org/job/hadoop-multibranch/job/PR-1791/4/artifact/out/Dockerfile
GITHUB PR #1791
JIRA Issue HADOOP-16785
Optional Tests dupname asflicense compile javac javadoc mvninstall mvnsite unit shadedclient findbugs checkstyle
uname Linux eb4d151346fc 4.15.0-66-generic #75-Ubuntu SMP Tue Oct 1 05:24:09 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality personality/hadoop.sh
git revision trunk / 768ee22
Default Java 1.8.0_232
checkstyle https://builds.apache.org/job/hadoop-multibranch/job/PR-1791/4/artifact/out/diff-checkstyle-root.txt
unit https://builds.apache.org/job/hadoop-multibranch/job/PR-1791/4/artifact/out/patch-unit-hadoop-common-project_hadoop-common.txt
Test Results https://builds.apache.org/job/hadoop-multibranch/job/PR-1791/4/testReport/
Max. process+thread count 1344 (vs. ulimit of 5500)
modules C: hadoop-common-project/hadoop-common hadoop-tools/hadoop-azure U: .
Console output https://builds.apache.org/job/hadoop-multibranch/job/PR-1791/4/console
versions git=2.7.4 maven=3.3.9 findbugs=3.1.0-RC1
Powered by Apache Yetus 0.11.1 https://yetus.apache.org

This message was automatically generated.

throw new IOException("Skipping final flush and write due to " + e, e);
} else
throw e;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead, I think we should update AbfsOutputStream.close to wrap the exception, short of having the Java implementers fix 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.

thought of that, but also thought it might be good to differentiate exception raised in the later bits of the flush. Keeping it in close() is cleaner as it puts the problem where it belongs

* exception rethrows the first.
*/
@Test
public void testFilteredDoubleClose() throws Throwable {
Copy link
Contributor

Choose a reason for hiding this comment

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

Double close would have already been passing with these changes. To really test the try-with-resources I think you need to modify the underlying blob after fs.create but before flush so that flush fails and sets AbfsOutputStream.lastError. For example, if you write some data to the blob so that the position held by the AbfsOutputStream is invalid, flush may fail. For example, the following test:

out = fs.create(path)
out.write('a');
// externally write data to the same path so that the next call to flush will fail due to position being off.
intercept(IOException.class, () -> out.flush());
intercept(IOException.class, () -> out.close());

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right, I couldn't think how to reliably replicate it. without going near mockito etc.,

or we add a package level setLastError() call?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can simply create a second stream for the same path, or even call delete on it after writing some data with the other stream. Basically, write to the same path with two streams.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, write+delete does the trick

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

checkstyle

/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsOutputStream.java:268:      } else: 'else' construct must use '{}'s. [NeedBraces]

of the same class.

This moves the wrapping logic out of flushInternal into close(),
using IOUtils.wrapException to ensure the type of the wrapped exception
is the same as that caught (without that the E2E exceptions fail).

the test uses try-with-resources as suggested by Thomas; we delete a file while
it is being written; this causes hsync to fail -with close() also throwing
an exception which is then caught and suppressed.

Change-Id: If1bcd2885bccbf39de888b8295a5a7e529935f2d
@steveloughran
Copy link
Contributor Author

Updated patch adds the test recommended by thomas and wraps the exception in close, while retaining the class of the original exception.

Tested: ABFS wales. It's very fast :)

  • the new tests HADOOP-16455 failed, I don't have an oauth2.client.id . Taking up on the JIRA.
  • .ITestClientUrlScheme fails as my a/c is HTTPS only

@hadoop-yetus
Copy link

🎊 +1 overall

Vote Subsystem Runtime Comment
+0 🆗 reexec 1m 12s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 0s No case conflicting files found.
+1 💚 @author 0m 0s The patch does not contain any @author tags.
+1 💚 test4tests 0m 0s The patch appears to include 4 new or modified test files.
_ trunk Compile Tests _
+0 🆗 mvndep 0m 25s Maven dependency ordering for branch
+1 💚 mvninstall 30m 55s trunk passed
+1 💚 compile 29m 31s trunk passed
+1 💚 checkstyle 2m 32s trunk passed
+1 💚 mvnsite 2m 12s trunk passed
+1 💚 shadedclient 20m 21s branch has no errors when building and testing our client artifacts.
+1 💚 javadoc 2m 4s trunk passed
+0 🆗 spotbugs 1m 2s Used deprecated FindBugs config; considering switching to SpotBugs.
+1 💚 findbugs 3m 1s trunk passed
_ Patch Compile Tests _
+0 🆗 mvndep 0m 25s Maven dependency ordering for patch
+1 💚 mvninstall 1m 21s the patch passed
+1 💚 compile 17m 7s the patch passed
+1 💚 javac 17m 7s the patch passed
+1 💚 checkstyle 2m 33s the patch passed
+1 💚 mvnsite 2m 2s the patch passed
+1 💚 whitespace 0m 0s The patch has no whitespace issues.
+1 💚 shadedclient 12m 21s patch has no errors when building and testing our client artifacts.
+1 💚 javadoc 2m 10s the patch passed
+1 💚 findbugs 3m 28s the patch passed
_ Other Tests _
+1 💚 unit 9m 18s hadoop-common in the patch passed.
+1 💚 unit 1m 35s hadoop-azure in the patch passed.
+1 💚 asflicense 0m 51s The patch does not generate ASF License warnings.
145m 44s
Subsystem Report/Notes
Docker Client=19.03.5 Server=19.03.5 base: https://builds.apache.org/job/hadoop-multibranch/job/PR-1791/5/artifact/out/Dockerfile
GITHUB PR #1791
JIRA Issue HADOOP-16785
Optional Tests dupname asflicense compile javac javadoc mvninstall mvnsite unit shadedclient findbugs checkstyle
uname Linux 938169794dd1 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 personality/hadoop.sh
git revision trunk / bc366d4
Default Java 1.8.0_232
Test Results https://builds.apache.org/job/hadoop-multibranch/job/PR-1791/5/testReport/
Max. process+thread count 1372 (vs. ulimit of 5500)
modules C: hadoop-common-project/hadoop-common hadoop-tools/hadoop-azure U: .
Console output https://builds.apache.org/job/hadoop-multibranch/job/PR-1791/5/console
versions git=2.7.4 maven=3.3.9 findbugs=3.1.0-RC1
Powered by Apache Yetus 0.11.1 https://yetus.apache.org

This message was automatically generated.

@steveloughran
Copy link
Contributor Author

added a followup #1809 -an extra test to confirm the filter output stream close was happy

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.

3 participants