<div dir="auto">Yeah I figured that would cause more problems than it would solve but still glad I asked. I might rewrite my import like you said. It is a better way of doing things.<div dir="auto"><br></div><div dir="auto">Thanks! </div></div><br><div class="gmail_quote"><div dir="ltr">On Sun, Feb 3, 2019, 3:14 PM Adam Chlipala <<a href="mailto:adamc@csail.mit.edu">adamc@csail.mit.edu</a> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 2/3/19 7:54 AM, Simon Van Casteren wrote:<br>
> About your first comment,<br>
><br>
> Yes I have the same code habit of first running validations and then <br>
> doing the actual work. As long as stuff stays kind of simple that is <br>
> manageable. But a place where this has caused some serious bugs was in <br>
> my import page. So I have a function that runs validations and then <br>
> makes the resource in the database. Now, my import page makes many of <br>
> these at once, based on a CSV file format (see one of my previous <br>
> questions). However when one fails, I'd like the whole import to fail. <br>
> A complete rollback operation would make this much easier and less <br>
> error-prone since I now have to delete all the previous saved resource <br>
> when one resource fails to save. It was more of a question on how to <br>
> do it though, since providing an explicit rollback is probably more <br>
> dangerous than it's worth.<br>
<br>
Right.  This part sounds doable by splitting your import functionality <br>
into separate validation and database insertion.  It sounds like a small <br>
drag, but at least it only locally affects your use case.<br>
<br>
One example of a pain arising from general database rollback is: imagine <br>
a nicely encapsulated function that allocates a message-passing channel, <br>
stashes it in an appropriate database table, and returns it to the <br>
caller (perhaps declared as an abstract type, so the caller doesn't even <br>
know a channel is involved).  The caller uses the rollback function you <br>
asked for, but the caller also hangs onto and uses the channel.  Now we <br>
have a scary ability to break application-wide invariants: rollback is, <br>
in effect, a way to mess with "private fields" of library modules!<br>
<br>
<br>
_______________________________________________<br>
Ur mailing list<br>
<a href="mailto:Ur@impredicative.com" target="_blank" rel="noreferrer">Ur@impredicative.com</a><br>
<a href="http://www.impredicative.com/cgi-bin/mailman/listinfo/ur" rel="noreferrer noreferrer" target="_blank">http://www.impredicative.com/cgi-bin/mailman/listinfo/ur</a><br>
</blockquote></div>