loosing connection to SQL

Discussion in 'Databases' started by armando6036, Feb 15, 2011.

  1. I am having intermittent problems connecting to SQL. I will be using the DB through the website and it works fine then I get an error saying lost connection to SQL db. Is there a problem with connections or what can I do to get the user from stop loosing connection to the SQL db. :confused:
     
  2. Ray

    Ray

    Where exactly are you seeing this error message? Is on the the web application and is that web application already uploaded on our server? Or is it from your local computer. Basically we first need to identify if the Winhost web server is loosing the connection which is in the same LAN as the SQL server or if it is your computer loosing the connection which will have to transverse over the Internet.
     
    Last edited by a moderator: Oct 14, 2015
  3. everywhere

    I have 10 friends that were looking at my website at different times. They all complained of the disconnection from their own computers to the application that I built with VS 2010 VB via internet. last night i had multiple problems trying to see the database from my computer where I am writing the website application.
     
  4. Ray

    Ray

    It sounds like your application pool was being recycled. Which would loose the connection string.

    Here are some of the conditions that would cause our system to recycle your application pool.

    1) More than 20 minutes of idle time (no http request in 20 minutes)
    2) The application uses more than 100 MB memory for the Basic plan and 200 MB memory for the Max and Ultimate plan
    3) The application uses more than 75% of CPU time
     
  5. We usually spend less than 20 minutes total on the computer and the error usually shows up when trying to update the db.
    The database is extremely small, probably less than 1 MB.
    The user has to update one piece of information on the database. One row on one table is all that is being updated.
    The error usually shows up when the user looks at the table clicks update to change the name and when clicks on update/ submit the error shows up. No idling at all.
     
  6. Ray

    Ray

    Do you have a URL and a way for us to see this error message on our end?
     
  7. crnaschedule.net
    user: armando
    password: password
    click on the button Choose CB Date and enter armando in the CRNA field. The problem would happen when the user clicks on edit, enter their name then click update, that is when they get the error.
    This is a gridview using a SQL connection.
     
  8. here is the error.

    Server Error in '/' Application.
    --------------------------------------------------------------------------------

    Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Web.HttpException: Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.

    Source Error:

    The source code that generated this unhandled exception can only be shown when compiled in debug mode. To enable this, please follow one of the below steps, then request the URL:

    1. Add a "Debug=true" directive at the top of the file that generated the error. Example:

    <%@ Page Language="C#" Debug="true" %>

    or:

    2) Add the following section to the configuration file of your application:

    <configuration>
    <system.web>
    <compilation debug="true"/>
    </system.web>
    </configuration>

    Note that this second technique will cause all files within a given application to be compiled in debug mode. The first technique will cause only that particular file to be compiled in debug mode.

    Important: Running applications in debug mode does incur a memory/performance overhead. You should make sure that an application has debugging disabled before deploying into production scenario.

    Stack Trace:


    [ViewStateException: Invalid viewstate.
    Client IP: 70.247.191.153
    Port: 49941
    Referer: http://crnaschedule.net/(F(J9Am8knF...U45PaNwZeJkXMGUtm0))/CBEditCBDayNamesAll.aspx
    Path: /CBEditCBDayNamesAll.aspx
    User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; GTB6.6; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; InfoPath.3; .NET4.0E; Tablet PC 2.0; MS-RTC LM 8)
    ViewState: ZfIMcf3/q129ru4ka4d3fRFbRS6sQO3SC+27s9GN8Z9crXMSs2YwvJoQpKTpYktUC4ZcSYar9h0qjnOxf7mDa0HprekWxjqf69jzr8QUtE+nItWq7Tr6CzSLFv0MtSixcfM9WmBOgwM76nrvo+/TD4zBO+pSzOJkPdq2Bt7FG+0UFMq8XwV7tGXrNImE7qh3wCjz4sfN4Kz5JHpXF0RdOSjT36Z2SVRAq/Z5gXsDTvwFZr0D5wFXOoifQB7c9CJXEUc3hc3/jtpUw5Vv4PizzRUaOG2eRqrSElNadPHVMRYRfHmQ6DWLvV5nrPRN0VjN4uojOOjwBKNPjcY5Az6nkEQT8zr8PfC3xFdjaP/3tbNpZPvP7EML5zgNBJSbW/LYITgHac+xklFuoYz1occpguAEDEx6v7QJt9/vi3d5glnfUKwvmim+yo...]

    [HttpException (0x80004005): Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.]
    System.Web.UI.ViewStateException.ThrowError(Exception inner, String persistedState, String errorPageMessage, Boolean macValidationError) +198
    System.Web.UI.ViewStateException.ThrowMacValidationError(Exception inner, String persistedState) +14
    System.Web.UI.ObjectStateFormatter.Deserialize(String inputString) +274
    System.Web.UI.ObjectStateFormatter.System.Web.UI.IStateFormatter.Deserialize(String serializedState) +4
    System.Web.UI.Util.DeserializeWithAssert(IStateFormatter formatter, String serializedState) +37
    System.Web.UI.HiddenFieldPageStatePersister.Load() +241
    System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +106
    System.Web.UI.Page.LoadAllState() +43
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +8431
    System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +253
    System.Web.UI.Page.ProcessRequest() +78
    System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +21
    System.Web.UI.Page.ProcessRequest(HttpContext context) +49
    ASP.cbeditcbdaynamesall_aspx.ProcessRequest(HttpContext context) +37
    System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +100
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75
     
  9. Ray

    Ray

    Your application is definitely being recycled by the server because it started to consume over 100 MB of the servers memory. As I ran through the test I monitored the server and noticed that the application pools memory usage steadily increased for each edit and update I performed. It did not go down. On the first initial stage the applications seems to be running well consuming 45 MB of the servers memory however by my 10th edit attempt, the application pool was already at 85 MB. Even when I stopped editing and simply looked at th site and navigated through different pages, the application pool stayed at 85 MB. This means that your application pool was not releasing the memory space it used. Then after 5 more edits the application pool surpassed 100 MB going to 104 MB and thus it was recycled by our server.
     
  10. So I need to run something on my application that releases SQL memory, correct? any help will be appreciate it. I am using vb.net visual basic in visual studio 2010.
     
  11. Ray

    Ray

    First make sure you are closing all your connection strings after you use them. Try looking at this kb article as an example on how to connect to a SQL server then close it.

    http://support.Winhost.com/KB/a647/how-to-query-an-sql-database-with-net-sql-data-provider.aspx

    Also you may want to explicitly specify to clear the connection pool to the SQL database.

    http://weblogs.asp.net/wallym/archive/2004/08/28/222184.aspx

    Now, keep in mind that your connection to the database and the query results maybe one of the contributing factors to your memory foot print. Since I did not design and create your database you may want to go through your coding and optimize it as much as you can. Such as declaring the correct variable and data type. The query or SQL statement itself such as only calling on the required data instead of using wild card. An example if you setup a query select * from table then all the columns in that table will be loaded into the process. Where as if you only need columns 1 and columns 2 you can explicitly state it. Select col1, col2 from table. That way you are not pulling data that you do not need.
     
    Last edited by a moderator: Oct 14, 2015
  12. can I check the memory pool from my computer to see the amount being used?
     
  13. Ray

    Ray

    You can run your application on your computer and see just how much memory it is using. That can give you an indication on how much it is using on the server. But keep in mind you have to download all your web applications. Some customers run multiple web applications under one account. And often times they only download one web application and test it which can give them an inaccurate results.
     
  14. still problems

    [ViewStateException: Invalid viewstate.
    Client IP: 70.247.124.26
    Port: 49377
    Referer: http://crnaschedule.net/Default4.aspx
    Path: /Default4.aspx
    User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; GTB6.6; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; InfoPath.3; .NET4.0E; Tablet PC 2.0; MS-RTC LM 8)
    ViewState: /wEPDwULLTE4OTMyODAyMTcPZBYCAgMPZBYCAgUPPCsAEQMADxYEHgtfIURhdGFCb3VuZGceC18hSXRlbUNvdW50AjxkARAWABYAFgAMFCsABBYIHgROYW1lBQJJRB4KSXNSZWFkT25seWgeBFR5cGUZKwEeCURhdGFGaWVsZAUCSUQWCB8CBQtEZXNjcmlwdGlvbh8DaB8EGSsCHwUFC0Rlc2NyaXB0aW9uFggfAgUJU2NoZWREYXRlHwNoHwQZKVxTeXN0ZW0uRGF0ZVRpbWUsIG1zY29ybGliLCBWZXJzaW9uPTQuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49Yjc3YTVjNTYxOTM0ZTA4OR8FBQlTY2hlZERhdGUWCB8CBQRDUk5BHwNoHwQZKwIfBQUEQ1JOQRYCZg9kFnoCAQ9kFggCAQ8PFgIeBFRleHQFAjcwZGQCAg8PFgIfBgUMU3VuZGF5IDEgRGF5ZGQCAw8PFgIfBgUGJm5ic3A7ZGQCBA8PFgIfBgUBLmRkAgIPZBYIAgEPDxYCHwYFAjcxZGQCAg8PFgIfBgUQU3VuZGF5IDEgRXZlbmluZ2RkAgMPDxYCHwYFBiZuYnNwO2RkAgQPDxYCHwYFAS5kZAIDD2QW...]

    [HttpException (0x80004005): Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.]
    System.Web.UI.ViewStateException.ThrowError(Exception inner, String persistedState, String errorPageMessage, Boolean macValidationError) +198
    System.Web.UI.ViewStateException.ThrowMacValidationError(Exception inner, String persistedState) +14
    System.Web.UI.ObjectStateFormatter.Deserialize(String inputString) +274
    System.Web.UI.ObjectStateFormatter.System.Web.UI.IStateFormatter.Deserialize(String serializedState) +4
    System.Web.UI.Util.DeserializeWithAssert(IStateFormatter formatter, String serializedState) +37
    System.Web.UI.HiddenFieldPageStatePersister.Load() +241
    System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +106
    System.Web.UI.Page.LoadAllState() +43
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +8431
    System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +253
    System.Web.UI.Page.ProcessRequest() +78
    System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +21
    System.Web.UI.Page.ProcessRequest(HttpContext context) +49
    ASP.default4_aspx.ProcessRequest(HttpContext context) +37
    System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +100
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75



    My code is: I am running http://crnaschedule.net/Default4.aspx

    Protected Sub btnUpdate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpdate.Click

    CRNAName = txtCRNA.Text

    Dim connectionString As String
    Dim connection As SqlConnection

    connectionString = GetConnectionString()
    connection = New SqlConnection(connectionString)

    Dim updateStatement As String

    updateStatement = "UPDATE CBSched " _
    & "SET CRNA = @CRNA " _
    & "WHERE ID = @ID"

    Dim cmd As New SqlCommand(updateStatement, New SqlConnection(GetConnectionString))

    cmd.Parameters.AddWithValue("ID", CRNAID)
    cmd.Parameters.AddWithValue("CRNA", CRNAName)


    Dim rowsAffected As Integer = 0

    Try
    cmd.Connection.Open()
    Dim i As Integer = cmd.ExecuteNonQuery()
    cmd.Connection.Close()

    Catch ex As Exception
    ' Server.Transfer("error.aspx")
    MsgBox("Error, did not insert info")
    End Try

    connection.Close()
    connection.Dispose()


    End Sub
     
  15. Ray

    Ray

  16. I will try that. Thanks.
     
  17. Question, shouldn't the SQL clean the pool after the user closer IE? Let say that the pool gets too big after 20 edits and it recycles. If I do 10 edits and close IE then come back a few minutes later and do another 10 edits it recycles, it still half fool from the previous session.
    How often does the SQL clean the memory pool, or does it do it at all?
     
  18. Ray

    Ray

    SQL clean the memory pool? You mean the SQL connection pool? If that is the case then no it does not automatically clean it.
     

Share This Page