From 5f9c9aad2d560b21732bf6a22373ae42fadfc0d2 Mon Sep 17 00:00:00 2001 From: Philip O'Toole Date: Mon, 18 Dec 2023 09:58:32 -0500 Subject: [PATCH] Don't re-open and close on shutdown --- store/store.go | 12 ------------ system_test/e2e/helpers.py | 6 +++--- system_test/e2e/single_node.py | 10 ++++++++++ 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/store/store.go b/store/store.go index 6c01de87..0123810b 100644 --- a/store/store.go +++ b/store/store.go @@ -608,18 +608,6 @@ func (s *Store) Close(wait bool) (retErr error) { if err := s.boltStore.Close(); err != nil { return err } - - // Open-and-close again to remove the -wal file. This is not - // strictly necessary, since any on-disk database files will be removed when - // rqlite next starts, but it leaves the directory containing the database - // file in a cleaner state. - walDB, err := sql.Open(s.dbPath, s.dbConf.FKConstraints, true) - if err != nil { - return err - } - if err := walDB.Close(); err != nil { - return err - } return nil } diff --git a/system_test/e2e/helpers.py b/system_test/e2e/helpers.py index fa1a3758..479f827d 100644 --- a/system_test/e2e/helpers.py +++ b/system_test/e2e/helpers.py @@ -82,7 +82,7 @@ def raise_for_status(r): raise e class Node(object): - def __init__(self, path, node_id, + def __init__(self, exe_path, node_id, api_addr=None, api_adv=None, bootstrap_expect=0, raft_addr=None, raft_adv=None, @@ -105,7 +105,7 @@ class Node(object): if dir is None: dir = tempfile.mkdtemp() self.dir = dir - self.path = path + self.exe_path = exe_path self.peers_path = os.path.join(self.dir, "raft/peers.json") self.node_id = node_id self.api_addr = api_addr @@ -168,7 +168,7 @@ class Node(object): if self.process is not None: return - command = [self.path, + command = [self.exe_path, '-node-id', self.node_id, '-http-addr', self.api_addr, '-bootstrap-expect', str(self.bootstrap_expect), diff --git a/system_test/e2e/single_node.py b/system_test/e2e/single_node.py index 3c807c7e..1df50edc 100644 --- a/system_test/e2e/single_node.py +++ b/system_test/e2e/single_node.py @@ -25,6 +25,16 @@ class TestSingleNode(unittest.TestCase): def tearDown(self): self.cluster.deprovision() + def test_no_wal_on_shutdown(self): + '''Test that a node does not have a WAL file after graceful shutdown''' + n = self.cluster.wait_for_leader() + n.execute('CREATE TABLE foo (id INTEGER NOT NULL PRIMARY KEY, name TEXT)') + self.assertTrue(os.path.exists(n.db_path())) + self.assertTrue(os.path.exists(n.wal_path())) + n.stop(graceful=True) + self.assertTrue(os.path.exists(n.db_path())) + self.assertFalse(os.path.exists(n.wal_path())) + def test_simple_raw_queries(self): '''Test simple queries work as expected''' n = self.cluster.wait_for_leader()