Uploaded image for project: 'controller'
  1. controller
  2. CONTROLLER-447

Concurrency Issue in NetconfDevice

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • Resolution: Done
    • Helium
    • None
    • netconf
    • None
    • Operating System: Mac OS
      Platform: PC

    • 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;
      }
      }
      });
      }

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            Unassigned Unassigned
            devin.avery@brocade.com Devin Avery
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: