Skip to content

Commit

Permalink
Use single connection for both schema history table management and ap…
Browse files Browse the repository at this point in the history
…plying migrations
  • Loading branch information
ashetkar committed Aug 9, 2024
1 parent c5b80c6 commit 1e7b343
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,9 @@ public String getRawCreateScript(Table table, boolean baseline) {
"CREATE INDEX IF NOT EXISTS \"" + table.getName() + "_s_idx\" ON " + table + " (\"success\");";
}

/**
* YugabyteDB does not support PG Advisor Locks. So the YugabyteDB plugin
* employs SELECT ... FOR UPDATE in a transaction to implement locking for
* Flyway operations instead of the PG Advisory locks. If a single
* connection is used, it may cause issues if multiple threads execute
* begin/commit on it for Flyway operations. Returning false from this
* method ensures the same connection is not used for migrations.
* @return false
*/
@Override
public boolean useSingleConnection() {
return false;
return true;
}

private void createLockTable() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
import org.flywaydb.core.internal.util.FlywayDbWebsiteLinks;

import java.sql.*;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentHashMap;

@CustomLog
public class YugabyteDBExecutionTemplate {

private final JdbcTemplate jdbcTemplate;
private final String tableName;
private final HashMap<String, Boolean> tableEntries = new HashMap<>();

private static final Map<String, Boolean> tableEntries = new ConcurrentHashMap<>();

YugabyteDBExecutionTemplate(JdbcTemplate jdbcTemplate, String tableName) {
this.jdbcTemplate = jdbcTemplate;
Expand Down

0 comments on commit 1e7b343

Please sign in to comment.