Purged unused records from uuids table
This patch also removed transaction id hooks when calling RootController default get. As a result, uuids record will not be created. Change-Id: I2ca0be02256ec62c8f9d48266867cc44121c1c4b
This commit is contained in:
parent
c7c6cd725a
commit
c06ecba646
@ -7,7 +7,11 @@ class TransactionIdHook(PecanHook):
|
|||||||
|
|
||||||
def before(self, state):
|
def before(self, state):
|
||||||
try:
|
try:
|
||||||
transaction_id = utils.make_transid()
|
controller = str(state.controller)
|
||||||
|
if 'RootController._default' in controller:
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
transaction_id = utils.make_transid()
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
abort(500, headers={'faultstring': str(exc)})
|
abort(500, headers={'faultstring': str(exc)})
|
||||||
|
|
||||||
|
@ -48,6 +48,21 @@ def execute_app_custom_sql(conn):
|
|||||||
conn.execute(update_regions, (customer_domain, ))
|
conn.execute(update_regions, (customer_domain, ))
|
||||||
|
|
||||||
|
|
||||||
|
def execute_purge_uuids_record(conn):
|
||||||
|
"""Execute custom SQL statements to purge records from uuids table.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
conn (sqlalchemy.db): connection object for the SQL database
|
||||||
|
|
||||||
|
"""
|
||||||
|
sql = 'delete from uuids where uuid_type=\'transaction\' and ' \
|
||||||
|
'uuid not in (select transaction_id from transactions) and ' \
|
||||||
|
'uuid not in (select tracking_id from transactions) and ' \
|
||||||
|
'uuid not in (select resource_id from transactions);'
|
||||||
|
|
||||||
|
conn.execute(sql)
|
||||||
|
|
||||||
|
|
||||||
def main(argv=None):
|
def main(argv=None):
|
||||||
|
|
||||||
if argv is None:
|
if argv is None:
|
||||||
@ -112,4 +127,5 @@ def main(argv=None):
|
|||||||
|
|
||||||
conn = engine.connect()
|
conn = engine.connect()
|
||||||
execute_app_custom_sql(conn)
|
execute_app_custom_sql(conn)
|
||||||
|
execute_purge_uuids_record(conn)
|
||||||
conn.close()
|
conn.close()
|
||||||
|
@ -8,9 +8,13 @@ class TransIdHook(TransactionIdHook):
|
|||||||
|
|
||||||
def before(self, state):
|
def before(self, state):
|
||||||
try:
|
try:
|
||||||
transaction_id = utils.make_transid()
|
controller = str(state.controller)
|
||||||
|
if 'RootController._default' in controller:
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
transaction_id = utils.make_transid()
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
abort(500, headers={'faultstring': exc.message})
|
abort(500, headers={'faultstring': str(exc)})
|
||||||
|
|
||||||
tracking_id = state.request.headers['X-RANGER-Tracking-Id'] \
|
tracking_id = state.request.headers['X-RANGER-Tracking-Id'] \
|
||||||
if 'X-RANGER-Tracking-Id' in state.request.headers else transaction_id
|
if 'X-RANGER-Tracking-Id' in state.request.headers else transaction_id
|
||||||
|
@ -1,11 +1,21 @@
|
|||||||
from orm.common.orm_common.hooks.transaction_id_hook import TransactionIdHook
|
from orm.common.orm_common.hooks.transaction_id_hook import TransactionIdHook
|
||||||
from orm.common.orm_common.utils import utils
|
from orm.common.orm_common.utils import utils
|
||||||
|
|
||||||
|
from pecan import abort
|
||||||
|
|
||||||
|
|
||||||
class TransIdHook(TransactionIdHook):
|
class TransIdHook(TransactionIdHook):
|
||||||
|
|
||||||
def before(self, state):
|
def before(self, state):
|
||||||
transaction_id = utils.make_transid()
|
try:
|
||||||
|
controller = str(state.controller)
|
||||||
|
if 'RootController._default' in controller:
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
transaction_id = utils.make_transid()
|
||||||
|
except Exception as exc:
|
||||||
|
abort(500, headers={'faultstring': str(exc)})
|
||||||
|
|
||||||
tracking_id = state.request.headers['X-RANGER-Tracking-Id'] \
|
tracking_id = state.request.headers['X-RANGER-Tracking-Id'] \
|
||||||
if 'X-RANGER-Tracking-Id' in state.request.headers else transaction_id
|
if 'X-RANGER-Tracking-Id' in state.request.headers else transaction_id
|
||||||
setattr(state.request, 'transaction_id', transaction_id)
|
setattr(state.request, 'transaction_id', transaction_id)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user