def _askCheckCurrentSerial(self, conn, ttid, serial, oid, request_time): try: self.app.tm.checkCurrentSerial(ttid, serial, oid) except ConflictError, err: # resolvable or not conn.answer(Packets.AnswerCheckCurrentSerial(1, oid, err.getTID()))
except NonReadableCell: logging.info('Ignore check of %s:%s by %s: unassigned partition', dump(oid), dump(serial), dump(ttid)) locked = ZERO_TID except NotRegisteredError: # transaction was aborted, cancel this event logging.info('Forget serial check of %s:%s by %s delayed by %s', dump(oid), dump(serial), dump(ttid), dump(self.app.tm.getLockingTID(oid))) locked = ZERO_TID else: if request_time and SLOW_STORE is not None: duration = time.time() - request_time if duration > SLOW_STORE: logging.info('CheckCurrentSerial delay: %.02fs', duration) conn.answer(Packets.AnswerCheckCurrentSerial(locked)) # like ClientOperationHandler but read-only & only for tid <= backup_tid class ClientReadOnlyOperationHandler(ClientOperationHandler): def _readOnly(self, conn, *args, **kw): conn.answer( Errors.ReadOnlyAccess( 'read-only access because cluster is in backuping mode')) askStoreTransaction = _readOnly askVoteTransaction = _readOnly askStoreObject = _readOnly askFinalTID = _readOnly askRebaseObject = _readOnly askRebaseTransaction = _readOnly
self._askCheckCurrentSerial(conn, ttid, serial, oid, time.time()) def _askCheckCurrentSerial(self, conn, ttid, serial, oid, request_time): try: self.app.tm.checkCurrentSerial(ttid, serial, oid) except ConflictError, err: # resolvable or not conn.answer(Packets.AnswerCheckCurrentSerial(1, oid, err.getTID())) except DelayedError: # locked by a previous transaction, retry later try: self.app.queueEvent(self._askCheckCurrentSerial, conn, (ttid, serial, oid, request_time), key=(oid, ttid)) except AlreadyPendingError: conn.answer(Errors.AlreadyPending(dump(oid))) except NotRegisteredError: # transaction was aborted, cancel this event logging.info('Forget serial check of %s:%s by %s delayed by %s', dump(oid), dump(serial), dump(ttid), dump(self.app.tm.getLockingTID(oid))) # send an answer as the client side is waiting for it conn.answer(Packets.AnswerCheckCurrentSerial(0, oid, serial)) else: if SLOW_STORE is not None: duration = time.time() - request_time if duration > SLOW_STORE: logging.info('CheckCurrentSerial delay: %.02fs', duration) conn.answer(Packets.AnswerCheckCurrentSerial(0, oid, serial))
conn.answer(Packets.AnswerCheckCurrentSerial(err.tid)) return except NonReadableCell: logging.info('Ignore check of %s:%s by %s: unassigned partition', dump(oid), dump(serial), dump(ttid)) except NotRegisteredError: # transaction was aborted, cancel this event logging.info('Forget serial check of %s:%s by %s delayed by %s', dump(oid), dump(serial), dump(ttid), dump(self.app.tm.getLockingTID(oid))) else: if request_time and SLOW_STORE is not None: duration = time.time() - request_time if duration > SLOW_STORE: logging.info('CheckCurrentSerial delay: %.02fs', duration) conn.answer(Packets.AnswerCheckCurrentSerial(None)) # like ClientOperationHandler but read-only & only for tid <= backup_tid class ClientReadOnlyOperationHandler(ClientOperationHandler): def _readOnly(self, conn, *args, **kw): conn.answer( Errors.ReadOnlyAccess( 'read-only access because cluster is in backuping mode')) askStoreTransaction = _readOnly askVoteTransaction = _readOnly askStoreObject = _readOnly askFinalTID = _readOnly askRebaseObject = _readOnly askRebaseTransaction = _readOnly