#50666 Add test for non-db files causing recovery issues
Closed 3 years ago by spichugi. Opened 4 years ago by firstyear.
firstyear/389-ds-base 50664-ds-can-fail-if-non-db-files  into  master

@@ -0,0 +1,48 @@ 

+ # --- BEGIN COPYRIGHT BLOCK ---

+ # Copyright (C) 2019 William Brown <william@blackhats.net.au>

+ # All rights reserved.

+ #

+ # License: GPL (version 3 or any later version).

+ # See LICENSE for details.

+ # --- END COPYRIGHT BLOCK ---

+ #

+ import os

+ import pytest

+ from lib389.topologies import topology_st

+ 

+ pytestmark = pytest.mark.tier1

+ 

+ def test_non_db_files_recovery(topology_st):

+     """In https://pagure.io/389-ds-base/issue/50664 it was

+     reported that when non-db files are present, this can prevent

+     the server from starting.

+ 

+     :id: be9ce986-dd1c-421f-af30-6e4bd39e953b

+     :setup: Single instance

+     :steps: 1. Kill the server with -9 to get to recovery

+             2. Add a non-db file or directory

+             3. Touch the guardian file to trigger the db recovery

+             4. Start the server

+     :expectedresults:

+             1. Server stops

+             2. File is created

+             3. File is created

+             4. Server starts

+     """

+ 

+     topology_st.standalone.unsafe_kill()

+ 

+     # Make the files

+     bogus_path = os.path.join(topology_st.standalone.ds_paths.db_dir, 'ldif')

+     os.makedirs(bogus_path)

+ 

+     guard_path = os.path.join(topology_st.standalone.ds_paths.db_dir, 'guardian')

+     with open(guard_path, 'w') as f:

+         pass

+ 

+     import time

+     print('attach now')

+     time.sleep(45)

+ 

+     topology_st.standalone.start()

+ 

empty or binary file added
@@ -1210,6 +1210,34 @@ 

                  os.kill(pid, signal.SIGKILL)

          self.state = DIRSRV_STATE_OFFLINE

  

+     def unsafe_kill(self):

+         '''

+         Forcefully end the DS process. This uses the kill -9 signal

+         which MAY cause the process to lose data or other such risks. You

+         should only use this when absolutely required!

+ 

+             @param self

+             @return None

+         '''

+         if self.status() is False:

+             return

+ 

+         if self.with_systemd():

+             self.log.debug("systemd status -> True")

+             # Do systemd things here ...

+             subprocess.check_call(["systemctl",

+                                    "kill",

+                                    "dirsrv@%s" % self.serverid])

+         else:

+             self.log.debug("systemd status -> False")

+             pid = pid_from_file(self.ds_paths.pid_file)

+             if pid == 0 or pid is None:

+                 raise ValueError("Failed to stop DS")

+             os.kill(pid, signal.SIGKILL)

+         self.log.debug("Killed ns-slapd process")

+         self.state = DIRSRV_STATE_OFFLINE

+ 

+ 

      def status(self):

          """

          Determine if an instance is running or not.

Closing because it's not possible to reproduce this deterministicly.

Pull-Request has been closed by firstyear

4 years ago

389-ds-base is moving from Pagure to Github. This means that new issues and pull requests
will be accepted only in 389-ds-base's github repository.

This pull request has been cloned to Github as issue and is available here:
- https://github.com/389ds/389-ds-base/issues/3721

If you want to continue to work on the PR, please navigate to the github issue,
download the patch from the attachments and file a new pull request.

Thank you for understanding. We apologize for all inconvenience.

Pull-Request has been closed by spichugi

3 years ago