[squeak-dev] Why is ModificationForbidden not an Error?

Eliot Miranda eliot.miranda at gmail.com
Fri Apr 24 01:48:12 UTC 2020



> On Apr 23, 2020, at 5:55 PM, Chris Muller <asqueaker at gmail.com> wrote:
> 
> 
> Hi Eliot,
> 
> Thanks for your patience with our questions while we get up to speed understanding how to use this new feature.
>  
>>> It's a super-low-level error that ought to be handled really really closely to where the error was raised. As Eliot mentioned, the VM can't know the circumstances and just raises it; the the closest possible handler should be in place that *does* know the circumstances. That way Chris gets to spot that is it a database issue and handle things properly, including likely raising a new error for higher level code.
>> 
>> As I've already mentioned what one can do, and the VisualWorks version does do, for GemStone-style persistence, as add behavior to the exception so one can specify a per-object response.
>> 
>> So if the exception is unhandled, then before it raises an UnhandledError it checks an identity dictionary, which maps object to message, and if the read-only object that was the cause of the error is in the dictionary, instead the exception performs the message with the object as an argument.  So a database layer can add the objects it is managing to the map in ModificationForbidden, and mark them as read-only.  Then any and all attempts at modifying these objects will cause the database man ager to be notified. 
>>  So very simply we can have a pluggable solution that allows different clients to map the exception into different responses as desired. 
> 
> But an object in your db table could easily be an Array literal held by a CompiledMethod, not expected to change, but persistent by reference nonetheless.  So if the application did then modify it accidentally, instead of Forbidden protection, your DB manager would happily modify it.  It's this separation of use-cases is all what the question was about I think, not a big deal, we've lived with unprotected CM literals for this long already, and I've never needed WriteBarrier for anything other than a DB.

Since objects get added to the collection intentionally the array literal would not be added and hence the manager would not modify it.  Your example is a straw man.

> 
> However, I still don't see the path for how to use this in a complex multi-db Magma application with oblivious objects (e.g., Morphs).  It's not something any of the GemStone clients I consulted at as developer or DBA ever had to contend with either, but perhaps not something you're targeting.  Squeak is a different animal...  I will stay tuned here and watch for the answers as they unfold...

The objects that get added to the wrote barrier management collection get added by managers that want to manage specific objects, not arbitrary objects. Can you see that a DB manager would add objects it has materialized from the DB that it wanted to transparently write-back in modification, and no others?

> 
>  - Chris
>  
>> So can we please stop wasting time discussing this and get on with implementing it?  The GemStone folks have understood how to manage ModificationForbidden for years and the use of it has been in production.  We simply need to catch up.  We're nearly there.   
>>  
>> 
>> Please don't make me explain this idea once again ;-)
>> 
>> >
>> >
>> > Given having a handler really close to the source, perhaps we are better off keeping it non-resumable and using one of the other approaches to continuing like #retryUsing: (ExceptionTester>>#simpleRetryUsingTest is the only example in the clean image) ? 
>>> 
>>> 
>>> tim
>>> --
>>> tim Rowledge; tim at rowledge.org; http://www.rowledge.org/tim
>>> Strange OpCodes: BFM: Branch on Full Moon
>>> 
>>> 
>>> 
>> 
>> 
>> -- 
>> _,,,^..^,,,_
>> best, Eliot
>> 
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20200423/f23319a7/attachment.html>


More information about the Squeak-dev mailing list