[CONTROLLER-447] Concurrency Issue in NetconfDevice Created: 02/May/14  Updated: 19/Oct/17  Resolved: 23/Jun/14

Status: Resolved
Project: controller
Component/s: netconf
Affects Version/s: Helium
Fix Version/s: None

Type: Bug
Reporter: Devin Avery Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: Mac OS
Platform: PC


External issue ID: 945

 Description   

There are concurrency issues that were introduced with CONTROLLER-317 / gerrit 6253 in the NetconfDevice.java. Specifically, in the "bringUp" method we set the value of a number of class scoped variables, but those variables are not synchronized or volatile. This can result in a race condition with the other locations where these member variables are used.

See gerrit 6253 for one example.

Offending Code:

void bringUp(final SchemaSourceProvider<String> delegate, final Set<QName> capabilities, final boolean rollbackSupported) {
// This has to be called from separate thread, not from netty thread calling onSessionUp in DeviceListener.
// Reason: delegate.getSchema blocks thread when waiting for response
// however, if the netty thread is blocked, no incoming message can be processed
// ... netty should pick another thread from pool to process incoming message, but it does not http://netty.io/wiki/thread-model.html
// TODO redesign +refactor
processingExecutor.submit(new Runnable() {
@Override
public void run() {
NetconfDevice.this.rollbackSupported = rollbackSupported;
remoteSourceProvider = schemaSourceProvider.createInstanceFor(delegate);
deviceContextProvider = new NetconfDeviceSchemaContextProvider(NetconfDevice.this, remoteSourceProvider);
deviceContextProvider.createContextFromCapabilities(capabilities);
if (mountInstance != null && getSchemaContext().isPresent())

{ mountInstance.setSchemaContext(getSchemaContext().get()); }

updateDeviceState(true, capabilities);

if (mountInstance != null) {
confReaderReg = mountInstance.registerConfigurationReader(ROOT_PATH, NetconfDevice.this);
operReaderReg = mountInstance.registerOperationalReader(ROOT_PATH, NetconfDevice.this);
commitHandlerReg = mountInstance.registerCommitHandler(ROOT_PATH, NetconfDevice.this);

List<RpcRegistration> rpcs = new ArrayList<>();
// TODO same condition twice
if (mountInstance != null && getSchemaContext().isPresent()) {
for (RpcDefinition rpc : mountInstance.getSchemaContext().getOperations())

{ rpcs.add(mountInstance.addRpcImplementation(rpc.getQName(), NetconfDevice.this)); }

}
rpcReg = rpcs;
}
}
});
}



 Comments   
Comment by Maros Marsalek [ 10/Jun/14 ]

This problem should be fixed now, as https://bugs.opendaylight.org/show_bug.cgi?id=832 was merged into master. Please review the code for sal-netconf-connector in master.

Comment by Maros Marsalek [ 23/Jun/14 ]

Fixed by https://bugs.opendaylight.org/show_bug.cgi?id=832

Generated at Wed Feb 07 19:53:02 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.