Fix bug causing bgsave/termsig flush failure if a snapshot flushed it
I came across an interesting scenario that led to the discovery of this bug: if a keyspace is created before a snapshot cycle and before termsig/bgsave, and then the snapshot cycle runs, then the subsequent runs of bgsave/termsig would fail. The reason behind this interesting bug turns out to be rather trivial. Since the `flush_full` routine, regardless of storage targets would untrip the PRELOAD switch, the snapshot target as expected untrips the switch. Now, this means that a tree re-init is not run by BGSAVE or save on termsig. As a consequence, while attempting to run bgsave/save on termsig, the new keyspace directories are not found, resulting in flush failure. This commit fixes it my simply checking if the target should untrip the switch or not. Tests for the same were addednext
parent
c4eaf3d182
commit
08cffa1d3f
@ -0,0 +1,14 @@
|
|||||||
|
[server]
|
||||||
|
host = "127.0.0.1"
|
||||||
|
port = 2007
|
||||||
|
noart = true
|
||||||
|
|
||||||
|
[snapshot]
|
||||||
|
every = 3600
|
||||||
|
atmost = 4
|
||||||
|
failsafe = true
|
||||||
|
|
||||||
|
[ssl]
|
||||||
|
key = "../key.pem"
|
||||||
|
chain = "../cert.pem"
|
||||||
|
port = 2008
|
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* Created on Tue Mar 29 2022
|
||||||
|
*
|
||||||
|
* This file is a part of Skytable
|
||||||
|
* Skytable (formerly known as TerrabaseDB or Skybase) is a free and open-source
|
||||||
|
* NoSQL database written by Sayan Nandan ("the Author") with the
|
||||||
|
* vision to provide flexibility in data modelling without compromising
|
||||||
|
* on performance, queryability or scalability.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2022, Sayan Nandan <ohsayan@outlook.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
use sky_macros::dbtest_func as dbtest;
|
||||||
|
use skytable::{query, Element, RespCode};
|
||||||
|
|
||||||
|
const SNAPSHOT_DISABLED: &str = "err-snapshot-disabled";
|
||||||
|
|
||||||
|
#[dbtest]
|
||||||
|
async fn test_snapshot_local_disabled() {
|
||||||
|
runeq!(
|
||||||
|
con,
|
||||||
|
query!("mksnap"),
|
||||||
|
Element::RespCode(RespCode::ErrorString(SNAPSHOT_DISABLED.to_owned()))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[dbtest(skip_if_cfg = "persist-suite")]
|
||||||
|
async fn test_snapshot_remote_okay() {
|
||||||
|
assert_okay!(con, query!("mksnap", "myremote"))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[dbtest(port = 2007)]
|
||||||
|
async fn test_snapshot_local_okay() {
|
||||||
|
assert_okay!(con, query!("mksnap"))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[dbtest(port = 2007, skip_if_cfg = "persist-suite")]
|
||||||
|
async fn test_snapshot_remote_okay_with_local_enabled() {
|
||||||
|
assert_okay!(con, query!("mksnap", "myremote"))
|
||||||
|
}
|
Loading…
Reference in New Issue