I have a web service and I'm experiencing a strange exception:
System.InvalidOperationException: Unable to change command: it is already prepared
at Xtensive.Orm.Providers.Command.AddPart(CommandPart part)
at Xtensive.Orm.Providers.BatchingCommandProcessor.Xtensive.Orm.Providers.ISqlTaskProcessor.ProcessTask(SqlLoadTask task)
at Xtensive.Orm.Providers.BatchingCommandProcessor.ExecuteBatch(Int32 numberOfTasks, QueryRequest lastRequest)
at Xtensive.Orm.Providers.SqlSessionHandler.ExecuteQueryTasks(IEnumerable`1 queryTasks, Boolean allowPartialExecution)
at Xtensive.Orm.Session.ProcessDelayedQueries(Boolean allowPartialExecution)
at Xtensive.Orm.Internals.Prefetch.Fetcher.ExecuteTasks(IEnumerable`1 containers, Boolean skipPersist)
at Xtensive.Orm.Internals.Prefetch.PrefetchManager.ExecuteTasks(Boolean skipPersist)
at Xtensive.Orm.Providers.SqlSessionHandler.FetchEntityState(Key key)
at Xtensive.Orm.QueryEndpoint.SingleOrDefault(Key key)
at Xtensive.Orm.Internals.FieldAccessors.EntityFieldAccessor`1.GetValue(Persistent obj)
at Xtensive.Orm.Persistent.GetFieldValue[T](FieldInfo field)
at Quadra.WMS.BusinessLogic.Place.get_FullName()
at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
at System.String.Join(String separator, IEnumerable`1 values)
at Quadra.WMS.BusinessLogic.Connector1C.DoUpdateAddress(Int32 skuId, IEnumerable`1 places)
Quadra.WMS.BusinessLogic.Place.get_FullName is in this code:
public class Place : Entity
{
public Place(Session session) : base(session)
{
}
[Key]
[Field]
public int Id { get; set; }
[Field]
public string Name { get; set; }
[Field]
public Barcode Barcode { get; set; }
[Field]
public Place ParentPlace { get; set; }
public string FullName
{
get
{
var placeList = new List<string>();
var p = this;
while (p != null)
{
placeList.Add(p.Name);
p = p.ParentPlace;
}
return string.Join(" / ", Enumerable.Reverse(placeList));
}
}
}
FullName should return a string of a full path of the place and its parent places.
I'm using 5.0-beta1 version.
asked
Sep 04 '14 at 04:02
Pavel Kudinov
7●3●3●5
Hi Pavel. I think problem is not in FullName. I created model with your type and filled it. Then i created query and for each entity of result i got FullName value and everything was fine. You have some delayed query. Could you show me more code, what do you do when this exception throws? Because I can't reproduce situation based on this data
This is a phantom problem. If I make lots of retries via F5 in my browser, this code works fine in 1 try of about 6. It seemes that there is a concurrency or something. I also cannot reproduce it anywhere in tests just in production env. What I'm doing is I'm running this code in another thread using Task.Factory.StartNew(() => myFunc(place.FullName))
After I stopped doing it in another thread I don't get this exception, I get another one:
System.NullReferenceException: Object reference not set to an instance of an object. at Xtensive.Orm.Providers.Command.NextRow()