Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure that the Number of runs is displayed correctly #4242

Merged
merged 1 commit into from
May 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions web/server/codechecker_server/api/report_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -3424,10 +3424,27 @@ def removeRun(self, run_id, run_filter):
# cascades and such. Deleting runs in separate transactions don't
# exceed a potential statement timeout threshold in a DBMS.
runs = []
deleted_run_cnt = 0

for run in q.all():
runs.append(run.name)
session.delete(run)
session.commit()
try:
runs.append(run.name)
session.delete(run)
session.commit()
deleted_run_cnt += 1
except Exception as e:
# TODO: Display alert on the GUI if there's an exception
# TODO: Catch SQLAlchemyError instead of generic
# exception once it is confirmed that the exception is
# due to a large run deletion timeout based on server
# log warnings
# This exception is handled silently because it is
# expected to never occur, but there have been some rare
# cases where it occurred due to underlying reasons.
# Handling it silently ensures that the Number of runs
# counter is not affected by the exception.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One reason of the exception can be an SQL statement timeout while a too large run is being deleted. We should include another TODO here which suggests the catching of SQLAlchemyError instead of the generic Exception when we can make this sure based on the warnings messages below, in the server logs.

LOG.warning(f"Suppressed an exception while "
f"deleting run {run.name}. Error: {e}")

session.close()

Expand All @@ -3436,7 +3453,7 @@ def removeRun(self, run_id, run_filter):

# Decrement the number of runs but do not update the latest storage
# date.
self._set_run_data_for_curr_product(-1 * len(runs))
self._set_run_data_for_curr_product(-1 * deleted_run_cnt)

# Remove unused comments and unused analysis info from the database.
# Originally db_cleanup.remove_unused_data() was used here which
Expand Down
Loading