skdb icon indicating copy to clipboard operation
skdb copied to clipboard

Fix: propagate updates when in a transaction

Open gregsexton opened this issue 1 year ago • 2 comments

I noticed that if tailing a reactive view built on a table I:

  • do an insert in to the source table, the tail outputs the update instantly

  • do the same insert wrapped in a transaction, it does not update until the condvar times out

Digging in, this seems to be because the context isn't update()d and so the changed dir names do not include the view, so notify never triggers the condvar.

gregsexton avatar May 17 '24 15:05 gregsexton

I figure this is the right fix rather than updating at the end. It makes sense that within a txn you would be able to read the effect of a write on downstream views after it has happened.

gregsexton avatar May 17 '24 15:05 gregsexton

I agree with the fix. Maybe it might be worth adding a mechanism to make sure the update was called whenever the context was modified?

If we tripped over it here, there might be other places like that.

pikatchu avatar May 18 '24 07:05 pikatchu

might be worth adding a mechanism to make sure the update was called whenever the context was modified?

Already on my todo list. This isn't the first time we've been bitten. Are there any situations you can think of where we don't automatically want to update though?

gregsexton avatar May 20 '24 09:05 gregsexton

local sequence number test failure looks legitimate, though -- I guess that logic relies on the context not updating within a transaction.

Yeah was relying on the gen sym counter. Now that we call update it will be bumped. I just updated the test expectation so tests should pass now.

gregsexton avatar May 20 '24 11:05 gregsexton