• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ERROR: Failed to call 'Add' method: Write lock may not be acquired with read lock...

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    ERROR: Failed to call 'Add' method: Write lock may not be acquired with read lock...

    Okay,

    I am making progress but wanted to make sure I tracked down my newest issue. I started to "Freeze()" brushes and some issues cleared up, but seems like I have a new one:

    Code:
      ERROR: Failed to call 'Add' method: Write lock may not be acquired with read lock held. This pattern is prone to deadlocks. Please ensure that read locks are released before taking a write lock. If an upgrade is necessary, use an upgrade lock in place of the read lock.
    Not sure what to do about this issue.

    #2
    Just a little more detail,

    I seem to find this happens when "Orders" go through and try to draw the update of the Order Market on the screen. Hopefully this helps get the development team closer to the issue.

    Comment


      #3
      Thanks for the info - ultimately we would need to be able to reproduce this bug to resolve.

      I'm not quite sure what you mean by "order market on the screen". Can you clarify or provide examples?
      MatthewNinjaTrader Product Management

      Comment


        #4
        Originally posted by NinjaTrader_Matthew View Post
        Thanks for the info - ultimately we would need to be able to reproduce this bug to resolve.

        I'm not quite sure what you mean by "order market on the screen". Can you clarify or provide examples?
        Sorry,

        Market should have been Marker. Seems like when an order is processed and displayed.

        Comment


          #5
          The error is related to loading a bars series - Are you running/loading/reloading any scripts that call multiple time frames when this happens?
          MatthewNinjaTrader Product Management

          Comment


            #6
            Nope,

            The only thing that may have happened is an active strategy may have executed a position. It sometimes happened if I manually executed an order on the DOM or Chart Trader.

            It seems like it was something happening on the chart when the order was placed and the entry/exit position was drawn on the chart. Maybe there are Pens/Brushes that need to be frozen.

            It would be good if you guys could create a BETA3 with the FREEZING corrected as some issues we are chasing intermittently might be related to built in resources not being frozen.

            Comment


              #7
              Thanks, we will keep an eye out for this error your reported.

              Beta 3 will not have any "fixes" related to the brush freezing/access UI objects, but will include more specfic logging under that scenario.
              MatthewNinjaTrader Product Management

              Comment


                #8
                Hi Matt,

                Just for clarification, did the design team lock down their own brushes & pens to remove that variable from the mix?

                Comment


                  #9
                  Originally posted by NJA_MC View Post
                  Hi Matt,

                  Just for clarification, did the design team lock down their own brushes & pens to remove that variable from the mix?
                  If you're asking if our brushes/pens are frozen, they should have been even in B1. If you have a case where you're getting errors and they're not from your custom resources it would be a bug that needs to be reported. We're aware of a potential issue with the Draw.Text() method.

                  Our development team has been aware of the requirement from day 1, it was those of us in Product Management that missed the requirement which is why there was not any documentation on the subject (which we're working on currently)
                  MatthewNinjaTrader Product Management

                  Comment


                    #10
                    I am getting this error now pretty consistently.

                    I am trying to put a strategy together to see if I can simulate this and make it repeatable. Once it occurs, I have to restart NT8 as it FREEZE all the charts, it is such a pain. The other windows seem to work but even charts not in use freeze and cannot be selected any longer.

                    How this just happened to me was:
                    1) I have a portfolio of instruments trading a strategy (9 instruments)
                    2) I updated the strategy (didn't reload any active strategies to keep the old code)
                    3) Used a free chart window to add this newly compiled version of the strategy on an instrument that is currently active with the old version
                    4) Strategy worked fine, no error
                    5) With strategy "active" switched to a different Instrument (again one already running the older version of the strategy) and as the chart loads up, I get the "Failed to call Add.... lock held" issue below. This chart and all background charts are no longer selectable and frozen.



                    2015-06-18 12:37:45:480|1|64|Instrument='6E 09-15' Account='Sim101' Average price=0 Quantity=0 Market position=Flat Operation=Remove
                    2015-06-18 12:37:52:893|1|4|NinjaScript strategy 'GHPIBStrategy01/45784792' submitting order
                    2015-06-18 12:37:52:894|1|32|Order='40ca563c441a413ca9784514a d86aa6a/Sim101' Name='Buy to cover' New state='Submitted' Instrument='ZB 09-15' Action='Buy to cover' Limit price=0 Stop price=0 Quantity=1 Type='Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
                    2015-06-18 12:37:53:001|1|32|Order='40ca563c441a413ca9784514a d86aa6a/Sim101' Name='Buy to cover' New state='Accepted' Instrument='ZB 09-15' Action='Buy to cover' Limit price=0 Stop price=0 Quantity=1 Type='Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
                    2015-06-18 12:37:53:001|1|32|Order='40ca563c441a413ca9784514a d86aa6a/Sim101' Name='Buy to cover' New state='Working' Instrument='ZB 09-15' Action='Buy to cover' Limit price=0 Stop price=0 Quantity=1 Type='Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
                    2015-06-18 12:37:53:002|1|32|Order='40ca563c441a413ca9784514a d86aa6a/Sim101' Name='Buy to cover' New state='Filled' Instrument='ZB 09-15' Action='Buy to cover' Limit price=0 Stop price=0 Quantity=1 Type='Market' Time in force=GTC Oco='' Filled=1 Fill price=149.59375 Error='No error' Native error=''
                    2015-06-18 12:37:53:002|1|8|Execution='2fe5659ffab94ef09640dc 3a2e450769' Instrument='ZB 09-15' Account='Sim101' Exchange=Default Price=149.59375 Quantity=1 Market position=Long Operation=Operation_Add Order='40ca563c441a413ca9784514ad86aa6a' Time='6/18/2015 12:38 PM'
                    2015-06-18 12:37:53:003|1|64|Instrument='ZB 09-15' Account='Sim101' Average price=0 Quantity=0 Market position=Flat Operation=Remove
                    2015-06-18 12:45:32:658|1|4|Enabling NinjaScript strategy 'GHPIBStrategy01/45784793' : On starting a real-time strategy - StartBehavior=WaitUntilFlatSynchronizeAccount EntryHandling=All entries EntriesPerDirection=1 StopTargetHandling=Per entry execution ErrorHandling=Stop strategy, cancel orders, close positions ExitOnClose=True / triggering 1000 seconds before close SetOrderQuantityBy=Strategy ConnectionLossHandling=Keep running DisconnectDelaySeconds=10 CancelEntriesOnStrategyDisable=False CancelExitsOnStrategyDisable=False Calculate=On bar close IsUnmanaged=False MaxRestarts=4 in 5 minutes
                    2015-06-18 12:46:30:633|1|4|Disabling NinjaScript strategy 'GHPIBStrategy01/45784793'
                    2015-06-18 12:46:30:762|1|4|Enabling NinjaScript strategy 'GHPIBStrategy01/45784793' : On starting a real-time strategy - StartBehavior=WaitUntilFlatSynchronizeAccount EntryHandling=All entries EntriesPerDirection=1 StopTargetHandling=Per entry execution ErrorHandling=Stop strategy, cancel orders, close positions ExitOnClose=True / triggering 1000 seconds before close SetOrderQuantityBy=Strategy ConnectionLossHandling=Keep running DisconnectDelaySeconds=10 CancelEntriesOnStrategyDisable=False CancelExitsOnStrategyDisable=False Calculate=On bar close IsUnmanaged=False MaxRestarts=4 in 5 minutes
                    2015-06-18 12:46:35:406|3|4|Failed to call 'Add' method: Write lock may not be acquired with read lock held. This pattern is prone to deadlocks. Please ensure that read locks are released before taking a write lock. If an upgrade is necessary, use an upgrade lock in place of the read lock.

                    Comment


                      #11
                      I am still working on reproducing this with a simple strategy. Have done it a few times but not consistently. Some additional reading that might help:
                      http://stackoverflow.com/questions/1...outecollection

                      Here there is a problem with "Routing"... Not sure how it applies, but might give an idea what causes this problem intermittently when change instruments with a running strategy.

                      Also, I have tried to trap this within Visual Studio 2013 Debugger, but doesn't seem to get caught by VS. I was hoping to capture the call stack but no luck.

                      Comment


                        #12
                        I can't reproduce this exact error so it might be a complication of the error I can reproduce with the sample MA crossover.

                        I have attached the Workspace (Zipped so I could upload) used to setup the issue. Enable the 4 strategies (I did it from the 4 individual charts, not sure if there is a difference).

                        Change the instrument between ZB and 6E a few times on each chart and wait for a "realtime" trade to take place. I think I triggered this while changing as well, but it may have been a realtime trade that occurred right after the switch.

                        Sooner or later you will get an exception (partial text below an image). I have enclosed the Account Box as well to show that this exception stopped one of the strategies (position isn't in sync with other version) but "remains" running.

                        2015-06-18 15:36:30:301 (NTBroker) Cbi.Account.Submit0: orderId='04fdd3b91c5e411b91f24c803080593b' account='Sim101' name='Sell short' orderState=Initialized instrument='6E 09-15' orderAction=SellShort orderType='Market' limitPrice=0 stopPrice=0 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 id=586 gtd='2099-12-01' currentOrderState=Initialized
                        2015-06-18 15:36:30:301 (NTBroker) Cbi.Account.Submit1: orderId='04fdd3b91c5e411b91f24c803080593b' account='Sim101' name='Sell short' orderState=Initialized instrument='6E 09-15' orderAction=SellShort orderType='Market' limitPrice=0 stopPrice=0 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 id=586 gtd='2099-12-01' currentOrderState=Initialized
                        2015-06-18 15:36:30:301 (NTBroker) Cbi.Simulator.Submit: orderId='04fdd3b91c5e411b91f24c803080593b' account='Sim101' name='Sell short' orderState=Initialized instrument='6E 09-15' orderAction=SellShort orderType='Market' limitPrice=0 stopPrice=0 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 id=586 gtd='2099-12-01'
                        2015-06-18 15:36:30:301 (NTBroker) Cbi.Account.OrderUpdateCallback: orderId='04fdd3b91c5e411b91f24c803080593b' account='Sim101' name='Sell short' orderState=Submitted instrument='6E 09-15' orderAction=SellShort limitPrice=0 stopPrice=0 quantity=1 orderType='Market' filled=0 averageFillPrice=0 error=NoError comment=''
                        2015-06-18 15:36:30:405 (NTBroker) Cbi.Account.OrderUpdateCallback: orderId='04fdd3b91c5e411b91f24c803080593b' account='Sim101' name='Sell short' orderState=Accepted instrument='6E 09-15' orderAction=SellShort limitPrice=0 stopPrice=0 quantity=1 orderType='Market' filled=0 averageFillPrice=0 error=NoError comment=''
                        2015-06-18 15:36:30:405 (NTBroker) Cbi.Account.OrderUpdateCallback: orderId='04fdd3b91c5e411b91f24c803080593b' account='Sim101' name='Sell short' orderState=Working instrument='6E 09-15' orderAction=SellShort limitPrice=0 stopPrice=0 quantity=1 orderType='Market' filled=0 averageFillPrice=0 error=NoError comment=''
                        2015-06-18 15:36:30:405 (NTBroker) Cbi.Simulator.Fill1: thread='28' orderId='04fdd3b91c5e411b91f24c803080593b' maxFillQuantity='0' price='1.138'
                        2015-06-18 15:36:30:405 (NTBroker) Cbi.Simulator.Fill2: orderId='04fdd3b91c5e411b91f24c803080593b' fillQuantity='1' price='1.138'
                        2015-06-18 15:36:30:405 (NTBroker) Cbi.Account.OrderUpdateCallback: orderId='04fdd3b91c5e411b91f24c803080593b' account='Sim101' name='Sell short' orderState=Filled instrument='6E 09-15' orderAction=SellShort limitPrice=0 stopPrice=0 quantity=1 orderType='Market' filled=1 averageFillPrice=1.138 error=NoError comment=''
                        2015-06-18 15:36:30:407 (NTBroker) Cbi.Account.ExecutionUpdateCallback: execution='43f4188d1e21495198fe34a376b75614' exchange=Default price=1.138 quantity=1 marketPosition=Short operation=Add orderID='04fdd3b91c5e411b91f24c803080593b' time='6/18/2015 3:36:39 PM'
                        2015-06-18 15:36:30:407 *************** unhandled exception trapped ***************
                        2015-06-18 15:36:30:407 Exception has been thrown by the target of an invocation.
                        2015-06-18 15:36:30:407 System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object.
                        at NinjaTrader.Gui.Chart.ChartBars.OnExecutionUpdate( Object sender, ExecutionEventArgs e)
                        at System.EventHandler`1.Invoke(Object sender, TEventArgs e)
                        at NinjaTrader.Cbi.Account.ExecutionUpdateCallback(In strument instrument, String executionId, Exchange exchange, DateTime time, MarketPosition marketPosition, String orderId, Int32 quantity, Double price, Double commission, Double fee, Boolean isSod, Operation operation)
                        at NinjaTrader.Cbi.Simulator.Fill(Int32 maxFillQuantity, Double avgFillPrice)
                        at NinjaTrader.Cbi.Simulator.OnMarketData(Object sender, MarketDataEventArgs e)
                        --- End of inner exception stack trace ---
                        at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
                        at System.Reflection.RuntimeMethodInfo.UnsafeInvokeIn ternal(Object obj, Object[] parameters, Object[] arguments)
                        at System.Delegate.DynamicInvokeImpl(Object[] args)
                        at System.Windows.Threading.ExceptionWrapper.Internal RealCall(Delegate callback, Object args, Int32 numArgs)
                        at MS.Internal.Threading.ExceptionFilterHelper.TryCat chWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)

                        2015-06-18 15:36:30:409 ERROR: There is no default email share service set. Make sure you've defined an email share service and check "Default".
                        Attached Files

                        Comment


                          #13
                          Thanks - I'm not sure the workspace file contains all the info you meant to include, but I think I get the idea. I'm running some tests now.

                          When you say you're switching between those two instruments, that is from a chart that the strategy is running, correct? Meaning you're on instrument 6E with strategy running, wait for an execution and then switch to ZB with the strategy still running?

                          Do you have Chart Trader on these charts?
                          MatthewNinjaTrader Product Management

                          Comment


                            #14
                            Originally posted by NinjaTrader_Matthew View Post
                            Thanks - I'm not sure the workspace file contains all the info you meant to include, but I think I get the idea. I'm running some tests now.

                            When you say you're switching between those two instruments, that is from a chart that the strategy is running, correct? Meaning you're on instrument 6E with strategy running, wait for an execution and then switch to ZB with the strategy still running?

                            Do you have Chart Trader on these charts?
                            Hummm... Okay I copied the file from my workspace and zipped it to upload. Did you place the unzipped file in your workspace?

                            Yes, switching the instrument on the charts. I have 2 chart windows with 2 tabs each and just kept changing them back and forth a bit so I have 2 ZB and 2 6E or 4 strategies. Then just let them run for a bit so they open a close a few positions and watch the log window for the errors.

                            I do believe the Chart Trader was open on the Chart Panels as well.

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by saltminer, Today, 05:19 PM
                            0 responses
                            3 views
                            0 likes
                            Last Post saltminer  
                            Started by martyn73, Today, 04:18 PM
                            0 responses
                            2 views
                            0 likes
                            Last Post martyn73  
                            Started by aprendiz, Today, 03:42 PM
                            0 responses
                            2 views
                            0 likes
                            Last Post aprendiz  
                            Started by 1001111, Today, 09:10 AM
                            1 response
                            12 views
                            0 likes
                            Last Post NinjaTrader_ChrisL  
                            Started by usero86, Today, 06:02 AM
                            1 response
                            8 views
                            0 likes
                            Last Post NinjaTrader_ChrisL  
                            Working...
                            X