Book a Demo

Author Topic: Is EA.Repository thread-safe?  (Read 4572 times)

Jim Beck

  • EA User
  • **
  • Posts: 29
  • Karma: +0/-0
    • View Profile
Is EA.Repository thread-safe?
« on: March 11, 2011, 10:48:55 am »
Hello.  I have recently tried to alleviate some aggravation for our users by doing some rather lengthy READ ONLY model elaboration using EA.Repository in a C# BackgroundWorker thread.  This is merely to allow users to cancel, but soon i will be having several readers of the repository.  There has been an occasional funny behavior, so I'm wondering if the repository is thread safe when reading only.  (My guess is yes, that it is deisgned this way as mostly a database front end, but you never know.)

Thanks!

Jim
« Last Edit: March 11, 2011, 10:49:11 am by jimbeck »

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Is EA.Repository thread-safe?
« Reply #1 on: March 11, 2011, 07:05:59 pm »
Jim,

I suspect the same, but I can't be 100% sure. Have you asked sparx support?

Geert

Jim Beck

  • EA User
  • **
  • Posts: 29
  • Karma: +0/-0
    • View Profile
Re: Is EA.Repository thread-safe?
« Reply #2 on: March 12, 2011, 05:18:32 am »
Hi Geert.  Indeed I did, I asked them this:

Hello.  I get a call-back in our add-in that has an EA.Repository object as an input argument.  There are a few scenarios that I have questions about:
 
1.       If I use the EA.Repository object in a different thread, and don’t return from the callback until the thread is done, then this must be ok, right?  (It is as if I use it only in the callback then.)
2.       If I use it in several threads, and still don’t return until they are done, is that ok too?  (Are simultaneous reads a  problem?)
3.       If I return from the callback and still use the EA.Repository object, then I can see that this might cause problems, right?  (Is the object now invalid?)
4.       So far I am only reading using the EA.Repository object, not changing anything.  Do any of the answers change if I am actually writing using it, i.e. changing the repository?  (Are simultaneous reads and writes allowed?)
 
Thanks (presumably Simon)!


When I get a reply, I'll let you guys know!

Jim

Jim Beck

  • EA User
  • **
  • Posts: 29
  • Karma: +0/-0
    • View Profile
Re: Is EA.Repository thread-safe?
« Reply #3 on: March 17, 2011, 04:54:38 am »
Answer I got from support was this:

Hello Jim,
Any situation where the repository object is used concurrently is likely to fail.
1) Generally this should be safe, although we have seen issues where the COM object couldn't be called from a different thread.
2) Will fail.
3) If you are operating concurrently with other EA operations it will fail.
4) No, it will still fail.

This is somewhat unfortunate in my opinion.  Most modern interface designs support concurrency.  I understand why it is not this way historically.  We wish that it was thread safe because the COM interface takes quite some time when models are even moderately large (even as low as 50 or so classes to completely get the information from them takes many minutes), and our so our users want to do things in the background while this is going on.

I am starting to look into SQL queries in lieu of using the COM interface per Geert's suggestion a while ago.  Meanwhile I am going with tehcnique number 1 up there and will not try 2 through 4.  My number one complaint about EA, besides the obscure user interface (will be trying beta 9 soon!) is the time it takes to get information from the repository.

It seems like the COM inteface has some really inefficient data structures or something.  (For example I ran a profiler once and getting connections takes around 8 times compared to other operations.)  I don't have any numbers for you, but it seems like exporting a huge model to XMI takes a lot less time than using the COM interface.  Maybe adding interpretting the XMI on top of that will still be quite less than using the COM interface.  This basically amounts to making our own interface.

EA does a lot of things for a little bit of money, but this is tough when you add on top that we don't trust version control or differencing (you should not need a best practices white paper, it should be in the manual and be very clear - Rose RT had a beautiful version control interface.  Artisan studio's is incredible with visual differencing of diagrams).  I do respect the amount of work that has gone into it, but I need some ways around these items if our (huge) company as a whole is going to use this and not just our 5-man group of die hard modeling people.

Jim Beck

  • EA User
  • **
  • Posts: 29
  • Karma: +0/-0
    • View Profile
Re: Is EA.Repository thread-safe?
« Reply #4 on: March 17, 2011, 05:00:11 am »
One more comment.  The fact that you cannot have simultaneous reads seems incredible (I could be naive).  Is there static data being used in the COM interface support?  I know nothing about databases, but I cannot imagine that they are not thread-safe (even reading and writing).  I understand that if we were to change the model underneath readers then that would be our own problem, but simultaneous reads should work.  That is unless something evil is done in the COM interface on top of the database.  I'm not sure I believe the response yet.