PreconditionNotMetError while waiting for waitset

3 posts / 0 new
Last post
Offline
Last seen: 3 years 9 months ago
Joined: 03/12/2018
Posts: 32
PreconditionNotMetError while waiting for waitset

I keep getting a PreconditionNotMet exception when I dispatch() a waitset.  When I try to handle the exception and print out its details with an "e.what()", I get "Invalid data".

I do this in a loop, and immediately try the dispatch again, and it works the next time.

I'm basically doing this:

While (1)
   try {
        waitSet.dispatch();
   }
   catch (dds::core::PreconditionNotMetError &e) {
      // print something so my program doesn't die
   }
}

As I mentioned, this is intermittent. 

Can someone please tell me why this might be happening intermittently (as opposed to consistently, which would be a different problem)? 

 

Offline
Last seen: 3 years 9 months ago
Joined: 03/12/2018
Posts: 32

I've noticed that this seems to happen only when my writer process dies.  

So, we have a reader thread spinning forever in a loop, and a writer process coming and going as testing demands.  It seems that when it goes away, the reader gets an exception in its reader condition dispatch().

Is this expected behavior?  Is it preventable?

In fact, I think I'm going to have a problem with exceptions altogether, since I believe they are not compatible with my target environment's safety  requirements.  Any tips on turning exceptions off?

 

 

 

Offline
Last seen: 3 months 5 days ago
Joined: 02/11/2016
Posts: 144

Hey,

When a writer "dies", the reader detects that and notifies the application of the change.
A part of this notification process means that instances which no longer have living writer, are considered "dead" (this is, their status is changed to "not_alive_no_writers".
I can only guess that in its underlying implementation, dispatch uses a LoanableSequence which (as pointed out in the documentation: https://community.rti.com/static/documentation/connext-dds/5.2.3/doc/api/connext_dds/api_cpp2/classrti_1_1sub_1_1LoanedSample.html) may throw PreconditionNotMetError in some cases (when converting the sequence or when trying to get the data from it).
It is not impossible that another class is throwing the exception, but I'm guessing the reason is the same: invalid data is being received by someone listening for data, it is somehow not handled in the best way and that ends up throwing an exception.
To find out about LoanableSequences throwing this exception I googled: "rti dds PreconditionNotMetError Invalid data"

Good luck,
Roy.