Change in ovirt-engine[ovirt-engine-3.6]: core: cleanup old event notification history

tnisan at redhat.com tnisan at redhat.com
Tue Apr 12 10:37:42 UTC 2016


Tal Nisan has submitted this change and it was merged.

Change subject: core: cleanup old event notification history
......................................................................


core: cleanup old event notification history

Description of the problem:

Customer is recording each login/logout from the system and sends
notifications on those events, in the database there are more than 0.5
Million of records for both audit_log and event_notification_hist
tables.

engine_357=# select count(*) from public.event_notification_hist;
 count
--------
 540260
(1 row)

engine_357=# select count(*) from public.audit_log;
 count
--------
 540250
(1 row)

The validatedb.sh script validates that there is no data that violates
Foreign Keys.

As part of this validation, the following query is generated and
executed :

select  (audit_log_id)
from public.event_notification_hist
where  (audit_log_id) IS NOT NULL
and (audit_log_id) not in (
    select audit_log_id from public.audit_log);

This is a very heavy query considering table sizes above and I can
understand why it expands from 1.5 hours to 7 hours, simply because both
tables keep on growing

One reason for this slow query is luck of suitable index on
event_notification_hist

Engine has a scheduler job that cleans records older than 30 days.
By checking why the audit_log and event_notification_history have
records older than 30 days I found that the cleanup mechanism skips
records that their audit_log_id exists in event_notification_history.
This caused the audit_log to include records older than 30 days and
event_notification_history not to be cleaned ever, making the upgrade
heavier from version to version as records grows.

This patch

1) Adds the missing index on event_notification_history so the FK
validation will use index and not do a table scan on such large tables.

2) Modify the cleanup mechanism to delete all old records, since
event_notification_history has a FK with DELETE CASCADE on audit_log, it
will be cleaned up as well.

3) Fix some broken tests

Patch was validated on the customer problematic DB and solved the
problem.

Change-Id: Ib93c1a37b0838d9020ca4f8a300346b3fe3b87f0
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1324733
Signed-off-by: emesika <emesika at redhat.com>
---
M backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/AuditLogDaoTest.java
M backend/manager/modules/dal/src/test/resources/fixtures.xml
M packaging/dbscripts/audit_log_sp.sql
A packaging/dbscripts/upgrade/03_06_2100_add_index_event_notification_hist.sql
4 files changed, 160 insertions(+), 155 deletions(-)

Approvals:
  Piotr Kliczewski: Looks good to me, but someone else must approve
  Tal Nisan: Looks good to me, but someone else must approve
  Martin Peřina: Looks good to me, approved
  Eli Mesika: Verified
  Jenkins CI: Passed CI tests



-- 
To view, visit https://gerrit.ovirt.org/55743
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib93c1a37b0838d9020ca4f8a300346b3fe3b87f0
Gerrit-PatchSet: 4
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.6
Gerrit-Owner: Eli Mesika <emesika at redhat.com>
Gerrit-Reviewer: Allon Mureinik <amureini at redhat.com>
Gerrit-Reviewer: Eli Mesika <emesika at redhat.com>
Gerrit-Reviewer: Jenkins CI
Gerrit-Reviewer: Martin Peřina <mperina at redhat.com>
Gerrit-Reviewer: Oved Ourfali <oourfali at redhat.com>
Gerrit-Reviewer: Piotr Kliczewski <piotr.kliczewski at gmail.com>
Gerrit-Reviewer: Sandro Bonazzola <sbonazzo at redhat.com>
Gerrit-Reviewer: Tal Nisan <tnisan at redhat.com>
Gerrit-Reviewer: gerrit-hooks <automation at ovirt.org>



More information about the Engine-commits mailing list