Skip to content
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

[YugabyteDB plugin] Use single connection for both schema history table management and applying migrations #53

Merged
merged 1 commit into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading