drop tables sequencially to avoid max_locks_per_transaction (#20190)

This commit is contained in:
Christophe Siraut 2019-04-15 16:30:45 +02:00
parent 70a7271d15
commit 0ef61ec694
1 changed files with 10 additions and 0 deletions

View File

@ -315,11 +315,21 @@ class WcsOlapFeeder(object):
def do_schema(self):
self.ex('SET search_path = public')
self.logger.debug('dropping schema %s', self.schema + '_temp')
self.drop_tables_sequencially()
self.ex('DROP SCHEMA IF EXISTS {schema_temp} CASCADE')
self.logger.debug('creating schema %s', self.schema)
self.ex('CREATE SCHEMA {schema_temp}')
self.ex('SET search_path = {schema_temp},public')
def drop_tables_sequencially(self):
"""
Drop tables one by one in order to avoid reaching max_locks_per_transaction
"""
self.ex("SELECT tablename FROM pg_tables WHERE schemaname = '{schema_temp}'")
for table in self.cur.fetchall():
tablename = '%s%s.%s' % (self.schema, '_temp', table[0])
self.ex('DROP TABLE IF EXISTS %s CASCADE;' % tablename)
def do_dates_table(self):
# test if public.dates exists
self.ex("SELECT * FROM information_schema.tables WHERE table_name = 'dates' AND"