In this article, you will come to know the solution to RDS Mysql ERROR max-prepared-stmt-count exceeded on AWS RDS Aurora (Mysql Compatibility)

Basically, you will get this error in AWS Aurora Mysql when max_prepared_stmt_count exceed the default value “16382”.

Eg: SQLState: 42000 can’t create more than max_prepared_stmt_count statements (current value: 16382)

command to check max_prepared_stmt_count in RDS Mysql DB

Solutions to the max_prepared_stmt_count exceeded

  • Login to AWS Console and goto RDS Service
  • Select the RDS instance on which you are getting an error
  • Explore DB Parameter group which is attached to the RDS instance
  • In DB parameter group – search for max_prepared_stmt_count
    • This is used if the potential for denial-of-service attacks based on running the server out of memory by preparing huge numbers of statements.

You can change the value as per the requirement “set max_prepared_stmt_count”, better to take DB snapshot before applying these changes.

Know more what is max_prepared_stmt_count and default value set by AWS RDS is 16382 and you can increase it to 1048576.

RDS Mysql ERROR max-prepared-stmt-count exceeded

Do we need to reboot RDS Instance after DB Parameter modified?

If we increase/change “set max_prepared_stmt_count” property then there is two condition to reboot RDS instance as mention:

  • When you change a dynamic parameter and save the DB parameter group, the change is applied immediately regardless of the Apply Immediately setting.
  • When you change a static parameter and save the DB parameter group, the parameter change will take effect after you manually reboot the DB instance.

Note: “max_prepared_stmt_count” is a dynamic parameter

When you do the parameter value change/update and save it, you can see the db-parameter state is in “modifying” state and after 2-3mins it will come in-sync in this process RDS instance reboot not required.

This is the simple solution for RDS Mysql ERROR max-prepared-stmt-count exceeded.

Check out RDS SOLUTION TO TABLE FULL ERROR