palantir / atlasdb

Transactional Distributed Database Layer
https://palantir.github.io/atlasdb/
Apache License 2.0
46 stars 7 forks source link

Improve stream store exceptions #7006

Closed pkoenig10 closed 4 months ago

pkoenig10 commented 4 months ago

We recently had a bug a NullPointerException was being thrown when consuming a stream.

java.lang.NullPointerException: {throwable0_message}
    at java.base/java.io.OutputStream.write(OutputStream.java:124)
    at com.palantir.example.MyStreamStore.loadSingleBlockToOutputStream(MyStreamStore.java:193)
    at com.palantir.example.MyStreamStore.loadSingleBlockToOutputStream(MyStreamStore.java:75)
    at com.palantir.atlasdb.stream.AbstractGenericStreamStore.loadNBlocksToOutputStream(AbstractGenericStreamStore.java:211)
    at com.palantir.atlasdb.stream.AbstractGenericStreamStore$1.lambda$get$0(AbstractGenericStreamStore.java:135)

In this instance, we were attempting to consume a stream outside of the transaction where it was loaded. A subsequent transaction marked the stream as unused and we then failed to read a block from the stream, resulting in a NullPointerException thrown in OutputStream.write when we attempt to get the length of a null byte[].

https://github.com/openjdk/jdk/blob/890adb6410dab4606a4f26a942aed02fb2f55387/src/java.base/share/classes/java/io/OutputStream.java#L124

This is clearly not a AtlasDB bug. But there are some changes we could make to the stream store to make it easier to diagnose these issues in the future:

svc-autorelease commented 4 months ago

Released 0.1057.0