Improve MIBUpdater to re-connect DBConnector when re-init data.#290
Merged
liuh-80 merged 10 commits intosonic-net:masterfrom Oct 30, 2023
Merged
Improve MIBUpdater to re-connect DBConnector when re-init data.#290liuh-80 merged 10 commits intosonic-net:masterfrom
liuh-80 merged 10 commits intosonic-net:masterfrom
Conversation
Contributor
Author
|
Pipeline build break, already create a fix PR. pending for #293 merge first |
Contributor
Author
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
qiluo-msft
reviewed
Sep 28, 2023
qiluo-msft
reviewed
Oct 9, 2023
src/ax_interface/mib.py
Outdated
|
|
||
| # run the background update task | ||
| self.update_data() | ||
| self.redis_exception_happen = False |
Contributor
There was a problem hiding this comment.
Contributor
Author
There was a problem hiding this comment.
Fixed, move redis_exception_happen to local variable. also because the python method override issue, add new method reinit_connection() to MIBUpdater interface.
qiluo-msft
reviewed
Oct 22, 2023
src/ax_interface/mib.py
Outdated
| if self.update_counter > self.reinit_rate: | ||
| # reconnect when redis exception happen | ||
| if redis_exception_happen: | ||
| self.reinit_connection() |
Contributor
There was a problem hiding this comment.
[](http://example.com/codeflow?start=24&length=4)
You can remove one extra level of indentation. #Closed
qiluo-msft
approved these changes
Oct 28, 2023
ssithaia-ebay
pushed a commit
to ssithaia-ebay/sonic-snmpagent
that referenced
this pull request
May 23, 2025
…c-net#290) Improve MIBUpdater to re-connect DBConnector when re-init data. #### Work item tracking Microsoft ADO (number only): 24705208 **- What I did** Fix when redis restart, some MIBUpdater's db connection will broken and keeps report error to syslog issue. There will be following message repeat in syslog: ``` sonic-net#12 File "/usr/local/lib/python3.7/dist-packages/sonic_ax_impl/mibs/ietf/rfc2737.py", line 674, in _update_per_namespace_data# sonic-net#12 msg = pubsub.get_message()# sonic-net#12 File "/usr/lib/python3/dist-packages/swsscommon/swsscommon.py", line 1626, in get_message# sonic-net#12 return _swsscommon.PubSub_get_message(self, timeout)# #012RuntimeError: RedisError: Failed to select, err=3: errstr=Server closed the connection ``` **- How I did it** Re-connect DBConnector in every MIBUpdater's reinit_data method. **- How to verify it** Pass all UT Manually test with following steps: 1. in database container kill redis server. 2. start redis in database container later: service redis-server start 2. check syslog, confirm following log exist but now new log few minutes later after mibs re-init: sudo cat /var/log/syslog | grep rfc2737.py | grep PubSub_get_message Sep 22 03:30:17.223944 vlab-01 ERR snmp#snmp-subagent [ax_interface] ERROR: MIBUpdater.start() caught an unexpected exception during update_data()#012Traceback (most recent call last):sonic-net#12 File "/usr/local/lib/python3.9/dist-packages/ax_interface/mib.py", line 43, in start#012 self.update_data()sonic-net#12 File "/usr/local/lib/python3.9/dist-packages/sonic_ax_impl/mibs/ietf/rfc2737.py", line 326, in update_data#012 updater.update_data(i, self.statedb[i])sonic-net#12 File "/usr/local/lib/python3.9/dist-packages/sonic_ax_impl/mibs/ietf/rfc2737.py", line 666, in update_data#012 self._update_per_namespace_data(self.pub_sub_dict[db_index])sonic-net#12 File "/usr/local/lib/python3.9/dist-packages/sonic_ax_impl/mibs/ietf/rfc2737.py", line 675, in _update_per_namespace_data#012 msg = pubsub.get_message()sonic-net#12 File "/usr/lib/python3/dist-packages/swsscommon/swsscommon.py", line 1996, in get_message#012 return _swsscommon.PubSub_get_message(self, timeout, interrupt_on_signal)#012RuntimeError: RedisError: Failed to select, err=3: errstr=Server closed the connection **- Description for the changelog** Improve MIBUpdater to re-connect DBConnector when re-init data.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Improve MIBUpdater to re-connect DBConnector when re-init data.
Work item tracking
Microsoft ADO (number only): 24705208
- What I did
Fix when redis restart, some MIBUpdater's db connection will broken and keeps report error to syslog issue.
There will be following message repeat in syslog:
- How I did it
Re-connect DBConnector in every MIBUpdater's reinit_data method.
- How to verify it
Pass all UT
Manually test with following steps:
sudo cat /var/log/syslog | grep rfc2737.py | grep PubSub_get_message
Sep 22 03:30:17.223944 vlab-01 ERR snmp#snmp-subagent [ax_interface] ERROR: MIBUpdater.start() caught an unexpected exception during update_data()#012Traceback (most recent call last):#12 File "/usr/local/lib/python3.9/dist-packages/ax_interface/mib.py", line 43, in start#012 self.update_data()#12 File "/usr/local/lib/python3.9/dist-packages/sonic_ax_impl/mibs/ietf/rfc2737.py", line 326, in update_data#012 updater.update_data(i, self.statedb[i])#12 File "/usr/local/lib/python3.9/dist-packages/sonic_ax_impl/mibs/ietf/rfc2737.py", line 666, in update_data#012 self._update_per_namespace_data(self.pub_sub_dict[db_index])#12 File "/usr/local/lib/python3.9/dist-packages/sonic_ax_impl/mibs/ietf/rfc2737.py", line 675, in _update_per_namespace_data#012 msg = pubsub.get_message()#12 File "/usr/lib/python3/dist-packages/swsscommon/swsscommon.py", line 1996, in get_message#012 return _swsscommon.PubSub_get_message(self, timeout, interrupt_on_signal)#012RuntimeError: RedisError: Failed to select, err=3: errstr=Server closed the connection
- Description for the changelog
Improve MIBUpdater to re-connect DBConnector when re-init data.