Commit 7c7cd613 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@13742 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent be644466
......@@ -93,7 +93,9 @@ class SQLDict(RAMDict):
group_method_id_list = [message.activity_kw.get('group_method_id', '') for message in registered_message_list]
tag_list = [message.activity_kw.get('tag', '') for message in registered_message_list]
order_validation_text_list = [self.getOrderValidationText(message) for message in registered_message_list]
activity_tool.SQLDict_writeMessageList( path_list = path_list,
uid_list = activity_tool.getPortalObject().portal_ids.generateNewLengthIdList(id_group='portal_activity', id_count=len(registered_message_list))
activity_tool.SQLDict_writeMessageList( uid_list = uid_list,
path_list = path_list,
method_id_list = method_id_list,
priority_list = priority_list,
broadcast_list = broadcast_list,
......@@ -517,8 +519,10 @@ class SQLDict(RAMDict):
uid = line.uid
activity_tool.SQLDict_assignMessage(processing_node=1, uid=[uid])
if node_count > 1:
uid_list = activity_tool.getPortalObject().id_tool.generateNewLengthIdList(id_group='portal_activity', id_count=node_count - 1)
for node in range(2, node_count+1):
activity_tool.SQLDict_writeMessage( path = path,
activity_tool.SQLDict_writeMessage( uid = uid_list.pop(),
path = path,
method_id = line.method_id,
priority = line.priority,
broadcast = 1,
......
......@@ -9,7 +9,7 @@ class_file:
</dtml-comment>
<params></params>
CREATE TABLE `message` (
`uid` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`uid` INT UNSIGNED NOT NULL,
`date` DATETIME NOT NULL,
`path` VARCHAR(255) NOT NULL,
`method_id` VARCHAR(255) NOT NULL,
......
......@@ -7,7 +7,8 @@ cache_time:0
class_name:
class_file:
</dtml-comment>
<params>path
<params>uid
path
method_id
message
priority
......@@ -19,6 +20,7 @@ tag
order_validation_text</params>
INSERT INTO message
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">,
......
......@@ -7,7 +7,8 @@ cache_time:0
class_name:
class_file:
</dtml-comment>
<params>path_list
<params>uid_list
path_list
method_id_list
message_list
priority_list
......@@ -18,11 +19,12 @@ group_method_id_list
tag_list
order_validation_text_list</params>
INSERT INTO message
(path, date, method_id, processing_node, processing, priority, broadcast, group_method_id, tag, order_validation_text, message)
(uid, path, date, method_id, processing_node, processing, priority, broadcast, group_method_id, tag, order_validation_text, message)
VALUES
<dtml-in prefix="loop" expr="_.range(_.len(path_list))">
<dtml-if sequence-start><dtml-else>,</dtml-if>
(
<dtml-sqlvar expr="uid_list[loop_item]" type="int">,
<dtml-sqlvar expr="path_list[loop_item]" type="string">,
<dtml-if date_list><dtml-sqlvar expr="date_list[loop_item]" type="datetime"><dtml-else><dtml-sqlvar "_.DateTime()" type="datetime"></dtml-if>,
<dtml-sqlvar expr="method_id_list[loop_item]" 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