Why the MySQL event scheduler doesn’t work on Aurora Serverless (and how to fix it with AWS Lambda)

Why the MySQL event scheduler doesn't work on Aurora Serverless (and how to fix it with AWS Lambda)

Where the MySQL Event Scheduler mechanism works for both the MySQL  and  Aurora Cluster RDS services. It seemed not to work after migrating our applications to Aurora Serverless clusters.

The event_scheduler parameter was still set in the parameter group:

  DBClusterParameterGroup:
    Type: AWS::RDS::DBClusterParameterGroup
    Properties:
      Description: !Sub 'terra10-${ENV}-parametergroup'
      Family: aurora5.6
      Parameters:
        event_scheduler: 'ON'
      Tags:
        - Key: Name
          Value: !Sub 'terra10-${ENV}-parametergroup'

But the database did not seem to pick up the setting:

SELECT @@global.event_scheduler;
"OFF"

Then we noticed this post which told us we are not alone. It seems a limitation when using the Aurora Serverless  MySQL engine, however not well documented.

Values changed of event_scheduler in Group Parameter are not reflecting in Aurora Database
I have configured an Aurora Serverless DB, I need to setup Event scheduler in it, But after updating the values of “event_scheduler” in the parameter group, this values is not appearing in the Global
Why the MySQL event scheduler doesn't work on Aurora Serverless (and how to fix it with AWS Lambda)

Luckily we had a AWS Lambda stack in place using the Serverless framework, so decided to move the current MySQL events to scheduled Lambda functions. With the help of the Serverless Schedule event this was incredible easy:

functions:
  aggregate:
    handler: aggregate.handler
    events:
      - schedule: rate(4 hours)

So keep this in mind if your start looking into Aurora Serverless for your applications.

Hope it helps!