<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>Dear List</div><div><br></div><div>I am having trouble understanding why Mnesia is grabbing a read-lock on an entire table. Can someone give me any insight?</div><div><br></div><div>Here are some facts (beliefs ;)</div><div><span style="text-indent: -0.25in; "><br></span></div><div style="text-indent: 0px;"><span style="text-indent: -0.25in; ">* The table is of type ordered_set</span></div><div style="text-indent: 0px;"><span style="text-indent: -0.25in; ">*<span style="font-family: 'Times New Roman'; font-size: 7pt; "> </span></span><span style="text-indent: -0.25in; ">My key is a two-tuple,  {unix-style-milliseconds-since-1970, Key} as in, {1351872742126278,"BI13626"}},</span></div><div style="text-indent: 0px;"><span style="text-indent: -0.25in; ">*<span style="font-family: 'Times New Roman'; font-size: 7pt; "> </span></span><span style="text-indent: -0.25in; ">There are two additional indexed columns</span></div><div style="text-indent: 0px;"><span style="text-indent: -0.25in; ">*</span><span style="text-indent: -0.25in; -webkit-tap-highlight-color: rgba(26, 26, 26, 0.292969); -webkit-composition-fill-color: rgba(175, 192, 227, 0.230469); -webkit-composition-frame-color: rgba(77, 128, 180, 0.230469); font-family: Symbol; "><span style="font-size: 7pt; font-family: 'Times New Roman'; ">  </span></span><span style="text-indent: -0.25in; -webkit-tap-highlight-color: rgba(26, 26, 26, 0.292969); -webkit-composition-fill-color: rgba(175, 192, 227, 0.230469); -webkit-composition-frame-color: rgba(77, 128, 180, 0.230469); ">I am frequently, in the same transaction, deleting and inserting two records which differ *</span><b style="text-indent: -0.25in; -webkit-tap-highlight-color: rgba(26, 26, 26, 0.292969); -webkit-composition-fill-color: rgba(175, 192, 227, 0.230469); -webkit-composition-frame-color: rgba(77, 128, 180, 0.230469); ">only</b><span style="text-indent: -0.25in; -webkit-tap-highlight-color: rgba(26, 26, 26, 0.292969); -webkit-composition-fill-color: rgba(175, 192, 227, 0.230469); -webkit-composition-frame-color: rgba(77, 128, 180, 0.230469); ">* in the time-stamp portion of the key – I am replacing an older version of the record with a newer version</span></div><div style="text-indent: 0px;"><span style="text-indent: -0.25in; "><span style="-webkit-tap-highlight-color: rgba(26, 26, 26, 0.292969); -webkit-composition-fill-color: rgba(175, 192, 227, 0.230469); -webkit-composition-frame-color: rgba(77, 128, 180, 0.230469);">* </span>All access is done within a function that is passed to mnesia:transaction/1</span></div><div style="text-indent: 0px;"><span style="text-indent: -0.25in; ">*<span style="font-family: 'Times New Roman'; font-size: 7pt; "> </span></span><span style="text-indent: -0.25in; ">All access to the table in question is via:</span></div><div style="text-indent: 0px;"><span style="text-indent: -0.25in; ">    </span><span style="text-indent: -0.25in; font-family: 'Courier New'; ">o<span style="font-size: 7pt; font-family: 'Times New Roman'; ">   </span></span><span style="text-indent: -0.25in; ">mnesia:index_read/3 where all three variables being passed in are *</span><b style="text-indent: -0.25in; ">always</b><span style="text-indent: -0.25in; ">* bound,  or</span></div><div style="text-indent: 0px;"><span style="text-indent: -0.25in; ">    </span><span style="text-indent: -0.25in; font-family: 'Courier New'; ">o<span style="font-size: 7pt; font-family: 'Times New Roman'; ">   </span></span><span style="text-indent: -0.25in; ">mnesia:select/2 as shown below</span></div><div style="text-indent: 0px;"><br></div><div style="text-indent: 0px;"><br></div><div style="text-indent: 0px;">lookup_since(Since) -></div><div style="text-indent: 0px;">    M = [{#key_to_value{update_map={'$1', '_'}, _='_'},</div><div style="text-indent: 0px;">    [{'>', '$1', Since}], ['$_']}]</div><div style="text-indent: 0px;">   {ok, mnesia:select(key_to_value, M)}.</div><div style="text-indent: 0px;"><br></div><div style="text-indent: 0px;">or</div><div style="text-indent: 0px;"><br></div><div style="text-indent: 0px;">lookup_keylist(Keys, Since) -></div><div style="text-indent: 0px;">   M = [{#key_to_value{update_map={'$1', K}, _='_'},</div><div style="text-indent: 0px;">          [{'>', '$1', Since}],  ['$_']} || K <- Keys],</div><div style="text-indent: 0px;">    {ok, mnesia:select(key_to_value, M)}.</div><div style="text-indent: 0px;"><br></div><div style="text-indent: 0px;">Mnesia:info reports the following</div><blockquote type="cite"><blockquote type="cite"><div class="WordSection1"><p class="MsoNormal"><o:p></o:p></p><p class="MsoNormal"><o:p> </o:p></p><p class="MsoNormal">Lock: {{key_to_value,'______WHOLETABLE_____'},read,{tid,247,<0.1717.0>}}<o:p></o:p></p><p class="MsoNormal">Lock: {{key_to_value,{1351872742126278,"BI13626"}},write,{tid,247,<0.1717.0>}}<o:p></o:p></p><p class="MsoNormal">Lock: {{key_to_value,{1351872742130724,"BI13623"}},write,{tid,247,<0.1717.0>}}<o:p></o:p></p><p class="MsoNormal">Lock: {{key_to_value,{1351872742136170,"BI13621"}},write,{tid,247,<0.1717.0>}}<o:p></o:p></p><p class="MsoNormal">Lock: {{key_to_value,{1351872742140957,"BI13616"}},write,{tid,247,<0.1717.0>}}<o:p></o:p></p><p class="MsoNormal">Lock: {{key_to_value,{1351872746638841,"BI13628"}},write,{tid,247,<0.1717.0>}}<o:p></o:p></p><p class="MsoNormal">Lock: {{key_to_value,{1351872746640989,"BI13626"}},write,{tid,247,<0.1717.0>}}<o:p></o:p></p><p class="MsoNormal">Lock: {{key_to_value,{1351872746642481,"BI13623"}},write,{tid,247,<0.1717.0>}}<o:p></o:p></p><p class="MsoNormal">Lock: {{key_to_value,{1351872746643406,"BI13621"}},write,{tid,247,<0.1717.0>}}<o:p></o:p></p><p class="MsoNormal">Lock: {{key_to_value,{1351872746644468,"BI13616"}},write,{tid,247,<0.1717.0>}}<o:p></o:p></p><p class="MsoNormal">Lock: {{scope_to_keys,"6B-PED"},write,{tid,247,<0.1717.0>}}<o:p></o:p></p><p class="MsoNormal">Lock: {{scope_to_keys,"InPatient"},write,{tid,247,<0.1717.0>}}<o:p></o:p></p><p class="MsoNormal">Lock: {{type_to_keys,"b_index"},write,{tid,247,<0.1717.0>}}<o:p></o:p></p><p class="MsoNormal">---> Processes waiting for locks <---<o:p></o:p></p><p class="MsoNormal">---> Participant transactions <---<o:p></o:p></p><p class="MsoNormal">---> Coordinator transactions <---<o:p></o:p></p><p class="MsoNormal">Tid: 247 (owned by <0.1717.0>)<o:p></o:p></p><p class="MsoNormal">---> Uncertain transactions <---<o:p></o:p></p><p class="MsoNormal"><o:p> </o:p></p><p class="MsoNormal"><o:p> </o:p></p><p class="MsoNormal">Here is a second example of the mnesia:info() output<o:p></o:p></p><p class="MsoNormal"><o:p> </o:p></p><p class="MsoNormal">---> Processes holding locks <---<o:p></o:p></p><p class="MsoNormal">Lock: {{key_to_value,'______WHOLETABLE_____'},read,{tid,707,<0.1876.0>}}<o:p></o:p></p><p class="MsoNormal">Lock: {{key_to_value,{1351872861465784,"VI14543"}},write,{tid,707,<0.1876.0>}}<o:p></o:p></p><p class="MsoNormal">Lock: {{key_to_value,{1351872868375564,"VI14543"}},write,{tid,707,<0.1876.0>}}<o:p></o:p></p><p class="MsoNormal">---> Processes waiting for locks <---<o:p></o:p></p><p class="MsoNormal">---> Participant transactions <---<o:p></o:p></p><p class="MsoNormal">---> Coordinator transactions <---<o:p></o:p></p><p class="MsoNormal">Tid: 707 (owned by <0.1876.0>)<o:p></o:p></p><p class="MsoNormal">---> Uncertain transactions <---</p></div></blockquote></blockquote>Any help would be greatly appreciated,<br>Jr0<blockquote type="cite"><blockquote type="cite"><div class="WordSection1"><p class="MsoNormal"><o:p></o:p></p></div></blockquote></blockquote></body></html>