Skip to content

Commit

Permalink
Fully deactivate a space during import (if indices are dropped) to pr…
Browse files Browse the repository at this point in the history
…event read access without indices

Signed-off-by: Benjamin Rögner <[email protected]>
  • Loading branch information
roegi committed Oct 17, 2024
1 parent 50e02da commit 9fdbcf7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

Expand Down Expand Up @@ -95,6 +96,8 @@ public void execute() throws SQLException, TooManyResourcesClaimed, WebClientExc
logger.info("No indices to found. None will be dropped for space " + getSpaceId());
}
else {
logger.info("[{}] Deactivating the space {} ...", getGlobalStepId(), getSpaceId());
hubWebClient().patchSpace(getSpaceId(), Map.of("active", false));
logger.info("Dropping the following indices for space " + getSpaceId() + ": " + indexes);
List<SQLQuery> dropQueries = buildSpaceTableDropIndexQueries(getSchema(db), indexes);
SQLQuery dropIndexesQuery = SQLQuery.join(dropQueries, ";");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import java.sql.SQLException;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

Expand Down Expand Up @@ -85,6 +86,12 @@ public void execute() throws WebClientException, SQLException, TooManyResourcesC
Space space = loadSpace(getSpaceId());
logger.info("Getting storage database for space {}", getSpaceId());
Database db = loadDatabase(space.getStorage().getId(), WRITER);

if (!space.isActive()) {
logger.info("[{}] Re-activating the space {} ...", getGlobalStepId(), getSpaceId());
hubWebClient().patchSpace(getSpaceId(), Map.of("active", true));
}

runReadQueryAsync(buildMarkForMaintenanceQuery(getSchema(db), getRootTableName(space)), db, calculateNeededAcus());
}

Expand Down

0 comments on commit 9fdbcf7

Please sign in to comment.