CodeSmith Community
Your Code. Your Way. Faster!

Error in DeepLoad during transaction

rated by 0 users
This post has 13 Replies | 3 Followers

Top 25 Contributor
Posts 164
Points 3,275
JJmartin Posted: 12-07-2006 5:16 PM

I am working through the NUnit tests specifically with a One To One Relationship table.  I had an item where the DeepLoad was failing on a time out. 

The DeepLoad was trying to get an item that had been created under the transaction but not using the transaction manager.

The NUnit test also wasn't sending the transaction manager during the deepload.(this had to be done before i found the error above).

 I am editing both the NUnit Tests and the DeepLoad templates... can someone point me to the procedure for sending in patches?

 

-Jeff Martin C# MCSD
Top 10 Contributor
Posts 2,797
Points 254,035
Great Find!

Try installing Tortoise SVN,

check out this URL to a local directory.
https://svn.sourceforge.net/svnroot/nettiers/source/trunk/Source

Once you've made the changes, just right click the Source directory
TortoiseSVN -> Create Patch

Then just post that patch file to the Contrib forums.


On 12/7/06, JJmartin <bounce-JJmartin@codesmithsupport.com> wrote:

I am working through the NUnit tests specifically with a One To One Relationship table.  I had an item where the DeepLoad was failing on a time out. 

The DeepLoad was trying to get an item that had been created under the transaction but not using the transaction manager.

The NUnit test also wasn't sending the transaction manager during the deepload.(this had to be done before i found the error above).

 I am editing both the NUnit Tests and the DeepLoad templates... can someone point me to the procedure for sending in patches?

 






Robert Hinojosa
-------------------------------------
Member of the Codesmith Tools, .netTiers, teams
http://www.nettiers.com
-------------------------------------
  • | Post Points: 35
Top 10 Contributor
Posts 2,797
Points 254,035

Hi,

I found the scenario where it fails, if there is an fk pointing to itself, then it fails.  I've corrected the DeepLoad Load Parent entity to pass the transaction, and also included the transaction in the deepload call.

SVN Rev 447


Robert Hinojosa
-------------------------------------
Member of the Codesmith Tools, .netTiers, teams
http://www.nettiers.com
-------------------------------------
  • | Post Points: 5
Top 25 Contributor
Posts 164
Points 3,275

ok - i have already been using the SVN releases.  I will get the latest update and create a patch.

 I have made several alterations so i will include one with all my alterations for your consideration and one with just the changes described above

on another note, I am still being left with a Timeout on my Nunit tests... this is because a couple of the tables i have have a large amount of rows (over a million)  and the unit test is doing a GetAll with the default time out of 30 seconds (it took 1:29 in Server Management Studio to get all the records back)

I have noticed little support for setting the timeouts on the connections being used.  It would be nice if that was supported... i could specifically up the value for this test and then return it to default.  It wouldnt' be just for the tests, there are several methods that I am doing using netTiers (custom methods) that have long processing times.  I had to write overrides on the inherited provider to allow for a connection timeout.  The provider should probably just have a property to set.

The other thing I notice is that the CreateMockInstance is doing a GetAll on its foriegn keys even tho its only getting the first 10... but there is a GetPaged built into the system.  By changing this call, my test only fails on the SelectAll rather than everything in the test.

As it turns out - the SelectAll is actually failing on a memory overflow... (collection with million+ entries will do that i guess.)

-Jeff Martin C# MCSD
  • | Post Points: 35
Top 10 Contributor
Posts 2,797
Points 254,035

Yeah, we need to optimize to just select for paging 10 items.  Tests should never ever do that.

As for the timeout, there is some support for that. 

There are two new options for that, 1) DefaultCommandTimeout is a property in the web.config nettiers section.
 

      <add

          name="SqlNetTiersProvider"

          type="Northwind36.Data.SqlClient.SqlNetTiersProvider, Northwind36.Data.SqlClient"

          connectionStringName="Northwind36.Data.ConnectionString"

          providerInvariantName="System.Data.SqlClient"

          entityFactoryType="Northwind36.Entities.EntityFactory"

          useEntityFactory="true"

          enableEntityTracking="false"

          enableMethodAuthorization="false"

          useStoredProcedure="false"

          defaultCommandTimeout="30"/>

The other:

DataRepository.Provider.DefaultCommandTimeout = 100;

 

And Finally:

DataRepository.OrdersProvider.DataRequesting += new NameSpace.Data.Bases.EntityProviderBaseCore<Orders, OrdersKey>.DataRequestingEventHandler(OrdersProvider_DataRequesting);

 

public void OrdersProvider_DataRequesting(object sender, Northwind36.Data.Bases.CommandEventArgs e)

{

     e.Command.CommandTimeout = 1000;

}

 

 


Robert Hinojosa
-------------------------------------
Member of the Codesmith Tools, .netTiers, teams
http://www.nettiers.com
-------------------------------------
  • | Post Points: 35
Top 25 Contributor
Posts 164
Points 3,275

nice... i like the event one...

I will keep that in mind.  Thanks.

I did post my patch in the other forum.

-Jeff Martin C# MCSD
  • | Post Points: 5
Top 25 Contributor
Posts 164
Points 3,275

Bummed.

Got a chance to try to use the DataRequested event to try to change the command timeout and it turns out that at least on the custom methods the event is called AFTER the execution of the query... doing very little to set the timeout of that specific command.

 Is this intentional? your earlier post would indicate that it wasn't.

 

-Jeff Martin C# MCSD
  • | Post Points: 5
Top 25 Contributor
Posts 164
Points 3,275
I also don't see anywhere where the command timeout is being set differently in the custom function when i use the web.config item.
-Jeff Martin C# MCSD
  • | Post Points: 5
Top 25 Contributor
Posts 164
Points 3,275
found the bug (at least for the event) in the template... the OnDataRequesting event is only called if the custom method was returning a dataset (not idatareader or void).   I just threw in the call on those spots.
-Jeff Martin C# MCSD
  • | Post Points: 35
Top 150 Contributor
Posts 32
Points 1,040
Any chance you could include the source, or make a patch?
  • | Post Points: 35
Top 25 Contributor
Posts 164
Points 3,275

sure... i am a bit leary of leaving a patch as i have other modifications to this file not related to this change.

the file is Source/DataAccessLayer.SqlClient/SqlEntityProviderBase.generated.cst

my line numbers will be off due to the other changes i have but at the end of the file is a Custom Methods region.  this is where the change is (starts around line 1271 in the original file) This color is the event already there.   This color is the event calls I added.  Hope this helps.

   <% if (returnType == "DataSet") { %>
   DataSet ds = null;
   
   //Provider Data Requesting Command Event
   OnDataRequesting(new CommandEventArgs(commandWrapper, "<%= methodName %>", (IEntity)null));

   if (transactionManager != null)
   { 
    ds = database.ExecuteDataSet(commandWrapper, transactionManager.TransactionObject);
   }
   else
   {
    ds = database.ExecuteDataSet(commandWrapper);
   }
   
   //Provider Data Requested Command Event
   OnDataRequested(new CommandEventArgs(commandWrapper, "<%= methodName %>", (IEntity)null));

   
<%=outputValues.ToString()%>
   
   return ds; 
   <% } else if (returnType == "IDataReader") { %>
   IDataReader dr = null;
   
   //Provider Data Requesting Command Event
   OnDataRequesting(new CommandEventArgs(commandWrapper, "<%= methodName %>", (IEntity)null));

   
   if (transactionManager != null)
   { 
    dr = Utility.ExecuteReader(transactionManager,commandWrapper);
   }
   else
   {
    dr = Utility.ExecuteReader(database, commandWrapper);
   }

   //Provider Data Requested Command Event
   OnDataRequested(new CommandEventArgs(commandWrapper, "<%= methodName %>", (IEntity)null));

<%=outputValues.ToString()%>

   return dr;
   <% } else if (returnType == "void") { %>
   //Provider Data Requesting Command Event
   OnDataRequesting(new CommandEventArgs(commandWrapper, "<%= methodName %>", (IEntity)null));

   if (transactionManager != null)
   { 
    Utility.ExecuteNonQuery(transactionManager, commandWrapper );
   }
   else
   {
    Utility.ExecuteNonQuery(database, commandWrapper);
   }
   
   //Provider Data Requested Command Event
   OnDataRequested(new CommandEventArgs(commandWrapper, "<%= methodName %>", (IEntity)null));

<%=outputValues.ToString()%>
    
    return;
   <% } else if  (collectionClassName.Contains(returnType)) { %>
   //Provider Data Requesting Command Event
   OnDataRequesting(new CommandEventArgs(commandWrapper, "<%= methodName %>", (IEntity)null));

   
   IDataReader reader = null;

-Jeff Martin C# MCSD
  • | Post Points: 35
Top 10 Contributor
Posts 2,797
Points 254,035
These events have been added to SVN REV 466, Thanks for the patch!

Robert Hinojosa
-------------------------------------
Member of the Codesmith Tools, .netTiers, teams
http://www.nettiers.com
-------------------------------------
  • | Post Points: 35
Top 25 Contributor
Posts 164
Points 3,275
I would like to see this event now in the DataRepository.Provider.ExecuteDataSet (et al.)  so that I can set the time out on long running custom queries.
-Jeff Martin C# MCSD
  • | Post Points: 35
Top 500 Contributor
Posts 15
Points 315
i have the same problem. Sad
  • | Post Points: 5
Page 1 of 1 (14 items) | RSS
Copyright © 2008 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems