Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DAOS-3885 test: Fix crash in shutdown and try dmg shutdown in NLT #4022

Merged
merged 7 commits into from
Jan 5, 2021
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ci/unit/test_main_node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ if grep /mnt/daos\ /proc/mounts; then
fi
sudo mkdir -p /mnt/daos

sudo mount -t tmpfs -o size=16G tmpfs /mnt/daos
sudo mkdir -p "$DAOS_BASE"
sudo mount -t nfs "$HOSTNAME":"$HOSTPWD" "$DAOS_BASE"
sudo cp "$DAOS_BASE/install/bin/daos_admin" /usr/bin/daos_admin
Expand Down Expand Up @@ -46,8 +45,10 @@ fi
cd "$DAOS_BASE"
if ${NLT:-false}; then
mkdir -p vm_test
# NLT will mount /mnt/daos itself.
./utils/node_local_test.py --output-file=vm_test/nlt-errors.json all
else
sudo mount -t tmpfs -o size=16G tmpfs /mnt/daos
IS_CI=true OLD_CI=false RUN_TEST_VALGRIND="$WITH_VALGRIND" utils/run_test.sh

if [ "$WITH_VALGRIND" == 'memcheck' ]; then
Expand Down
4 changes: 4 additions & 0 deletions src/rdb/rdb_raft.c
Original file line number Diff line number Diff line change
Expand Up @@ -2558,6 +2558,10 @@ rdb_raft_resign(struct rdb *db, uint64_t term)
struct rdb_raft_state state;
int rc;

if (db == NULL) {
D_ERROR("db cannot be NULL\n");
return;
}
ABT_mutex_lock(db->d_raft_mutex);
if (term != raft_get_current_term(db->d_raft) ||
!raft_is_leader(db->d_raft)) {
Expand Down
2 changes: 1 addition & 1 deletion utils/nlt_server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ servers:
- FI_SOCKETS_CONN_TIMEOUT=2000
scm_mount: /mnt/daos
scm_class: ram
scm_size: 4
scm_size: 32
52 changes: 44 additions & 8 deletions utils/node_local_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,7 @@ def start(self):
server_env['PATH'])

cmd = [daos_server, '--config={}'.format(self._yaml_file.name),
'start', '-t' '4', '--insecure', '-d', self.agent_dir,
'--recreate-superblocks']
'start', '-t' '4', '--insecure', '-d', self.agent_dir]

server_env['DAOS_DISABLE_REQ_FWD'] = '1'
self._sp = subprocess.Popen(cmd, env=server_env)
Expand All @@ -384,14 +383,31 @@ def start(self):

# Use dmg to block until the server is ready to respond to requests.
start = time.time()

while True:
time.sleep(0.5)
rc = self.run_dmg(['storage', 'format'])
ready = False
if rc.returncode == 1:
for line in rc.stdout.decode('utf-8').splitlines():
if 'format storage of running instance' in line:
ready = True

if ready:
break
if time.time() - start > 20:
raise Exception("Failed to format")

print('Format completion in {:.2f} seconds'.format(time.time() - start))

while True:
time.sleep(0.5)
rc = self.run_dmg(['system', 'query'])
ready = False
if rc.returncode == 0:
for line in rc.stdout.decode('utf-8').splitlines():
if line.startswith('status'):
if 'Ready' in line or 'Joined' in line:
if 'Joined' in line:
ready = True

if ready:
Expand All @@ -409,6 +425,28 @@ def stop(self):

if not self._sp:
return
rc = self.run_dmg(['system', 'stop'])
assert rc.returncode == 0

start = time.time()
while True:
time.sleep(0.5)
rc = self.run_dmg(['system', 'query'])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, I am changing this in my PR to use JSON output instead of doing string matching: https://github.com/daos-stack/daos/pull/4064/files#diff-74f1d143169d1655c88e727ed677f50cb035b054c6fc1ace2c615b3c91210725R392

We should probably pull the run_dmg()/json.loads() into a helper that appends the --json argument and parses the response.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth knowing. This code still uses the --recreate-superblocks option so does need updating.

I still can't get daos to stop though, it seems to return "Stopping" continuously and never progress to "Stopped" so I almost left out this part of the PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. I think we may have a regression here that wasn't noticed because we haven't been using stop without --force. @tanabarr, please take a look at this. I tried Ashley's PR on master and on your latest events branch and in both cases the second instance on my system never moved from stopping->stopped. I can also see that there is still a daos_io_server process running.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without the other change in this PR daos_io_server would probably segfault, and therefore wouldn't be running afterwards, although I doubt that's how we intend it to work.

Copy link
Contributor

@tanabarr tanabarr Dec 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of stop without force normally results in errored state but this PR catches the segfault as Ashley has mentioned, the behaviour you are describing is an artifact of suppressing that. happy to look into it further if you could raise a ticket and assign to me. I've worked with Ashley and we've got this PR working now without the use of recreate-superblocks.

ready = False
if rc.returncode == 0:
for line in rc.stdout.decode('utf-8').splitlines():
if line.startswith('status'):
if 'Stopped' in line:
ready = True
if 'Stopping' in line:
ready = True

if ready:
break
if time.time() - start > 20:
print('Failed to stop')
break
print('Server stopped in {:.2f} seconds'.format(time.time() - start))

# daos_server does not correctly shutdown daos_io_server yet
# so find and kill daos_io_server directly. This may cause
Expand Down Expand Up @@ -458,10 +496,6 @@ def stop(self):
except ProcessLookupError:
pass

# Workaround for DAOS-5648
if ret == 2:
ret = 0

# Show errors from server logs bug suppress memory leaks as the server
# often segfaults at shutdown.
if os.path.exists(self._log_file):
Expand All @@ -477,7 +511,9 @@ def run_dmg(self, cmd):
exe_cmd.append('--insecure')
exe_cmd.extend(cmd)

return subprocess.run(exe_cmd, stdout=subprocess.PIPE)
return subprocess.run(exe_cmd,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)

def il_cmd(dfuse, cmd, check_read=True, check_write=True):
"""Run a command under the interception library
Expand Down