Files
scylladb/service
Pavel Solodovnikov bcbcc18aa1 raft: raft_sys_table_storage: fix broken load_snapshot and load_term_and_vote
Loading snapshot id and term + vote involve selecting static
fields from the "system.raft" table, constrained by a given
group id.

The code incorrectly assumes that, for example,
`SELECT snapshot_id FROM raft WHERE group_id=?` in
`load_snapshot` always returns  only one row.
This is not true, since this will return a row
for each (pk, ck) combination, which is (group_id, index)
for "system.raft" table.

The same applies for the `load_term_and_vote`, which selects
static `vote_term` and `vote` from "system.raft".

This results in a crash at node startup when there is
a non-empty raft log containing more than one entry
for a given `group_id`.

Restrict the selection to always return one row by applying
`LIMIT 1` clause.

Tests: unit(dev)

Signed-off-by: Pavel Solodovnikov <pa.solodovnikov@scylladb.com>
Message-Id: <20210723183232.742083-1-pa.solodovnikov@scylladb.com>
2021-07-25 02:01:34 +02:00
..