Bug description

Each triggering of an alert or report appears in the log twice. Once with its actual runtime and result, once with a runtime of 00:00:00 or 00:00:01. Is there a bad join or does some event need to be filtered out?

How to reproduce the bug

Create an alert or report, let it run, look at the execution log.

Screenshots/recordings

Apache Superset Duplicated entries in Alerts & Reports execution log

Superset version

4.0.2

Python version

I don't know

Node version

I don't know

Browser

Not applicable

Additional context

In case it matters, all reports and alerts are being delivered by email, not Slack.

Checklist

  • [X] I have searched Superset docs and Slack and didn't find a solution to my problem.
  • [X] I have searched the GitHub issue tracker and didn't find a similar bug report.
  • [X] I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.

Comment From: Siddharth-Latthe-07

possible solutions steps:- 1. Check the Log Creation Process 2. Examine the Database Queries:- Review the queries that retrieve the log entries for display. Ensure there are no issues like joins or unions that could be causing duplicate entries. 3. Sample snippet:-

def log_execution(alert_id, runtime, result):
    # This function should only be called once per execution
    # Ensure there's no duplicate call to this function
    log_entry = {
        'alert_id': alert_id,
        'runtime': runtime,
        'result': result,
    }
    save_log_entry_to_database(log_entry)

# This function might be called at different stages of execution
# Ensure it’s not causing duplicate log entries
def execute_alert(alert):
    start_time = get_current_time()
    log_execution(alert.id, start_time, "Started")

    result = perform_alert_execution(alert)

    end_time = get_current_time()
    log_execution(alert.id, end_time, result)

Follow the same for checking the queries Hope this helps, Thanks

Comment From: rusackas

@sfirke is this still an issue you're facing?

Comment From: sfirke

Hrm, I haven't been able to test it on a newer version of Superset so not sure if it's been fixed. I hope that's something I can get to in the near term.

Comment From: rusackas

I'm still seeing what you see in the screenshot... it looks like one line is the trigger, and one line is the result. It does seem that the result entry should replace the trigger, since they have the same timestamp and it's just an updated status.

CC @sadpandajoe @yousoph @Vitor-Avila - not sure if any Preset customers have cared about this, but maybe it's worth taking on if so?

Comment From: Vitor-Avila

hey @rusackas I can confirm that this is the case in Preset Cloud as well, but not something people would complain/report very often. Considering that each entry can have both start time and duration, I imagine it would be OK to simplify these