Commit b411b407 authored by Vincent Pelletier's avatar Vincent Pelletier

Use portal_ids to generate message uids instead of using MySQL AUTO_INCREMENT....

Use portal_ids to generate message uids instead of using MySQL AUTO_INCREMENT. This will lower deadlock probability by removing the one caused by AUTO_INCREMENT table-level lock.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@13757 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 16b63d66
......@@ -61,7 +61,9 @@ class SQLQueue(RAMQueue):
"""
def prepareQueueMessage(self, activity_tool, m):
if m.is_registered:
activity_tool.SQLQueue_writeMessage(path = '/'.join(m.object_path) ,
#import pdb; pdb.set_trace()
activity_tool.SQLQueue_writeMessage(uid = activity_tool.getPortalObject().portal_ids.generateNewLengthId(id_group='portal_activity_queue'),
path = '/'.join(m.object_path) ,
method_id = m.method_id,
priority = m.activity_kw.get('priority', 1),
broadcast = m.activity_kw.get('broadcast', 0),
......@@ -316,8 +318,10 @@ class SQLQueue(RAMQueue):
# Broadcast messages must be distributed into all nodes.
activity_tool.SQLQueue_assignMessage(processing_node=1, uid=uid)
if node_count > 1:
uid_list = activity_tool.getPortalObject().portal_ids.generateNewLengthIdList(id_group='portal_activity_queue', id_count=node_count - 1)
for node in range(2, node_count+1):
activity_tool.SQLQueue_writeMessage( path = line.path,
activity_tool.SQLQueue_writeMessage(uid = uid_list.pop(),
path = line.path,
method_id = line.method_id,
priority = line.priority,
broadcast = 1,
......
......@@ -9,7 +9,7 @@ class_file:
</dtml-comment>
<params></params>
CREATE TABLE `message_queue` (
`uid` int(11) NOT NULL auto_increment,
`uid` int(11) NOT NULL,
`date` datetime,
`path` VARCHAR(255),
`method_id` VARCHAR(40),
......
......@@ -7,7 +7,8 @@ cache_time:0
class_name:
class_file:
</dtml-comment>
<params>path
<params>uid
path
method_id
message
priority
......@@ -17,6 +18,7 @@ date
tag</params>
INSERT INTO message_queue
SET
uid = <dtml-sqlvar uid type="int">,
path = <dtml-sqlvar path type="string">,
<dtml-if date>date = <dtml-sqlvar date type="string">, <dtml-else>date = <dtml-sqlvar "_.DateTime()" type="datetime">, </dtml-if>
method_id = <dtml-sqlvar method_id type="string">,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment