Exception: This service instance has not been activated yet

We very sporadically get this exception when calling DataAbstract GetData in our .NET RO/DA service (windows service).

What could cause this? How can we fix this?
Simply restarting the service fixes the issue.

The full error callstack is

GetData/)| executed in 18,9912ms and returned Exception:RemObjects.SDK.Exceptions.ServiceInstanceNotActiveException: This service instance has not been activated yet.
   bij RemObjects.SDK.Server.Service.InternalGetSession(Boolean throwException)
   bij Officinall.BaseClasses.SQLLogger.createSQLCommand(String operationName, SQLEntry& sqlentry, Boolean bFinishExpected)
   bij Officinall.BaseClasses.SQLLogger.logDatabaseCommand(IDbCommand command)
   bij RemObjects.DataAbstract.Schema.BeforeExecutingGetDataReaderEventHandler.Invoke(ServiceSchema sender, BeforeExecutingGetDataReaderEventArgs e)
   bij RemObjects.DataAbstract.Schema.ServiceSchema.GetDataReader(IAbstractConnection connection, SchemaDataTable table, String[] dynamicSelect, XmlNode dynamicWhere, Boolean validateDynamicWhere, String[] parameterNames, Object[] parameterValues, SchemaColumnMappingCollection& columnMappings, IDbCommand& command)
   bij RemObjects.DataAbstract.Server.DataAbstractService.GetDataViaTableRequestFromPlainTable(SchemaDataTable tableSchema, TableRequestWrapper requestInfo, DataStreamer streamer)
   bij RemObjects.DataAbstract.Server.DataAbstractService.GetDataViaTableRequest(String tableName, TableRequestWrapper requestInfo, DataStreamer streamer, Boolean allowPrivateAccess)
   bij RemObjects.DataAbstract.Server.DataAbstractService.InternalGetData(String[] tableNames, TableRequestInfo[] requestInfo, DataStreamer streamer, Boolean allowPrivateAccess)
   bij RemObjects.DataAbstract.Server.DataAbstractService.GetData(String[] tableNames, TableRequestInfo[] requestInfo)
   bij OffNetServer.DataAbstract.OffNetDataAbstractService.GetData(String[] aTableNameArray, TableRequestInfo[] aTableRequestInfoArray)

Hm, I could see this happening if the service accesses the session before it has finished going the the Activate().

When request comes in, a your class factory is asked for a new or existing instance, and class ActivateInstance on that, then ir tuts the service call, and then Deactivates it. ServiceInstanceNotActiveException is thrown when trying to access the session on a service instance that has not been activated (or has been deactivated again).

What server channel and class factory are you using?

It’s a TCP channel, the client (delphi) and server (.net) are on the same LAN

No class factory is specified for the our DA service (it inherits from DataAbstractService)
Note: This DA service can dynamically load the schema file, could that be related to the issue?

Some code snippets below

channel creation snippet:
server.NetworkServer.ServerChannel = new RemObjects.SDK.Server.IpTcpServerChannel();
server.NetworkServer.Port = 7789;
int maxMesSize = int.MaxValue;
BinMessage message = new BinMessage();
message.MaxMessageSize = maxMesSize;
message.MaxDecompressedMessageSize = maxMesSize;
server.NetworkServer.RegisterServerMessage(message);
server.Run(args);

schema loader snippet:
var schemaLoader = new SchemaLoader(“genericdb.daSchema”);
var container = new SimpleContainer();
container.RegisterSDK(server.NetworkServer);
container.RegisterDataAbstract();
container.RegisterSingleton(schemaLoader);
container.RegisterSingleton<ISchemaProvider, SchemaProvider>();
container.RegisterServices();
server.DependencyResolver = container

Curious. the you say “very sporadically”, how often does this happen (one a day? week? month?), and how many requests succeed in comparison (ie is it one in 10 or one in a million)? Can you see any system or commonality between the requests that fail? e.g., is it always the same client, or always the same data table, or the like?

Is the above call stack complete? ie does it not go deeper than OffNetDataAbstractService.GetData? (which is odd).

We have not witnessed the issue inhouse ourselves
Our application is deployed on ~400 machines.
Only one customer reported this issue twice
I tested some other customer logs and saw other occurances
For one customer the month october had 16 errors in another DA schema (not with schemaloader) out of 100k+ DA calls.
I do not see any commonality. The service is typically up for days without issues. First noticed occurance ~15/10
We catch the exception and log the callstack in our .NET code, I presume that code limits the callstack size.

Very strange. Best I can do right now is have a dry code review for this next week to see if I can find anything obviously, but on first look tis is very much a “this can never happen” scenario. Of course, those always are the most fun to debug :wink:

I assume you are using latest (not that this class has changed much recently)?

At present we are using RO v10.0.0.15533
I will send you the source in a private mail

Hi,

can you add BeforeActivate and BeforeDeactivate events and write to log messages like BeforeActivate is called & BeforeDeactivate is called with ClientConnectionId, pls?

it will help to detect current case:

  • service wasn’t activated at all
  • service was deactivated in middle of process

Where do I find ClientConnectionId?
I don’t see this in the DataAbstractService or ServiceActivationEventArgs
FYI I can log e.SessionID

Hi,

this is SessionID but you have logged it as ClientConnectionId :slight_smile:

   bij OffNetServer.DataAbstract.OffNetDataAbstractService.GetData(String[] aTableNameArray, TableRequestInfo[] aTableRequestInfoArray)
ClientConnectionId:7f80a605-695c-4791-9c57-3a3a9b500b31

I believe the ClientConnectionId you show comes from
sqlloggger_.setResult(false, null, $“Exception:{ex.ToString()}”);
Looking at the log file where this is dumped this is part of System.Data.SqlClient.SqlException.ToString() but this is not the error we are discussing.

I would like to investigate the RemObjects.SDK.Exceptions.ServiceInstanceNotActiveException error.
I propose to add the RO SessionId to the log file for this exception, OK?

Additional question: Is ServiceActivationEventArgs.SessionId identical to DataAbstractService.SessionId?

Hi,

agree

yes, it is identical


finally, you will have one from two cases:

ERROR|GenericDB(GetData/)...

or

BeforeActivate is called (SessionId)
BeforeDeactivate is called (SessionId)
ERROR|GenericDB(GetData/)...