I accidentally have code like
ReadYourWritesTransaction tr(cx); // cx is the Database object state Reference<ReadYourWritesTransaction> trReference = Reference<ReadYourWritesTransaction>::addRef(&tr); // .... wait(delay(1)); // The lifetime of tr ends here // .... trReference->get(...); // Error since the transaction object has been deleted.
Not sure if this is okay. I searched in the codebase, there is no existing use case like this and nearly all of
ReadYourWritesTransaction are declared with
state, which makes the scenario that a reference lives longer than the ryw object is much less likely to happen.
However, since ReadYourWritesTransaction is ReferenceCounted, if there is an existing Reference points to it, by intuition, it should not be deleted.