How can we help you today? How can we help you today?

Out of memory when flyway installs several migrations

Hello,
I'm using Flyway in a Spring Boot (3.0.9) application with about 100 migration files. The largest migration occupies 138 MB and the application has a Java heap space of 384 MB (-Xmx384m).

When I start the application with an empty database, Flyway can not execute all the migration because of Out of Memery exception (09:42:06.188 [restartedMain] DEBUG org.flywaydb.core.FlywayExecutor - Memory usage: 336 of 384M).
Instead, if some of the migrations are already istalled (approximately half) before the start up, Flyway executes the missing migrations and the application start correctly.

Analysing the heap dump of the OoM case I see that threre are a lot of istances of class org.flywaydb.core.internal.resolver.sql.SqlMigrationResolver.


Why is memory occupancy lower when the migrations are installed in two runs?

Is it possible that Flyway accumulates memory space for each installed migration?
If so, is there any configuration to avoid it?

Thank you in advance.


Versions:
Flyway Java API 9.5.1, Maven plugin 9.16.1, MySql 8.0

davide94
0

Comments

1 comment

  • DanC
    The issue was resolved directly in a support ticket, but for the benefit of anyone coming across this, the outcome was as follows:

     You can use the stream configuration to rectify this behavior
     
    Stream would make it so that each statement is loaded individually instead of the entire migration in memory at once, so that should decrease the memory usage: https://documentation.red-gate.com/fd/stream-184127543.html
    DanC
    0

Add comment

Please sign in to leave a comment.