Skip to content

Commit

Permalink
Preparations for versioning in PSQL Connector
Browse files Browse the repository at this point in the history
Preparations for intermediate deployment phase1:
- Fix disabling phaseLock for OTA phase1

Signed-off-by: Benjamin Rögner <[email protected]>
  • Loading branch information
roegi committed Dec 13, 2022
1 parent 1a39632 commit ae2407e
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -915,18 +915,19 @@ public static int readVersionsToKeep(Event event) {
}

private boolean executeOneTimeAction(String phase, Map<String, Object> inputData) throws SQLException {
boolean phaseLock = "phase1".equals(phase) ? false : true;
try (final Connection connection = dataSource.getConnection()) {
logger.info("oneTimeAction " + phase + ": Starting execution ...");
if (_advisory(phase, connection, true, false)) {
if (!phaseLock || _advisory(phase, connection, true, false)) {
try {
switch (phase) {
case "phase0": {
oneTimeActionForVersioning(phase, inputData, connection, true);
oneTimeActionForVersioning(phase, inputData, connection);
break;
}
case "phase1": {
setupOneTimeActionFillNewColumns(phase, connection);
oneTimeActionForVersioning(phase, inputData, connection, false);
oneTimeActionForVersioning(phase, inputData, connection);
break;
}
case "phaseX": {
Expand All @@ -947,7 +948,8 @@ private boolean executeOneTimeAction(String phase, Map<String, Object> inputData
}
}
finally {
_advisory(phase, connection, false, false);
if (phaseLock)
_advisory(phase, connection, false, false);
}
return true;
}
Expand All @@ -972,7 +974,7 @@ private Map<String, Object> getDefaultInputDataForOneTimeAction(String phase) th
return Collections.emptyMap();
}

private void oneTimeActionForVersioning(String phase, Map<String, Object> inputData, Connection connection, boolean phaseLock) throws SQLException {
private void oneTimeActionForVersioning(String phase, Map<String, Object> inputData, Connection connection) throws SQLException {
if (inputData == null || !inputData.containsKey("tableNames") || !(inputData.get("tableNames") instanceof List))
throw new IllegalArgumentException("Table names have to be defined for OTA phase: " + phase);
List<String> tableNames = (List) inputData.get("tableNames");
Expand All @@ -989,7 +991,7 @@ private void oneTimeActionForVersioning(String phase, Map<String, Object> inputD
boolean tableCompleted = false;
logger.info(phase + ": process table: " + tableName);

if (!phaseLock || _advisory(tableName, connection, true, false)) {
if (_advisory(tableName, connection, true, false)) {
long tableStartTime = System.currentTimeMillis();
boolean cStateFlag = connection.getAutoCommit();
try {
Expand Down

0 comments on commit ae2407e

Please sign in to comment.