[SNMP-2] ConcurrentModificationException warnings during walk, incomplete data retrieved Created: 01/Jul/15 Updated: 19/Oct/17 Resolved: 12/Jul/15 |
|
| Status: | Resolved |
| Project: | snmp |
| Component/s: | General |
| Affects Version/s: | unspecified |
| Fix Version/s: | None |
| Type: | Bug | ||
| Reporter: | Jon Rosenberger | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Operating System: All |
||
| Attachments: |
|
| External issue ID: | 3921 |
| Priority: | High |
| Description |
|
Calls to snmpGet with input type GETWALK return partial results when the result set is large enough. The problem is only seen in queries that require a number of seconds to execute. No error is returned, but results are incomplete. Caller has no way to know they are incomplete. Logs contain many stack traces logged as WARN, below. Attached test case reproduces the problem consistently. It connects to a real server. Any server/oid combination returning a sizable result set should suffice to reproduce this issue. [Timer-0] WARN org.opendaylight.snmp.plugin.internal.AsyncGetHandler - Error parsing response |
| Comments |
| Comment by Jon Rosenberger [ 01/Jul/15 ] |
|
Attachment testWalkRemote.rtf has been added with description: test case to reproduce issue |
| Comment by Jon Rosenberger [ 01/Jul/15 ] |
|
The problem: Everything works for several seconds, but then snmp4j begins sending response events to AsyncGetHandler.onResponse() containing null responses, immediately after requests are made. These are not timeouts; the correct data does arrive after several ms in a separate event as expected. The issue is resolved by adding to the top of onResponse: // acknowledge receipt of the event which is recommended by the API docs: public void onResponse(ResponseEvent event) { // Always cancel async request when response has been received // otherwise a memory leak is created! Not canceling a request // immediately can be useful when sending a request to a broadcast // address. ((Snmp)event.getSource()).cancel(event.getRequest(), this); System.out.println("Received response PDU is: "+event.getResponse()); }see http://www.snmp4j.org/doc/org/snmp4j/Snmp.html This causes the handler to call setResult. Events continue to arrive however, resulting in the ConcurrentModificationException. |
| Comment by Jon Rosenberger [ 01/Jul/15 ] |
|
Attached patch resolves the issue. It also adds error logging so that the problem can be seen as it happens, rather than downstream (in this case the ConcurrentModificationException was not the root cause). This will help in other cases where the response is null (timeouts). |
| Comment by Jon Rosenberger [ 01/Jul/15 ] |
|
Attachment file_3921.txt has been added with description: patch to resolve issue |