Manage persistence service history

6 posts / 0 new
Last post
Offline
Last seen: 2 months 2 weeks ago
Joined: 09/10/2022
Posts: 21
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: 5 hours 47 min ago
Joined: 11/29/2012
Posts: 588

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: 2 months 2 weeks ago
Joined: 09/10/2022
Posts: 21
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: 5 hours 47 min ago
Joined: 11/29/2012
Posts: 588

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: 2 months 2 weeks ago
Joined: 09/10/2022
Posts: 21

Thanks for your help.

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

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