[odb-users] Problem with session cache and weak_ptr

Marcel Nehring mne at qosmotec.com
Mon Apr 25 04:21:44 EDT 2016


Hi,

I think I discovered a problem with ODB's object loading mechanism in conjunction with weak_ptr.
I am using a custom session implementation so that my session's cache behaves a bit different from ODB's.
Therefore it might happen, that I have an object in my cache that references another object via a weak_ptr member. If the pointee goes out of scope so that the weak_ptr expires I run into problems when loading the pointing object.
The pointing object is still in my cache, so ODB correctly gets the instance from there. I then see, that ODB asks the cache for the (already expired) pointee. The cache cannot provide it, so I see ODB inserting it into the cache. After loading finishes, however, the weak_ptr member is still empty. Both objects correctly exist in my cache but the link is missing/invalid. Looks like ODB does not (re)set the weak_ptr to the newly loaded instance.

Any thoughts on this?

Regards,
Marcel


More information about the odb-users mailing list