Skip to content

Commit

Permalink
Merge pull request #53 from yugabyte/gh_23327
Browse files Browse the repository at this point in the history
[YugabyteDB plugin] Use single connection for both schema history table management and applying migrations
  • Loading branch information
piers-williams authored Aug 30, 2024
2 parents c5b80c6 + 1e7b343 commit 8c72dc2
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 8c72dc2

Please sign in to comment.