Output Adapter not stopping
-
18 April 2012 18:44
<input id="4ed964c1-295d-4e9c-83a4-b9955509e612_attachments" type="hidden" />I am noticing that the Stop() Event in my output adapter is never being called. Even though the query is being stopped. I see a similar issue in another post (http://qa.social.msdn.microsoft.com/Forums/en-US/streaminsight/thread/8ccdd37c-add1-4fb0-bac5-6ec891cf9262) was to send a max CTI when the input adapter stops and when the output adapter gets it, it can stop itself
I am trying to do the same thing. It works the first time I run up my query with input and output adapters. I see the data flowing through and then when I stop the query, I see the input adapter Stop() and then the output adapter picking up the max CTI time and also stopping. When I try to restart my query, though, things fall apart. No data flows through the query.
I didn't think the max CTI event from the previous run of the query would impact the following runs, but it looks that way to me. Is this what is happening?
This is how I am enqueueing the max CTI in the input adapter. Is this incorrect?
public override void Stop() { EnqueueCtiEvent(DateTimeOffset.MaxValue); dataSource.Stop(); Stopped(); base.Stop(); }
Semua Balasan
-
19 April 2012 3:29
First, have you read my blog entry on output adapter lifetime? It goes through the details of the life and death of an output adapter. Keep in mind that the output adapter won't be stopped until the entire queue is emptied. It doesn't sound like that's your problem but I thought it worth mentioning.
Now ... as for your input adapter ... you are enqueuing an infinity CTI on shutdown. Unless you delete and recreate the query, you won't be able to enqueue any further events. When you try, you'll get a CTI violation. Have you noticed this happening?
Just because you stop a query doesn't mean that the timeline restarts from zero. It doesn't ... this would cause a lot of problems in scenarios where the metadata services are used or when the query is restarting from a checkpoint (which also uses metadata services). The only way you can get the timeline to reset is to delete the query. This is also why the AdvanceTimeSettings include the option to AdvanceToInfinityOnShutdown ... this is what you are doing ... but it's an option. Because it's not suitable to do that in all use cases. Like when the query will be restarted.
DevBiker (aka J Sawyer)
Microsoft MVP - Sql Server (StreamInsight)
If I answered your question, please mark as answer.
If my post was helpful, please mark as helpful.- Ditandai sebagai Jawaban oleh Roman SchindlauerMicrosoft Employee 30 April 2012 6:54
-
19 April 2012 9:30
Thanks for the reply. I have read through the doc on adapter lifetimes and I understand that I will need to recreate the query if I want to be able to enqueue additional events. My situation is this: I have an application that is built up dynamically - the query, input adapter and output adapter are all defined at runtime. When I want to stop the query, my runtime app does just that, it stops the queries in the application's collection. It then proceeds to dispose of various resources and ultimately shuts down the app. Later, when the user wants to start it up again, the app is created (dynamicallly) again, with the configuration setup by the user for input adapters, output adapters and queries. They are all recreated, so the max CTI sent out during the previous shutdown won't impact on the new startup.
The problem I have is that while I see the Stop() method being callled for my input adapters, I don't see them being called for my output adapters.
-
19 April 2012 16:26
That is rather odd.
Are you getting any exceptions? Have you shutdown the application and then the server together and gotten any hangs? I don't see any locks in your input adapter so you may be getting exceptions due to timing. And are you using the metadata services? If so, you need to delete the query and query template when you shutdown.
DevBiker (aka J Sawyer)
Microsoft MVP - Sql Server (StreamInsight)
If I answered your question, please mark as answer.
If my post was helpful, please mark as helpful. -
20 April 2012 10:31
I don't get any exceptions if I am starting (and stopping) a single application at a time. I must add, though, that I do get a randomly occuring exception on shutdown if I am starting and stopping multiple (about ten) applications at the same time. The exception is thrown when I try to delete the application object: "The object cannot be deleted because it is referenced by another object".
At any rate, while I was investigating that exception, I discovered that the problem only exists if I have an output adapter bound to the query. My architecture sets up a publised stream output adapter as a default and then links in any additional output adapters that are configured by the user at runtime, so what I am really saying is that the problem only exists if there are no "user defined" output adapters.
This led me to look into the shutdown process of those output adapters and that was when I found that the Stop() method is not being called. It may be a red herring, but I am trying to understand if this is the root of my problem. It may not be but it is currently the only fish I have on my line
I am not 100% what you mean by metadata service. I am using QueryBinder and QueryTemplate. During my cleanup I do delete the QueryTemplate, Query, InputAdapter and OutputAdapter objects. I only shutdown the applications. I have a singleton server that typically stays alive unless my hosting app shuts down (IIS)
- Diedit oleh FarnhamSurrey 20 April 2012 10:38
- Diedit oleh FarnhamSurrey 20 April 2012 14:25
-
20 April 2012 14:32
Have you tried this outside of IIS?
I will say that I wouldn't recommend running in IIS ... the app domain for IIS recycles on its own ... you have absolutely no control over that. When this happens, your application will restart as well and you'll lose any events that you may have already enqueued.
DevBiker (aka J Sawyer)
Microsoft MVP - Sql Server (StreamInsight)
If I answered your question, please mark as answer.
If my post was helpful, please mark as helpful.- Ditandai sebagai Jawaban oleh Roman SchindlauerMicrosoft Employee 30 April 2012 6:54
-
23 April 2012 9:05Our product is hosted on iis so it will be hard to detach it. I have to say, though, that we seem to be controlling (or disabling) app domain recycling by appropriately setting the "Recycle worker process" time (or unchecking the box) in the application pool property editor. If you don't touch the application's files or folders, you won't recycle the app domain. Or have I misunderstood something here?
- Diedit oleh FarnhamSurrey 24 April 2012 10:51
