Skip to content

Commit

Permalink
Remove the SQLAlchemy session at the end of the process function
Browse files Browse the repository at this point in the history
This fixes a bug where the process function fails to update the database when setting the task status to `reported` if the pebble process had previously processed the task.

By removing the session after processing, the next task that runs in the same process will grab a new session and will be forced to pull new objects from the database. Preventing any data inconsistencies.
  • Loading branch information
josh-feather committed Jan 30, 2025
1 parent 3f81dd1 commit f96022f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions utils/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,12 @@ def process(

log.removeHandler(per_analysis_handler)

# Remove the SQLAlchemy session to ensure the next task pulls objects from
# the database, instead of relying on a potentially outdated object cache.
# Stale data can prevent SQLAlchemy from querying the database or issuing
# statements, resulting in unexpected errors and inconsistencies.
db.session.remove()


def init_worker():
signal.signal(signal.SIGINT, signal.SIG_IGN)
Expand Down

0 comments on commit f96022f

Please sign in to comment.