Skip to content

Avoid deadlock on server shutdown #279

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

Merged
merged 2 commits into from
Sep 19, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 0 additions & 10 deletions mongodb_store/scripts/config_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@ def __init__(self):
else:
self._mongo_client=MongoClient(db_host, db_port)

rospy.on_shutdown(self._on_node_shutdown)

self._database=self._mongo_client.config
self._database.add_son_manipulator(MongoTransformer())

Expand Down Expand Up @@ -241,14 +239,6 @@ def _list_params(self):
print(name, " "*(30-len(name)),val," "*(30-len(str(val))),filename)
print()


def _on_node_shutdown(self):
try:
# PyMongo 2.9 or later
self._mongo_client.close()
except Exception as e:
self._mongo_client.disconnect()

# Could just use the ros parameter server to get the params
# but one day might not back onto the parameter server...
def _getparam_srv_cb(self,req):
Expand Down
2 changes: 1 addition & 1 deletion mongodb_store/scripts/mongodb_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,10 @@ def block_mongo_kill():
rospy.logerr("Mongo process error! Exit code="+str(self._mongo_process.returncode))

self._gone_down = True
self._ready=False

def _on_node_shutdown(self):
rospy.loginfo("Shutting down datacentre")
self._ready=False
if self._gone_down:
rospy.logwarn("It looks like Mongo already died. Watch out as the DB might need recovery time at next run.")
return
Expand Down
4 changes: 2 additions & 2 deletions mongodb_store/tests/config_manager.test
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<launch>
<include file="$(find mongodb_store)/launch/mongodb_store.launch">
<arg name="db_path" value="/tmp" />
<arg name="test_mode" value="true"/>
</include>
j

<!-- rosout and diagnostic topic logger -->
<!-- <node name="diagnostics_logger" pkg="strands_diagnostics" type="logger"/> -->

Expand Down