1
0
Fork 0

Don't re-open and close on shutdown

master
Philip O'Toole 9 months ago
parent 4697bdc560
commit 5f9c9aad2d

@ -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
}

@ -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),

@ -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()

Loading…
Cancel
Save