I have a parser with ~50 threads. After a few hours of parserwork a have an error
sqlalchemy.exc.InternalError: (psycopg2.errors.InternalError_) Canceling query because of high VMEM usage. Used: 14MB, available 195MB, red zone: 1800MB (runaway_cleaner.c:202)
Full traceback -- https://pastebin.com/7yf7r850
I am using dataset 1.5.0 library to work with database. https://dataset.readthedocs.io/en/latest/
I create db and table functions in the init function for each thread
def __init__(self, config_data, person_id, parsing_mode):
self.db = dataset.connect(configs.DB_CONNECTION)
self.table = self.db.get_table('social_network_user')
then in cycle i perform insert or update operation
self.table.upsert(dict(
lom_id=user_id,
social_network_id=follower_id,
social_network_login=follower_id,
follower_url=follower_url,
follower_name=follower_name,
social_network_type_id=0,
social_uuid=f"{follower_id}.0",
default_total=int(self.total_followers_number),
subscribers_visible=subscribers_visible,
subscribed_ids=[int(self.person_id),]
), ["lom_id", "social_uuid"])
How can I fix the error? The server is powerfull, can I increase some system limits for database?
psql --version
psql (PostgreSQL) 12.8 (Ubuntu 12.8-0ubuntu0.20.04.1)