Skip to content

Commit

Permalink
Merge pull request #32 from aiven/orange-avoid-fd-spike
Browse files Browse the repository at this point in the history
Avoid FD spike after retrying KafkaAdminClient
  • Loading branch information
aiven-anton committed Aug 8, 2024
2 parents 19ff1f4 + dfe42d0 commit e0ab864
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions kafka/admin/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,20 @@ def __init__(self, **configs):
metric_group_prefix='admin',
**self.config
)
self._client.check_version(timeout=(self.config['api_version_auto_timeout_ms'] / 1000))

# Get auto-discovered version from client if necessary
if self.config['api_version'] is None:
self.config['api_version'] = self._client.config['api_version']

self._closed = False
self._refresh_controller_id()
try:
self._client.check_version(timeout=(self.config['api_version_auto_timeout_ms'] / 1000))

# Get auto-discovered version from client if necessary
if self.config['api_version'] is None:
self.config['api_version'] = self._client.config['api_version']

self._closed = False
self._refresh_controller_id()
except Exception:
self._metrics.close()
self._client.close() # prevent FD leak
self._closed = True
raise
log.debug("KafkaAdminClient started.")

def close(self):
Expand Down

0 comments on commit e0ab864

Please sign in to comment.