Skip to content
  • Dmitry Shulga's avatar
    b7bb8913
    Fixed bug#11748899 (formerly known as 37666): Event set to DISABLED status · b7bb8913
    Dmitry Shulga authored
    and ON COMPLETION NOT PRESERVE is deleted at server restart.
    
    From user's point of view when user creates event with default on
    completion behaviour and its status is DISABLE,
    then after restart of server this event is deleted from schema.
    
    The problem was that during loading of events from mysql.event table
    server was used incorrect implementation for 'on completion' behaviour, i.e.
    if event loaded from table had status value DISABLE and ON COMPLETION flag
    was equal to true, then server deleted event from table without regarding 
    status value. The root of cause was at the method Events::load_events_from_db()
    (this method called by Events::init() during server startup initialization).
    This method reads every event from table and creates event object from 
    loaded data. When event that was disabled and had the default ON COMPLETION
    NOT PRESERVE behaviour was loaded from mysql.event table into
    object of class Event_queue_element then it had attribute
    on_completion=Event_parse_data::ON_COMPLETION_DROP and
    status = Event_parse_data::DISABLED. After loading completed it tries to
    put event into queue but this failed because status == DISABLE.
    Then this event dropped since the condition 
    'else if (drop_on_completion)' is true.
    
    The solution is to change wrong condition. The right condition is
    to check for value of attribute Event_queue_element::dropped that is set
    to true when event really should dropped because it expired
    (this check is implemented at
    Event_queue_element::compute_next_execution_time).
    
    This patch also fix a bug related to deleting of expired events from 
    mysql.event table after server restart.
    
    The problem was that if there was an event that expired at time T
    and before that time came server was down and started again after 
    time T was elapsed then expired event will never be removed.
    
    The reason for this bug is that when the server initializes scheduler
    structures at Events::init() it's never calls set_time() 
    for new THD object and so THD::start_time attribute has value 0.
    Afterwards when events is loaded from mysql.event table into memory
    server checks end_time of event against value of 
    current_thd->query_start() that returns value 0. As a result expired
    events is considered as expired.
    
    The solution is to call THD::set_time() for new created THD at Events::init.
    b7bb8913
    Fixed bug#11748899 (formerly known as 37666): Event set to DISABLED status
    Dmitry Shulga authored
    and ON COMPLETION NOT PRESERVE is deleted at server restart.
    
    From user's point of view when user creates event with default on
    completion behaviour and its status is DISABLE,
    then after restart of server this event is deleted from schema.
    
    The problem was that during loading of events from mysql.event table
    server was used incorrect implementation for 'on completion' behaviour, i.e.
    if event loaded from table had status value DISABLE and ON COMPLETION flag
    was equal to true, then server deleted event from table without regarding 
    status value. The root of cause was at the method Events::load_events_from_db()
    (this method called by Events::init() during server startup initialization).
    This method reads every event from table and creates event object from 
    loaded data. When event that was disabled and had the default ON COMPLETION
    NOT PRESERVE behaviour was loaded from mysql.event table into
    object of class Event_queue_element then it had attribute
    on_completion=Event_parse_data::ON_COMPLETION_DROP and
    status = Event_parse_data::DISABLED. After loading completed it tries to
    put event into queue but this failed because status == DISABLE.
    Then this event dropped since the condition 
    'else if (drop_on_completion)' is true.
    
    The solution is to change wrong condition. The right condition is
    to check for value of attribute Event_queue_element::dropped that is set
    to true when event really should dropped because it expired
    (this check is implemented at
    Event_queue_element::compute_next_execution_time).
    
    This patch also fix a bug related to deleting of expired events from 
    mysql.event table after server restart.
    
    The problem was that if there was an event that expired at time T
    and before that time came server was down and started again after 
    time T was elapsed then expired event will never be removed.
    
    The reason for this bug is that when the server initializes scheduler
    structures at Events::init() it's never calls set_time() 
    for new THD object and so THD::start_time attribute has value 0.
    Afterwards when events is loaded from mysql.event table into memory
    server checks end_time of event against value of 
    current_thd->query_start() that returns value 0. As a result expired
    events is considered as expired.
    
    The solution is to call THD::set_time() for new created THD at Events::init.
Loading