mirror of
https://github.com/scylladb/scylladb.git
synced 2026-05-31 03:56:42 +00:00
repair: job id must start at 1
This patch fixes a bug where the *first* run of "nodetool repair" always returned immediately, instead of waiting for the repair to complete. Repair operations are asynchronous: Starting a repair returns a numeric id, which can then be used to query for the repair's completion, and this is what "nodetool repair" does (through our JMX layer). We started with the repair ID "0", the next one is "1", and so on. The problem is that "nodetool repair", when it sees 0 being returned, treats it not as a regular repair ID, but rather as an answer that there is nothing to repair - printing a message to that effect and *not* waiting for the repair (which was correctly started) to complete. The trivial fix is to start our repair IDs at 1, instead of 0. We currently do not return 0 in any case (we don't know there is nothing to repair before we actually start the work, and parameter errors cause an exception, not a return of 0). Signed-off-by: Nadav Har'El <nyh@scylladb.com>
This commit is contained in:
@@ -147,7 +147,9 @@ static class {
|
||||
private:
|
||||
// Each repair_start() call returns a unique int which the user can later
|
||||
// use to follow the status of this repair with repair_status().
|
||||
int _next_repair_command = 0;
|
||||
// We can't use the number 0 - if repair_start() returns 0, it means it
|
||||
// decide quickly that there is nothing to repair.
|
||||
int _next_repair_command = 1;
|
||||
// Note that there are no "SUCCESSFUL" entries in the "status" map:
|
||||
// Successfully-finished repairs are those with id < _next_repair_command
|
||||
// but aren't listed as running or failed the status map.
|
||||
@@ -325,6 +327,10 @@ static int do_repair_start(seastar::sharded<database>& db, sstring keyspace,
|
||||
|
||||
repair_options options(options_map);
|
||||
|
||||
// Note: Cassandra can, in some cases, decide immediately that there is
|
||||
// nothing to repair, and return 0. "nodetool repair" prints in this case
|
||||
// that "Nothing to repair for keyspace '...'". We don't have such a case
|
||||
// yet. Real ids returned by next_repair_command() will be >= 1.
|
||||
int id = repair_tracker.next_repair_command();
|
||||
logger.info("starting user-requested repair for keyspace {}, repair id {}", keyspace, id);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user