Double the size

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Double the size

Brian Murphy-Dye-2
The following code snippet shows a size of 10, but #do: processes  
those 10 items twice. Any ideas what I'm doing wrong?

m := MagmaCollection new.
1 to: 10 do: [:each | m add: each].
Transcript show: String cr, 'size: ', m size asString, String cr.
m do: [:each | Transcript show: each asString, String cr].

Brian.
Reply | Threaded
Open this post in threaded view
|

Magma1.0-cmm.4 (was: Double the size)

Chris Muller
Hm, you definitely found a bug.  Enumerating a
non-persistent MagmaCollection (as opposed to a
Reader) is very rare, so I'm not surprised no one
noticed this.

I have now posted Magma1.0-cmm.4 on SqueakSource which
fixes this bug.  A quick fix, but the test cases
passed.

Thank you, Brian, for pointing it out and also for
providing such an easy way to reproduce it.  Easily
reproduced = easily fixed!

 - Chris

PS - Your e-mail was rejected by the list, I had to
manually approve it.  I hope you will join us on the
Magma list.


--- Brian Murphy-Dye <[hidden email]> wrote:

> The following code snippet shows a size of 10, but
> #do: processes
> those 10 items twice. Any ideas what I'm doing
> wrong?
>
> m := MagmaCollection new.
> 1 to: 10 do: [:each | m add: each].
> Transcript show: String cr, 'size: ', m size
> asString, String cr.
> m do: [:each | Transcript show: each asString,
> String cr].
>
> Brian.
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Magma1.0-cmm.4 (was: Double the size)

Brian Murphy-Dye-5
Chris,

Thanks for the speedy response!

I have a new problem, surely due to some less-than-bight act on my  
part. I am using Cees' Kilauea magma-server image download, and have  
Magma 1.0 loaded in my working image.

I wasn't able to load Magma-seaside-mmb.2.mcz, so I'm creating the  
session on my own in the #initialize method of the top component,  
beginning a transaction right off the bat, and doing a 'session  
commit; begin' when the user clicks 'Save'. So I'm always in an open  
transaction -- the last of which never gets closed. I'm sure this  
isn't the right way to do this, but couldn't think of a better way.  
I've added data to the repository using this method all day, but  
still guess this may have something to do with my problem. Just  
before things went south, I had been breaking, er, modifying my  
Seaside components, and had started quite a few new sessions.

Now upon startup, the server produces an 'Error: a primitive has  
failed' error while (I think) reading a MaHashIndexRecord. Looking at  
http://localhost:21000/, all the repositories are shutting down. I've  
tried abandoning, and doing 'MagmaSession cleanUp', and then saving  
as a new version, but get an error (in  
MagmaCollectionManager>>collectionOid, respository session is nil).

Any ideas on getting going again? I really only have one repository I  
care about, and don't need the MagmaCollection, as I can recreate it  
from the other data in the repository.

Brian.

P.S. I had joined the mailing list, but sent from the wrong account  
(not the first time I've made that mistake :)


On Feb 23, 2006, at 11:45 PM, Chris Muller wrote:

> Hm, you definitely found a bug.  Enumerating a
> non-persistent MagmaCollection (as opposed to a
> Reader) is very rare, so I'm not surprised no one
> noticed this.
>
> I have now posted Magma1.0-cmm.4 on SqueakSource which
> fixes this bug.  A quick fix, but the test cases
> passed.
>
> Thank you, Brian, for pointing it out and also for
> providing such an easy way to reproduce it.  Easily
> reproduced = easily fixed!
>
>  - Chris
>
> PS - Your e-mail was rejected by the list, I had to
> manually approve it.  I hope you will join us on the
> Magma list.
>
>
> --- Brian Murphy-Dye <[hidden email]> wrote:
>
>> The following code snippet shows a size of 10, but
>> #do: processes
>> those 10 items twice. Any ideas what I'm doing
>> wrong?
>>
>> m := MagmaCollection new.
>> 1 to: 10 do: [:each | m add: each].
>> Transcript show: String cr, 'size: ', m size
>> asString, String cr.
>> m do: [:each | Transcript show: each asString,
>> String cr].
>>
>> Brian.
>>
>>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Magma1.0-cmm.4 (was: Double the size)

Chris Muller

> I wasn't able to load Magma-seaside-mmb.2.mcz, so
> I'm creating the
> session on my own in the #initialize method of the
> top component,
> beginning a transaction right off the bat, and doing
> a 'session
> commit; begin' when the user clicks 'Save'. So I'm
> always in an open
> transaction -- the last of which never gets closed.

Use commitAndBegin, a bit faster because it does the
commit and gives you a new transaction in a single
call to the server.

> Now upon startup, the server produces an 'Error: a
> primitive has
> failed' error while (I think) reading a
> MaHashIndexRecord. Looking at
> http://localhost:21000/, all the repositories are
> shutting down. I've
> tried abandoning, and doing 'MagmaSession cleanUp',
> and then saving
> as a new version, but get an error (in
> MagmaCollectionManager>>collectionOid, respository
> session is nil).
>
> Any ideas on getting going again? I really only have
> one repository I
> care about, and don't need the MagmaCollection, as I
> can recreate it
> from the other data in the repository.

Were you doing a local or remote repository?  It
sounds like the underlying files are closed but the
repository is still trying to access them.  The image
shutDown/startUp code closes/opens the repository,
disconnects/reconnects all sessions, so something got
out of sync.

Try

  MagmaSession initialize.
  MagmaRepositoryController initialize.

and should clear out Magma's startUp/shutDown lists
that should then allow saving of the image.  You
should be able to reopen them and continue working.

Beyond that, a stack trace would be most helpful.

 - Chris