-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sqlite locks when attempting a migration result in SQLException: [SQLITE_BUSY] #1499
Comments
Created repository containing an example. |
Possibly related to #1318 and #1180. As a workaround, I tried creating a wrapper DataSource that uses an underlying SQLiteDataSource but returns the same connection each time getConnection() is called unless that connection is closed. The migration appears to proceed as expected when this wrapper is provided, though I'm not familiar enough with Flyway to know if it will have any side effects. This is not thread safe but seems fine otherwise. Sample: public class WorkaroundDataSource implements DataSource {
private final SQLiteDataSource dataSource;
private Connection connection;
public WorkaroundDataSource(SQLiteDataSource dataSource) {
this.dataSource = dataSource;
}
@Override
public Connection getConnection() throws SQLException {
if (connection == null || connection.isClosed()) {
this.connection = dataSource.getConnection();
}
return connection;
}
// other methods passed through to dataSource
// ...
} |
Thanks for the investigation. Truly appreciated! We used to only force the use of a single connection when using our own datasource via We have now fixed this to work with any datasource. |
No worries, workaround will do us for now but looking forward to the next update. |
What version of Flyway are you using?
4.0.3
Which client are you using? (Command-line, Java API, Maven plugin, Gradle plugin, SBT plugin, ANT tasks)
Java API
What database are you using (type & version)?
SQLite Xerial JDBC driver 3.8.11.2
What operating system are you using?
Windows 10 64-bit
What did you do?
(Please include the content causing the issue, any relevant configuration settings, and the command you ran)
Attempted a migration that included table creation, using a flyway object with DataSource set to preconfigured org.sqlite.SQLiteDataSource. No other processes using the database as far as I am aware:
Test migration script
V2__test.sql
:What did you expect to see?
Successful migration to v2
What did you see instead?
The following exception:
The text was updated successfully, but these errors were encountered: