cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Álvaro Martínez <alvaro_marti...@ptbsl.com>
Subject Re: Selective commit
Date Tue, 08 Jan 2008 15:16:00 GMT
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<br>
<br>
I get the same deadlock with 3.0M2 &nbsp; :-(<br>
<br>
<small><br>
<br>
Name: Timer-4<br>
State: BLOCKED on org.apache.cayenne.access.ObjectStore@c9f698 owned
by: Timer-0<br>
Total blocked: 13&nbsp; Total waited: 778<br>
<br>
Stack trace: <br>
org.apache.cayenne.access.DataContextMergeHandler.graphChanged(DataContextMergeHandler.java:99)<br>
sun.reflect.GeneratedMethodAccessor108.invoke(Unknown Source)<br>
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)<br>
java.lang.reflect.Method.invoke(Method.java:597)<br>
org.apache.cayenne.util.Invocation.fire(Invocation.java:204)<br>
org.apache.cayenne.event.EventManager$Dispatch.fire(EventManager.java:397)<br>
org.apache.cayenne.event.DispatchQueue.dispatchEvent(DispatchQueue.java:162)<br>
org.apache.cayenne.event.DispatchQueue.dispatchEvent(DispatchQueue.java:58)<br>
&nbsp;&nbsp; - locked org.apache.cayenne.event.DispatchQueue@15c80d8<br>
org.apache.cayenne.event.EventManager.dispatchEvent(EventManager.java:336)<br>
org.apache.cayenne.event.EventManager.postEvent(EventManager.java:307)<br>
org.apache.cayenne.access.DataContext.fireDataChannelChanged(DataContext.java:1704)<br>
org.apache.cayenne.access.DataContext.onContextFlush(DataContext.java:1189)<br>
org.apache.cayenne.access.DataContext.onSync(DataContext.java:1167)<br>
org.apache.cayenne.access.DataContext.flushToParent(DataContext.java:1234)<br>
&nbsp;&nbsp; - locked org.apache.cayenne.access.ObjectStore@b92a34<br>
org.apache.cayenne.access.DataContext.commitChanges(DataContext.java:1138)<br>
com.ptb.commons.db.services.StatsServices.addForClient(StatsServices.java:42)<br>
com.ptb.backendnode.tasks.DataMgrStatsCalculation.run(DataMgrStatsCalculation.java:78)<br>
java.util.TimerThread.mainLoop(Timer.java:512)<br>
java.util.TimerThread.run(Timer.java:462)<br>
<br>
<br>
<br>
<br>
Name: Timer-0<br>
State: BLOCKED on org.apache.cayenne.event.DispatchQueue@15c80d8 owned
by: Timer-4<br>
Total blocked: 5&nbsp; Total waited: 22<br>
<br>
Stack trace: <br>
org.apache.cayenne.event.DispatchQueue.dispatchEvent(DispatchQueue.java:54)<br>
org.apache.cayenne.event.EventManager.dispatchEvent(EventManager.java:336)<br>
org.apache.cayenne.event.EventManager.postEvent(EventManager.java:307)<br>
org.apache.cayenne.access.DataContext.fireDataChannelChanged(DataContext.java:1704)<br>
org.apache.cayenne.access.DataContext.onContextFlush(DataContext.java:1189)<br>
org.apache.cayenne.access.DataContext.onSync(DataContext.java:1167)<br>
org.apache.cayenne.access.DataContext.flushToParent(DataContext.java:1234)<br>
&nbsp;&nbsp; - locked org.apache.cayenne.access.ObjectStore@c9f698<br>
org.apache.cayenne.access.DataContext.commitChanges(DataContext.java:1138)<br>
com.ptb.confignode.ConfigNode.newConfigGenerated(ConfigNode.java:711)<br>
&nbsp;&nbsp; - locked java.lang.Boolean@5f6d5a<br>
com.ptb.confignode.tasks.GenerateNewDistribution.run(GenerateNewDistribution.java:162)<br>
java.util.TimerThread.mainLoop(Timer.java:512)<br>
java.util.TimerThread.run(Timer.java:462)<br>
<br>
</small><br>
<br>
Andrus Adamchik escribi&oacute;:
<blockquote
 cite="mid:B4B17649-DC7C-4EF4-B507-433735274ED1@objectstyle.org"
 type="cite">Could you also try it with 3.0M2? I wonder if there is a
difference, before I start looking into that.
  <br>
  <br>
Thanks
  <br>
Andrus
  <br>
  <br>
  <br>
  <br>
On Jan 8, 2008, at 4:11 PM, &Aacute;lvaro Mart&iacute;nez wrote:
  <br>
  <blockquote type="cite"><br>
Of course, sorry, 2.0.4
    <br>
    <br>
    <br>
    <br>
Andrus Adamchik escribi&oacute;:
    <br>
    <blockquote type="cite">Could you confirm the exact version of
Cayenne you are using?
      <br>
      <br>
Thanks,
      <br>
Andrus
      <br>
      <br>
On Jan 8, 2008, at 4:05 PM, &Aacute;lvaro Mart&iacute;nez wrote:
      <br>
      <br>
      <blockquote type="cite"><br>
Hi, I'm running some issues on this one.
        <br>
        <br>
I now create a new child data context on every situation. But I'm
always getting the same deadlock. I can't figure out how to fix this
from my own code.
        <br>
        <br>
I've googled other people who also had a similar problem, but didn't
help.
        <br>
        <br>
This is the explanation from jConsole:
        <br>
        <br>
        <br>
        <br>
        <br>
        <br>
Name: Timer-0
        <br>
State: BLOCKED on org.apache.cayenne.event.DispatchQueue@c25268 owned
by: Timer-4
        <br>
Total blocked: 3&nbsp; Total waited: 68
        <br>
        <br>
Stack trace:
        <br>
org.apache.cayenne.event.DispatchQueue.dispatchEvent(DispatchQueue.java:54)
        <br>
org.apache.cayenne.event.EventManager.dispatchEvent(EventManager.java:336)
        <br>
org.apache.cayenne.event.EventManager.postEvent(EventManager.java:307)
        <br>
org.apache.cayenne.access.DataContext.fireDataChannelChanged(DataContext.java:1704)
        <br>
org.apache.cayenne.access.DataContextMergeHandler.graphFlushed(DataContextMergeHandler.java:114)
        <br>
sun.reflect.GeneratedMethodAccessor65.invoke(Unknown Source)
        <br>
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        <br>
java.lang.reflect.Method.invoke(Method.java:597)
        <br>
org.apache.cayenne.util.Invocation.fire(Invocation.java:204)
        <br>
org.apache.cayenne.event.EventManager$Dispatch.fire(EventManager.java:397)
        <br>
org.apache.cayenne.event.DispatchQueue.dispatchEvent(DispatchQueue.java:162)
        <br>
org.apache.cayenne.event.DispatchQueue.dispatchEvent(DispatchQueue.java:58)
        <br>
&nbsp; - locked org.apache.cayenne.event.DispatchQueue@12d553e
        <br>
org.apache.cayenne.event.EventManager.dispatchEvent(EventManager.java:336)
        <br>
org.apache.cayenne.event.EventManager.postEvent(EventManager.java:307)
        <br>
org.apache.cayenne.access.DataContext.fireDataChannelCommitted(DataContext.java:1680)
        <br>
org.apache.cayenne.access.DataContext.flushToParent(DataContext.java:1247)
        <br>
&nbsp; - locked org.apache.cayenne.access.ObjectStore@137958b
        <br>
org.apache.cayenne.access.DataContext.onContextFlush(DataContext.java:1192)
        <br>
org.apache.cayenne.access.DataContext.onSync(DataContext.java:1167)
        <br>
org.apache.cayenne.access.DataContext.flushToParent(DataContext.java:1234)
        <br>
&nbsp; - locked org.apache.cayenne.access.ObjectStore@1b3a10d
        <br>
org.apache.cayenne.access.DataContext.commitChanges(DataContext.java:1138)
        <br>
com.ptb.confignode.ConfigNode.newConfigGenerated(ConfigNode.java:711)
        <br>
&nbsp; - locked java.lang.Boolean@3b13c5
        <br>
com.ptb.confignode.tasks.GenerateNewDistribution.run(GenerateNewDistribution.java:162)
        <br>
java.util.TimerThread.mainLoop(Timer.java:512)
        <br>
java.util.TimerThread.run(Timer.java:462)
        <br>
        <br>
        <br>
        <br>
        <br>
Name: Timer-4
        <br>
State: BLOCKED on org.apache.cayenne.access.ObjectStore@1b3a10d owned
by: Timer-0
        <br>
Total blocked: 20&nbsp; Total waited: 799
        <br>
        <br>
Stack trace:
        <br>
org.apache.cayenne.access.DataContextMergeHandler.graphChanged(DataContextMergeHandler.java:99)
        <br>
sun.reflect.GeneratedMethodAccessor69.invoke(Unknown Source)
        <br>
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        <br>
java.lang.reflect.Method.invoke(Method.java:597)
        <br>
org.apache.cayenne.util.Invocation.fire(Invocation.java:204)
        <br>
org.apache.cayenne.event.EventManager$Dispatch.fire(EventManager.java:397)
        <br>
org.apache.cayenne.event.DispatchQueue.dispatchEvent(DispatchQueue.java:162)
        <br>
org.apache.cayenne.event.DispatchQueue.dispatchEvent(DispatchQueue.java:58)
        <br>
&nbsp; - locked org.apache.cayenne.event.DispatchQueue@c25268
        <br>
org.apache.cayenne.event.EventManager.dispatchEvent(EventManager.java:336)
        <br>
org.apache.cayenne.event.EventManager.postEvent(EventManager.java:307)
        <br>
org.apache.cayenne.access.DataContext.fireDataChannelChanged(DataContext.java:1704)
        <br>
org.apache.cayenne.access.DataContext.onContextFlush(DataContext.java:1189)
        <br>
org.apache.cayenne.access.DataContext.onSync(DataContext.java:1167)
        <br>
org.apache.cayenne.access.DataContext.flushToParent(DataContext.java:1234)
        <br>
&nbsp; - locked org.apache.cayenne.access.ObjectStore@a86d2f
        <br>
org.apache.cayenne.access.DataContext.commitChanges(DataContext.java:1138)
        <br>
com.ptb.commons.db.services.StatsServices.addForClient(StatsServices.java:42)
        <br>
com.ptb.backendnode.tasks.DataMgrStatsCalculation.run(DataMgrStatsCalculation.java:78)
        <br>
java.util.TimerThread.mainLoop(Timer.java:512)
        <br>
java.util.TimerThread.run(Timer.java:462)
        <br>
        <br>
        <br>
        <br>
Thanks!
        <br>
        <br>
        <br>
Michael Gentry escribi&oacute;:
        <br>
        <blockquote type="cite"><br>
Hi &Aacute;lvaro,
          <br>
          <br>
Creating a DataContext is a fairly cheap operation.&nbsp; I would suggest
          <br>
creating them as you need them and not try to optimize this operation
          <br>
at this point.&nbsp; If you run into bottlenecks in the future, then maybe
          <br>
look at other options, but there is a good chance that creating extra
          <br>
DataContexts will not be the source of a performance problem.
          <br>
          <br>
/dev/mrg
          <br>
          <br>
          <br>
On Jan 7, 2008 10:30 AM, &Aacute;lvaro Mart&iacute;nez
<a class="moz-txt-link-rfc2396E" href="mailto:alvaro_martinez@ptbsl.com">&lt;alvaro_martinez@ptbsl.com&gt;</a>
wrote:
          <br>
          <br>
          <blockquote type="cite">Thanks, Andrus and Philip
            <br>
            <br>
The threads I'm talking about are created from many sources and for
            <br>
different reasons. Not of all them are triggered in response to
            <br>
"something". There are also watchers, periodic tasks... So I can't map
            <br>
data contexts to some particular condition.
            <br>
            <br>
So then I have to create one data context per operation (that means a
            <br>
set of actions). Is this expensive? We are developing a heavy loaded
            <br>
cluster of servers, so it's important.
            <br>
            <br>
Thanks again!
            <br>
            <br>
            <br>
Andrus Adamchik escribi&oacute;:
            <br>
            <br>
            <br>
            <blockquote type="cite">Hi &Aacute;lvaro,
              <br>
              <br>
It is hard to give a precise advice on multithreading without knowing
              <br>
the nature of your application. So here is a few general notes:
              <br>
              <br>
* DataContext instance is your isolated area for making in-memory
              <br>
changes to objects that will all be committed at once. So consider
              <br>
using multiple contexts as appropriate. Cayenne docs recommend various
              <br>
common patterns, such as DataContext per session (i.e. each user has a
              <br>
dedicated context), DataContext per request, or DataContext per
              <br>
application (in a read-only app). You can also devise your own
              <br>
approach, if none of the above fit your needs. All you need to know
              <br>
here is that multiple threads *reading* from a shared DataContext is
              <br>
ok, but multiple threads *writing* to a shared DataContext is not ok.
              <br>
              <br>
* In a rare case if you really need multiple threads to work off of
              <br>
the same context, consider using a dedicated nested DataContext for
              <br>
each atomic object modifications.
              <br>
              <br>
Andrus
              <br>
              <br>
              <br>
On Jan 7, 2008, at 2:44 PM, &Aacute;lvaro Mart&iacute;nez wrote:
              <br>
              <br>
              <blockquote type="cite">Hi, I've been working for a while
with Cayenne but never realized I
                <br>
had a problem... until I got a weird exception.
                <br>
                <br>
The fact is that I had been using context.newObject() and
                <br>
context.commitChanges() to create new rows in the database. But my
                <br>
application works with many threads, so global commits can (and in
                <br>
fact do) interrupt normal creation of objects. Thread A and Thread B
                <br>
are creating objects and filling their fields, but then B commits all
                <br>
and A throws a validation exception because mandatory fields are
                <br>
missing.
                <br>
                <br>
How could I commit only one object?
                <br>
                <br>
Thanks,
                <br>
                <br>
&Aacute;lvaro from Spain (Push the button Inc.)
                <br>
                <br>
                <br>
                <br>
                <br>
              </blockquote>
              <br>
              <br>
            </blockquote>
            <br>
          </blockquote>
          <br>
          <br>
        </blockquote>
        <br>
      </blockquote>
      <br>
      <br>
      <br>
    </blockquote>
    <br>
    <br>
  </blockquote>
  <br>
  <br>
  <br>
</blockquote>
<br>
</body>
</html>

Mime
View raw message