Manage persistence service history

12 posts / 0 new
Last post
Offline
Last seen: 1 day 23 hours ago
Joined: 09/10/2022
Posts: 34
Manage persistence service history

I am using rti dds version 6.0.0

How can I delete an instance from persistence services history?

I know if I dispose instance with data writer that published last sample, it will delete from persistence history if it was in keep_history_last. But I want delete last sample from persistence services history after reboot computer, when I create new data writers and data readers

Howard's picture
Offline
Last seen: 22 hours 47 min ago
Joined: 11/29/2012
Posts: 618

The Persistence Service must receive a Disposed sample for the instance to remove the history of the instance from persistence storage.

So, you pretty much have to call Dispose on a DataWriter for the instance that you want to dispose.  So, when you create the new DataWriter, you need to call dispose() with the instance that you are disposing.  If that isn't working, you may need to first send a dummy sample with the new DataWriter and then call dispose().

Finally, if there is a reasonable lifespan for a sample, you can use the Lifespan QoS to have Persistence Service automatically remove expired samples.

 

Offline
Last seen: 1 day 23 hours ago
Joined: 09/10/2022
Posts: 34
Thank you for your response. I found that only datawriter that sent the last sample of instance, can dispose instance and remove instance from persistences history, other datawriters can not remove sample from persistences history. And persistence stores and recognizes datawriters by their virtual_guid (a 16 length array of uint8_t), so I made a solution for my self. I make a unique virtual_guid for my durable datawriters automatically, so they can dispose any samples that they sent and remove it from persistences history. When I close my program and start it again or I restart the computer I generate that virtual_guid again in a logical way that gives the same virtual_guid. I just need to create a unique virtual_guid for durable datawriters.
Howard's picture
Offline
Last seen: 22 hours 47 min ago
Joined: 11/29/2012
Posts: 618

Yes, that's why I suggest that you have your datawriter app send a "dummy" sample before calling dispose()...so that it will be the datawriter that sent the last sample for the instance.  But your way can also work...the issue is if you are using a virtual GUID, your seq no must be > than the last seq no sent using the virtual GUID...or else the sample will be dropped as an old sample.

Offline
Last seen: 1 day 23 hours ago
Joined: 09/10/2022
Posts: 34

Thanks for your help.

Howard's picture
Offline
Last seen: 22 hours 47 min ago
Joined: 11/29/2012
Posts: 618

Oh, something that might work without you having to send a dummy data sample for an instance that a new writer wants to dispose...you can try setting this QoS:

 <datawriter_qos>                
     <protocol>
         <serialize_key_with_dispose>
              true <!-- allow dispose of an unwritten instance -->
         </serialize_key_with_dispose>
     </protocol>

The documentation is here:

https://community.rti.com/static/documentation/connext-dds/7.3.0/doc/api/connext_dds/api_cpp/structDDS__DataWriterProtocolQosPolicy.html#a7d8c1e77cbcf49d4b993d2e567c6468a

Offline
Last seen: 1 day 23 hours ago
Joined: 09/10/2022
Posts: 34
Thanks, I will test it.
Offline
Last seen: 1 day 23 hours ago
Joined: 09/10/2022
Posts: 34
Unfortunately it just works for keyed topics. What can I do if topic was none keyed? How can I dispose it with dataWriter that is not owner?
Howard's picture
Offline
Last seen: 22 hours 47 min ago
Joined: 11/29/2012
Posts: 618

Dispose is only defined with respect to instances and thus keyed topics.  What is your use case such that you want to dispose a non-keyed topic?

Offline
Last seen: 1 day 23 hours ago
Joined: 09/10/2022
Posts: 34
I want to delete one or any sample that saved in persistance service's history, without writing any dummy sample. I don't want that data readers receive any dummy sample when I remove samples from persistance service. Now I do this: I add a boolean field in topic like "deletedInstance" with "false" default value And I filtered "deletedInstance" in all datareaders by this filter = "deletedInstance=False". When I want to remove one Instance, I write the instance with "deletedInstance=True". Then no dataReader will receive this sample and it's like removing from persistence service, because it will fill persistence services history. But it would be better that I can manage persistence services history without this difficulties. This is not the real soloution.
Howard's picture
Offline
Last seen: 22 hours 47 min ago
Joined: 11/29/2012
Posts: 618

Sorry to say, that for non-keyed topics, there is no way to command or otherwise stimulate the Persistence Service to drop data for the non-keyed topic in its cache (aka history queue).

The only way that data is removed from the history queue is if

1) it's overwritten by new data with a finite history, the queue is used as a round robin queue

or

2) DataWriters sending the data are confgured with LifeSpan QoS such that the data has a limited lifetime after sending.  Persistence Service will remove the data once its lifespan has expired.

https://community.rti.com/static/documentation/connext-dds/current/doc/api/connext_dds/api_cpp/structDDS__LifespanQosPolicy.html

 

 

Offline
Last seen: 1 day 23 hours ago
Joined: 09/10/2022
Posts: 34
Thank you for your responsibilty in answering questions.