Skip to content

Commit 8c72dc2

Browse files
Merge pull request #53 from yugabyte/gh_23327
[YugabyteDB plugin] Use single connection for both schema history table management and applying migrations
2 parents c5b80c6 + 1e7b343 commit 8c72dc2

File tree

2 files changed

+4
-13
lines changed

2 files changed

+4
-13
lines changed

flyway-database-yugabytedb/src/main/java/org/flywaydb/community/database/postgresql/yugabytedb/YugabyteDBDatabase.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,18 +77,9 @@ public String getRawCreateScript(Table table, boolean baseline) {
7777
"CREATE INDEX IF NOT EXISTS \"" + table.getName() + "_s_idx\" ON " + table + " (\"success\");";
7878
}
7979

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

9485
private void createLockTable() {

flyway-database-yugabytedb/src/main/java/org/flywaydb/community/database/postgresql/yugabytedb/YugabyteDBExecutionTemplate.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88
import org.flywaydb.core.internal.util.FlywayDbWebsiteLinks;
99

1010
import java.sql.*;
11-
import java.util.HashMap;
11+
import java.util.Map;
1212
import java.util.concurrent.Callable;
13+
import java.util.concurrent.ConcurrentHashMap;
1314

1415
@CustomLog
1516
public class YugabyteDBExecutionTemplate {
1617

1718
private final JdbcTemplate jdbcTemplate;
1819
private final String tableName;
19-
private final HashMap<String, Boolean> tableEntries = new HashMap<>();
20-
20+
private static final Map<String, Boolean> tableEntries = new ConcurrentHashMap<>();
2121

2222
YugabyteDBExecutionTemplate(JdbcTemplate jdbcTemplate, String tableName) {
2323
this.jdbcTemplate = jdbcTemplate;

0 commit comments

Comments
 (0)