Commit f84e8722 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Split multi-inserted messages into chunks, because an insert query generated...

Split multi-inserted messages into chunks, because an insert query generated by prepareQueueMessageList may exceed the limit of packet size defined by MySQL, when one transaction activate many, many methods. The max size is heuristic, though.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@28426 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 5b115a8f
......@@ -56,6 +56,8 @@ READ_MESSAGE_LIMIT = 1000
# objects are impacted by elected messages.
MAX_GROUPED_OBJECTS = 100
MAX_MESSAGE_LIST_SIZE = 100
class SQLDict(RAMDict, SQLBase):
"""
A simple OOBTree based queue. It should be compatible with transactions
......@@ -64,11 +66,9 @@ class SQLDict(RAMDict, SQLBase):
"""
# Transaction commit methods
def prepareQueueMessageList(self, activity_tool, message_list):
registered_message_list = []
for message in message_list:
if message.is_registered:
registered_message_list.append(message)
if len(registered_message_list) > 0:
message_list = [m for m in message_list if m.is_registered]
for i in xrange(0, len(message_list), MAX_MESSAGE_LIST_SIZE):
registered_message_list = message_list[i:i + MAX_MESSAGE_LIST_SIZE]
#LOG('SQLDict prepareQueueMessageList', 0, 'registered_message_list = %r' % (registered_message_list,))
path_list = ['/'.join(message.object_path) for message in registered_message_list]
active_process_uid_list = [message.active_process_uid for message in registered_message_list]
......
......@@ -65,6 +65,8 @@ READ_MESSAGE_LIMIT = 1000
# first.
MESSAGE_BUNDLE_SIZE = 1
MAX_MESSAGE_LIST_SIZE = 100
class SQLQueue(RAMQueue, SQLBase):
"""
A simple OOBTree based queue. It should be compatible with transactions
......@@ -73,8 +75,9 @@ class SQLQueue(RAMQueue, SQLBase):
"""
def prepareQueueMessageList(self, activity_tool, message_list):
registered_message_list = [m for m in message_list if m.is_registered]
if len(registered_message_list):
message_list = [m for m in message_list if m.is_registered]
for i in xrange(0, len(message_list), MAX_MESSAGE_LIST_SIZE):
registered_message_list = message_list[i:i + MAX_MESSAGE_LIST_SIZE]
uid_list = activity_tool.getPortalObject().portal_ids.generateNewLengthIdList(
id_group='portal_activity_queue', id_count=len(registered_message_list),
store=0)
......
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