The dreaded NPE, and transaction boundary thought

13 views
Skip to first unread message

Andrew McConnell

unread,
Dec 9, 2019, 9:44:40 PM12/9/19
to Trellis LDP
I got an NPE storing a container this evening.

2019-12-10 02:11:11,662 ERROR [org.tre.htt.TrellisHttpResource] (Thread-11) Error:: java.util.concurrent.CompletionException: org.trellisldp.api.RuntimeTrellisException: Error storing audit dataset for <trellis:data/photos2>
at java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:273)
at java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:280)
at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1629)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.trellisldp.api.RuntimeTrellisException: Error storing audit dataset for <trellis:data/photos2>
at org.trellisldp.ext.db.DBResourceService.lambda$add$35(DBResourceService.java:211)
at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1626)
... 1 more
Caused by: java.lang.NullPointerException
at org.jdbi.v3.core.statement.ArgumentBinder.bindPositional(ArgumentBinder.java:37)
at org.jdbi.v3.core.statement.ArgumentBinder.bind(ArgumentBinder.java:29)
at org.jdbi.v3.core.statement.PreparedBatch.internalBatchExecute(PreparedBatch.java:164)
at org.jdbi.v3.core.statement.PreparedBatch.execute(PreparedBatch.java:67)
at org.trellisldp.ext.db.DBResourceService.lambda$null$33(DBResourceService.java:206)
at java.util.Optional.ifPresent(Optional.java:159)
at org.trellisldp.ext.db.DBResourceService.lambda$null$34(DBResourceService.java:196)
at org.jdbi.v3.core.HandleConsumer.lambda$asCallback$0(HandleConsumer.java:32)
at org.jdbi.v3.core.Jdbi.withHandle(Jdbi.java:341)
at org.jdbi.v3.core.Jdbi.useHandle(Jdbi.java:357)
at org.trellisldp.ext.db.DBResourceService.lambda$add$35(DBResourceService.java:196)
... 2 more

Not surprisingly I got 500 internal server error back at the client. So, obviously the NPE needs to be addressed at some point. It was an unauthenticated call POSTing:

@prefix ldp: <http://www.w3.org/ns/ldp#> .
@prefix dcterms: <http://purl.org/dc/terms/> .
 
<> a ldp:Container, ldp:BasicContainer;
   dcterms:title "Photos of Alice" ;
   dcterms:description "This container will contain photos of Alice." .

I was surprised, though, that I got a 409 Conflict response when I resubmitted the call. I would think that the whole transaction ought to be rolled back OR that audit log failures ought to be non-fatal.



Aaron Coburn

unread,
Dec 10, 2019, 1:48:02 PM12/10/19
to trell...@googlegroups.com
I assume that this error was related to working with Trellis in the context of AWS-lambda. You would want to verify that a functional audit subsystem is getting correctly injected into the runtime.

As for transactional boundaries, that's a hard one. Not all Trellis back-ends even have a notion of transaction, so "roll-back" isn't something that can be defined in a generic sense. And wearing my DevSecOps hat, I'd say that not everyone would agree that audit log failures should be non-fatal. As for how to recover from this, though, just issue a DELETE on the problematic resource; alternatively, send a PUT request.

Aaron

--
You received this message because you are subscribed to the Google Groups "Trellis LDP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trellis-ldp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/trellis-ldp/9ec5d37b-c3c9-4a7f-85e3-67ae60731c0a%40googlegroups.com.

Andrew McConnell

unread,
Dec 12, 2019, 4:48:39 PM12/12/19
to Trellis LDP
Just to close this issue out and maybe help someone in the future, the audit errors (which manifested themselves in a couple of ways including an NPE and more usefully:

Caused by: org.jdbi.v3.core.statement.UnableToCreateStatementException: Missing positional param at (0 based) position 0 [statement:"INSERT INTO log (id, subject, predicate, object, lang, datatype) VALUES (?, ?, ?, ?, ?, ?)", arguments:{positional:{5:NULL}, named:{}, finder:[]}]

I resolved them by correcting an AWS permission issue with writing the events to SNS. Once the SNS publish worked correctly, the audit errors disappeared.

Aaron Coburn

unread,
Dec 13, 2019, 8:32:32 AM12/13/19
to trell...@googlegroups.com
Thanks for following up on this. I know the Trellis documentation doesn't currently have much to say about setting up the code to work with Lambda or with these AWS services, generally. So if you have ideas for adding specific text to the documentation (either the README.md files in the various code repositories or on the Github wiki), please do let me know.

Cheers,
Aaron 

--
You received this message because you are subscribed to the Google Groups "Trellis LDP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trellis-ldp...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages