Note that there are some explanatory texts on larger screens.

plurals
  1. POConcurrency problem
    text
    copied!<p>We got an old system here in .NET 4.0 using an Oracle DB. At some point, some calculus are made and the system "locks" that register in the table using the following command: "SELECT [the registry that will be update by the calculus] FOR UPDATE NOWAIT". So if anyone tries to calculate or update the registry with that ID it won't work. After calculating, the system connects to the DB again and then "releases" the registry by simply executing a Rollback command.</p> <p>Theoretically, this is correct for the system(altought I don't like it).</p> <p>Anyway, here is the thing: if something is being calculated(and these calculous take like 5 minutes to finish) and in the middle of the calculous I close the browser, the registry will still be "locked", only being unlocked when IIS restarts(actually I dunno if it's released first, I forced IIS restart 'cause it was taking too long).</p> <p>Could anybody give me a light about how to deal with that? Or if you guys have a better approach to deal with this tipe of concurrency, I'll be greatful.</p> <p>Thanks! Gabriel.</p> <p>Adding some code. Before starting the calculus, this method is called:</p> <pre><code>Public Shared Sub LockAndUnlock(ByVal pTable As String, ByVal pWhere As String, ByVal pConnectionString As String, ByVal pLock As Boolean) Dim vConnection As OleDbConnection = New OleDbConnection(pConnectionString) Dim vCommand As OleDbCommand = New OleDbCommand Try vCommand.Connection = vConnection If (pLock) Then vCommand.CommandText = "SELECT * " &amp; " FROM " &amp; pTable &amp; " WHERE " &amp; pWhere &amp; " FOR UPDATE NOWAIT" vConnection.Open() vCommand.ExecuteNonQuery() Else vCommand.CommandText = "ROLLBACK" If (vConnection.State = ConnectionState.Closed) Then vConnection.Open() End If vCommand.ExecuteNonQuery() vConnection.Close() End If Catch ex As Exception Throw ex End Try End Sub </code></pre> <p>If the parameter pLock is True then the method locks. Otherwise, it unlocks.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload