-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lighten the load on Cassandra backend with less repair_run scans
Reaper checks the running and paused repair runs every 10 to 30 seconds to perform maintenance operations. When the repair history starts growing, Reaper will scan them all to look for running/paused repairs because the repair_run_by_cluster table doesn't contain the repair run state. This commit adds this column, which allows to filter runs early in the process instead of scanning them all in the repair_run table. Filter runs by state in the repair_run_by_state table to avoid reading them all from the repair_run table. Push limit from the UI to the DAO to avoid reading more repair runs from the database than required.
- Loading branch information
1 parent
fca00c4
commit 2a676b0
Showing
12 changed files
with
198 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
src/server/src/main/java/io/cassandrareaper/storage/cassandra/Migration025.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright 2019-2019 The Last Pickle Ltd | ||
* | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.cassandrareaper.storage.cassandra; | ||
|
||
|
||
import com.datastax.driver.core.PreparedStatement; | ||
import com.datastax.driver.core.ResultSet; | ||
import com.datastax.driver.core.Row; | ||
import com.datastax.driver.core.Session; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public final class Migration025 { | ||
|
||
private static final Logger LOG = LoggerFactory.getLogger(Migration025.class); | ||
private static final String V1_TABLE = "repair_run_by_cluster"; | ||
private static final String V2_TABLE = "repair_run_by_cluster_v2"; | ||
private static PreparedStatement v2_insert; | ||
|
||
private Migration025() { | ||
} | ||
|
||
/** | ||
* Switch to v2 of repair_run_by_cluster | ||
*/ | ||
public static void migrate(Session session, String keyspace) { | ||
|
||
try { | ||
if (session.getCluster().getMetadata().getKeyspace(keyspace).getTable(V1_TABLE) != null) { | ||
v2_insert = session.prepare( | ||
"INSERT INTO " + V2_TABLE + "(cluster_name, id, repair_run_state) values (?, ?, ?)"); | ||
LOG.info("Converting {} table...", V1_TABLE); | ||
ResultSet results = session.execute("SELECT * FROM " + V1_TABLE); | ||
for (Row row:results) { | ||
String state = session.execute("SELECT distinct state from repair_run where id = " + row.getUUID("id")).one() | ||
.getString("state"); | ||
session.execute(v2_insert.bind(row.getString("cluster_name"), row.getUUID("id"), state)); | ||
} | ||
session.execute("DROP TABLE " + V1_TABLE); | ||
} | ||
} catch (RuntimeException e) { | ||
LOG.error("Failed transferring rows to " + V2_TABLE, e); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.