Commit ba43938e authored by Vincent Pelletier's avatar Vincent Pelletier

Log when StoreObject takes longer than given duration.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2079 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 86ecb4bd
...@@ -19,6 +19,11 @@ from neo import protocol ...@@ -19,6 +19,11 @@ from neo import protocol
from neo.protocol import Packets from neo.protocol import Packets
from neo.storage.handlers import BaseClientAndStorageOperationHandler from neo.storage.handlers import BaseClientAndStorageOperationHandler
from neo.storage.transactions import ConflictError, DelayedError from neo.storage.transactions import ConflictError, DelayedError
import time
# Log stores taking (incl. lock delays) more than this many seconds.
# Set to None to disable.
SLOW_STORE = 2
class ClientOperationHandler(BaseClientAndStorageOperationHandler): class ClientOperationHandler(BaseClientAndStorageOperationHandler):
...@@ -42,8 +47,8 @@ class ClientOperationHandler(BaseClientAndStorageOperationHandler): ...@@ -42,8 +47,8 @@ class ClientOperationHandler(BaseClientAndStorageOperationHandler):
False) False)
conn.answer(Packets.AnswerStoreTransaction(tid)) conn.answer(Packets.AnswerStoreTransaction(tid))
def askStoreObject(self, conn, oid, serial, def _askStoreObject(self, conn, oid, serial, compression, checksum, data,
compression, checksum, data, tid): tid, request_time):
uuid = conn.getUUID() uuid = conn.getUUID()
try: try:
self.app.tm.storeObject(uuid, tid, serial, oid, compression, self.app.tm.storeObject(uuid, tid, serial, oid, compression,
...@@ -54,11 +59,20 @@ class ClientOperationHandler(BaseClientAndStorageOperationHandler): ...@@ -54,11 +59,20 @@ class ClientOperationHandler(BaseClientAndStorageOperationHandler):
conn.answer(Packets.AnswerStoreObject(1, oid, tid_or_serial)) conn.answer(Packets.AnswerStoreObject(1, oid, tid_or_serial))
except DelayedError: except DelayedError:
# locked by a previous transaction, retry later # locked by a previous transaction, retry later
self.app.queueEvent(self.askStoreObject, conn, oid, serial, self.app.queueEvent(self._askStoreObject, conn, oid, serial,
compression, checksum, data, tid) compression, checksum, data, tid, request_time)
else: else:
if SLOW_STORE is not None:
duration = time.time() - request_time
if duration > SLOW_STORE:
logging.info('StoreObject delay: %.02fs', duration)
conn.answer(Packets.AnswerStoreObject(0, oid, serial)) conn.answer(Packets.AnswerStoreObject(0, oid, serial))
def askStoreObject(self, conn, oid, serial,
compression, checksum, data, tid):
self._askStoreObject(conn, oid, serial, compression, checksum, data,
tid, time.time())
def askTIDs(self, conn, first, last, partition): def askTIDs(self, conn, first, last, partition):
# This method is complicated, because I must return TIDs only # This method is complicated, because I must return TIDs only
# about usable partitions assigned to me. # about usable partitions assigned to me.
......
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