title: Corda Drain mode does not prevent the flows to start
body: <p>Reading the documentation of Corda I thought that the drain mode should not allow any flows to be started on a node until the drain mode is disabled. However seems not to be the case, at least when I run my flows from a ServiceHub. Here is what I have tried:</p>
  <p>I run my cordapp with deployNodes task. In the corda shell I run <code>run setFlowsDrainingModeEnabled enabled: true</code>. Then I run a flow through ServiceHub which updates an existing state in that node, and without undraining the node I query vault and see that the state was successfully updated. So I am really confused. How does actually the draining works?</p>
  <p>What I really want to achieve is to create a small utility program to safely shutdown the node, or fail after some time of trying. here is the code:</p>
  <pre><code>class ShutdownOrFailHelper {
  
  private val sleepInterval = 1_000L
  private val maxSleepTimes = 120
  private var count = 0
  
  fun run(args: Array&lt;String&gt;) {
      val connection = RPCConnector().connect(args)
      val proxy = connection.proxy
      val nodeInfo = proxy.nodeInfo()
  
      proxy.setFlowsDrainingModeEnabled(true)
      do {
          val pendingSize = proxy.stateMachinesSnapshot().size
  
          if(pendingSize == 0){
              proxy.shutdown()
              println(&quot;Done&quot;)
              break
          }
          Thread.sleep(sleepInterval)
          count++
          println(&quot;$pendingSize flows are running. Waiting flows to finish on $nodeInfo&quot;)
  
          if(count &gt; maxSleepTimes){
              println(&quot;Node still has $pendingSize flows running. Give up waiting..&quot;)
              proxy.setFlowsDrainingModeEnabled(false)
              connection.notifyServerAndClose()
              exitProcess(1)
          }
      } while (pendingSize != 0)
  }}
  </code></pre>
  <p>But for this to work properly I need to make sure that after <code>proxy.setFlowsDrainingModeEnabled(true)</code> it is not possible to start any more flows, but actually even after this I am able to start flows. And I really don't understand what is the purpose of drain mode then...</p>