in reply to Re: Is "die" the best way to be atomic?
in thread Is "die" the best way to be atomic?

Firstly, I am glad someone saw threough my poorly worded question what I meant - I _am_ looking for your definition of atomic - "do it, or don't do it - don't go halfway..." Well the two main places of concern are the permissions script and the rsync - if something goes wrong with either it could be a BadThing(tm).

I like your idea of the undo() function, but am not sure it would be feasible in either case, meaning I am not sure if there would be a way to actually undo what had occurred. One way I might be able to cover myself on the rsync is to first run the rsync with the --dry-run option, and as long as all goes well run it without. Is there any kind of "dry run" in perl? Does eval or try work in that way - in that it tries to do it, but doesn't actually do it unless it is sucessful?

-Shane

Replies are listed 'Best First'.
Re: Re: Re: Is "die" the best way to be atomic?
by castaway (Parson) on Apr 27, 2004 at 17:00 UTC
    Not really, no. At least, there appear to be a few modules for doing transactional perl code, eg WhatIf and Transaction, but these are not likely to be able to rollback system calls. So you'll need to know how to do that yourself.

    Seeing as the permissions call appears to be to a script you wrote yourself, (if I read the post correctly), then surely you know what that does internally, and how to roll it back? You might even make it take some sort of parameter, which makes it rollback itself.

    As to the rsync, there are also some Rsync modules, but whether any support rollback/transactions I couldnt see. (I would have thought any decent backup mechanism would be atomic somehow)

    C.