Skip to content

Commit

Permalink
[_562] release old connection when redirecting
Browse files Browse the repository at this point in the history
When data objects were opened on redirected host connections, the
old connection was being leaked (overwritten without being properly released.)
The accumulation of irods.Connection object in source iRODSSession's active pool
caused agents to pile up rather than closing down and exiting as they should.
Eventually this caused a failure to connect from the client.
  • Loading branch information
d-w-moore committed Jun 13, 2024
1 parent 9f22ee5 commit f4a6055
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions irods/manager/data_object_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ def make_FileOpenRequest(**extra_opts):
# This is the actual redirect.
directed_sess = self.sess.clone(host = redirected_host)
returned_values['session'] = directed_sess
conn.release()
conn = directed_sess.pool.get_connection()
logger.debug('redirect_to_host = %s', redirected_host)

Expand Down
20 changes: 20 additions & 0 deletions irods/test/data_obj_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2081,6 +2081,26 @@ def test_touch_operation_does_not_work_when_given_a_collection__525(self):
with self.assertRaises(ex.InvalidInputArgument):
user_session.data_objects.touch(home_collection_path)

def test_client_redirect_lets_go_of_connections__issue_562(self):
self._skip_unless_connected_to_local_computer_by_other_than_localhost_synonym()
# Force data object connections to redirect by enforcing a non-equivalent hostname for their resource
with self.create_simple_resc(hostname = 'localhost') as resc_name:
REPS_TO_REPRODUCE_CONNECT_ERROR = 100
paths=[]
try:
# Try to exhaust connections
for n in range(REPS_TO_REPRODUCE_CONNECT_ERROR):
data_path = '{self.coll_path}/issue_562_test_obj_{n:03d}.dat'.format(**locals())
paths.append(data_path)
with self.sess.data_objects.open(data_path, 'w', **{kw.DEST_RESC_NAME_KW: resc_name}) as f:
pass
finally:
# Clean up data objects before resource is deleted.
for data_path in paths:
if self.sess.data_objects.exists(data_path):
self.sess.data_objects.unlink(data_path, force = True)
else:
break

if __name__ == '__main__':
# let the tests find the parent irods lib
Expand Down

0 comments on commit f4a6055

Please sign in to comment.