<!-- 
RSS generated by JIRA (5.2.7#850-sha1:b2af0c8dc8537b36121c6a579fabbdf79fc919e5) at Thu May 23 23:17:22 UTC 2013

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary add field=key&field=summary to the URL of your request.
For example:
http://www.doctrine-project.org/jira/si/jira.issueviews:issue-xml/DC-185/DC-185.xml?field=key&field=summary
-->
<rss version="0.92" >
<channel>
    <title>Doctrine Project</title>
    <link>http://www.doctrine-project.org/jira</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>5.2.7</version>
        <build-number>850</build-number>
        <build-date>21-02-2013</build-date>
    </build-info>

<item>
            <title>[DC-185] The pessimistic offline locking manager locks the entire table</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-185</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;Scenario: &lt;br/&gt;
    $entity = Doctrine::getTable(&apos;Steps&apos;)-&amp;gt;find($pID);&lt;br/&gt;
    $lockingManager = new Doctrine_Locking_Manager_Pessimistic( Doctrine_Manager::connection()  );&lt;br/&gt;
    $lockingManager-&amp;gt;releaseAgedLocks(300);&lt;br/&gt;
    $gotLock = $lockingManager-&amp;gt;getLock($entity, &apos;user1&apos; ); &lt;/p&gt;

&lt;p&gt;Running this code locks the entire table &quot;Steps&quot;, and not just the record. &lt;/p&gt;

&lt;p&gt;in the table &quot;doctrine_lock_tracking&quot;, in the fields: &quot;object_type&quot; and &quot;object_key&quot;  are saved in this case: &quot;Steps&quot; and &quot;IDStep&quot;. &lt;br/&gt;
I think that here must be saved &quot;Steps&quot; and &quot;120&quot; (the value of IDStep). &lt;/p&gt;
</description>
                <environment>Windows XP, WampServer Version 2.0&lt;br/&gt;
</environment>
            <key id="10336">DC-185</key>
            <summary>The pessimistic offline locking manager locks the entire table</summary>
                <type id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/bug.png">Bug</type>
                                <priority id="3" iconUrl="http://www.doctrine-project.org/jira/images/icons/priorities/major.png">Major</priority>
                    <status id="4" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/reopened.png">Reopened</status>
                    <resolution id="-1">Unresolved</resolution>
                                <assignee username="jwage">Jonathan H. Wage</assignee>
                                <reporter username="fbrussa">Fabian Brussa</reporter>
                        <labels>
                    </labels>
                <created>Wed, 4 Nov 2009 18:33:58 +0000</created>
                <updated>Thu, 13 Dec 2012 13:12:52 +0000</updated>
                                    <version>1.1.4</version>
                <version>1.1.5</version>
                <version>1.2.3</version>
                                                        <due></due>
                    <votes>7</votes>
                        <watches>7</watches>
                        <comments>
                    <comment id="10736" author="fbrussa" created="Wed, 18 Nov 2009 16:01:48 +0000"  >&lt;p&gt;Is anybody looking into this issue ?&lt;/p&gt;</comment>
                    <comment id="10755" author="jwage" created="Wed, 18 Nov 2009 22:05:55 +0000"  >&lt;p&gt;Can you provide a test case that shows the issue? It is hard to look into the issue without a test to run &lt;img class=&quot;emoticon&quot; src=&quot;http://www.doctrine-project.org/jira/images/icons/emoticons/smile.gif&quot; height=&quot;20&quot; width=&quot;20&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt; When I look at the code and our tests everything is passing and fine so I am not sure what your issue could be. Re-open if you have more information to provide.&lt;/p&gt;</comment>
                    <comment id="10774" author="fbrussa" created="Thu, 19 Nov 2009 12:14:42 +0000"  >&lt;p&gt;ok, I attach the test case&lt;/p&gt;</comment>
                    <comment id="10994" author="fbrussa" created="Thu, 3 Dec 2009 19:51:20 +0000"  >&lt;p&gt;Have you already been able to look at the testcase ??&lt;/p&gt;</comment>
                    <comment id="11385" author="fbrussa" created="Thu, 14 Jan 2010 19:48:41 +0000"  >&lt;p&gt;Any news ??&lt;/p&gt;</comment>
                    <comment id="13413" author="leszczu" created="Fri, 25 Jun 2010 10:15:21 +0000"  >&lt;p&gt;This issue is still valid for Doctrine 1.2. Doctrine_Locking_Manager_Pessimistic is &lt;b&gt;UNUSABLE&lt;/b&gt; without this bug fixed!&lt;/p&gt;</comment>
                    <comment id="13496" author="markus.woessner" created="Fri, 2 Jul 2010 05:26:05 +0000"  >&lt;p&gt;Having a look at &quot;Doctrine_Locking_Manager_Pessimistic::getLock()&quot; it becomes clear what causes this misbehaviour:&lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;    &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function getLock(Doctrine_Record $record, $userIdent)
    {
        $objectType = $record-&amp;gt;getTable()-&amp;gt;getComponentName();
        $key        = $record-&amp;gt;getTable()-&amp;gt;getIdentifier();

        $gotLock = &lt;span class=&quot;code-keyword&quot;&gt;false&lt;/span&gt;;
        $time = time();

        &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; (is_array($key)) {
            &lt;span class=&quot;code-comment&quot;&gt;// Composite key
&lt;/span&gt;            $key = implode(&apos;|&apos;, $key);
        }

        &lt;span class=&quot;code-keyword&quot;&gt;try&lt;/span&gt; {
            $dbh = $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;conn-&amp;gt;getDbh();
            $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;conn-&amp;gt;beginTransaction();

            $stmt = $dbh-&amp;gt;prepare(&apos;INSERT INTO &apos; . $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;_lockTable
                                  . &apos; (object_type, object_key, user_ident, timestamp_obtained)&apos;
                                  . &apos; VALUES (:object_type, :object_key, :user_ident, :ts_obtained)&apos;);

            $stmt-&amp;gt;bindParam(&apos;:object_type&apos;, $objectType);
            $stmt-&amp;gt;bindParam(&apos;:object_key&apos;, $key);
            $stmt-&amp;gt;bindParam(&apos;:user_ident&apos;, $userIdent);
            $stmt-&amp;gt;bindParam(&apos;:ts_obtained&apos;, $time);
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;There is NO hint about the Record&apos;s identifier VALUE but only about the identifier&apos;s NAME (mostly &quot;id&quot;) which appears to be redundant information. Instead of ...&lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;        $key = $record-&amp;gt;getTable()-&amp;gt;getIdentifier();
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;..there should be something like ..&lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;        $key = $record-&amp;gt;get($record-&amp;gt;getTable()-&amp;gt;getIdentifier());
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;In case of composite keys a string concatenation, prefixed by identifier&apos;s name might work but I would recommend using &quot;md5()&quot; on resulting value to limit its length since field &quot;object_key&quot; is limited to 250 chars.&lt;/p&gt;</comment>
                    <comment id="13497" author="branleb" created="Fri, 2 Jul 2010 10:49:03 +0000"  >&lt;p&gt;Based on the previous comment by Markus W&#246;&#223;ner i created a patch for  row based locking.&lt;/p&gt;

&lt;p&gt;It concatenates the PK fields and their values to a string and calculates the sha-1 hash as a unique string representing that record. This string is then used as key so that we&apos;ll only lock the single Record and not the whole table.&lt;/p&gt;

&lt;p&gt;I hope you&apos;ll give this patch a try - It solved this problem for me.&lt;/p&gt;</comment>
                    <comment id="13498" author="markus.woessner" created="Fri, 2 Jul 2010 17:18:56 +0000"  >&lt;p&gt;I applied patch from Mr. Florian Zumkeller-Quast and provided testcase didn&apos;t fail anymore. I think this should do it. By the way I find it strange that this issue isn&apos;t already fixed. I guess locking is not very much used by Doctrine users.&lt;/p&gt;</comment>
                    <comment id="16895" author="jeromeweb" created="Mon, 21 Nov 2011 10:29:51 +0000"  >&lt;p&gt;I applied patch too and it works now. I guess too that nobody use Lockings but when you use it ... without the patch it fails.&lt;/p&gt;</comment>
                    <comment id="19131" author="greg0ire" created="Thu, 13 Dec 2012 13:12:52 +0000"  >&lt;p&gt;Duplicate of &lt;a href=&quot;http://www.doctrine-project.org/jira/browse/DC-984&quot; class=&quot;external-link&quot;&gt;http://www.doctrine-project.org/jira/browse/DC-984&lt;/a&gt;&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                    <attachment id="10174" name="DC185TestCase.php" size="1952" author="fbrussa" created="Thu, 19 Nov 2009 12:15:52 +0000" />
                    <attachment id="10688" name="row_based_locking.patch" size="3262" author="branleb" created="Fri, 2 Jul 2010 10:49:03 +0000" />
                </attachments>
            <subtasks>
        </subtasks>
        </item>
</channel>
</rss>