Analytics database timeout can occur when a contact session is submitted to the database

  • Description

    Connections to the Analytics database (MongoDB) can time out when the session of a contact with a large number of interactions is saved to the database. The following exception appears in the Sitecore XP log:

    WARN  Session Submit has failed.
    Exception: System.IO.IOException
    Message: Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
    Source: System
       at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
       at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count)
       at System.Net.Security._SslStream.StartFrameHeader(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
       at System.Net.Security._SslStream.StartReading(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
       at System.Net.Security._SslStream.ProcessRead(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
       at System.Net.Security.SslStream.Read(Byte[] buffer, Int32 offset, Int32 count)
       at MongoDB.Bson.IO.ByteBufferFactory.LoadFrom(Stream stream)
       at MongoDB.Driver.Internal.MongoConnection.ReceiveMessage[TDocument](BsonBinaryReaderSettings readerSettings, IBsonSerializer serializer, IBsonSerializationOptions serializationOptions)
       at MongoDB.Driver.Operations.QueryOperation`1.GetFirstBatch(IConnectionProvider connectionProvider)
       at MongoDB.Driver.Operations.QueryOperation`1.Execute(IConnectionProvider connectionProvider)
       at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
       at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
       at Sitecore.Analytics.Data.DataAccess.MongoDb.MongoDbInteractionStorage.RenumberInteractions(Guid contactId)
       at Sitecore.Analytics.Data.DataAccess.MongoDb.MongoDbDataAdapterProvider.RenumberInteractions(ID contactId)
       at Sitecore.Analytics.Data.ContactRepository.ReconcileContact(Contact contact, LeaseOwner owner, TimeSpan duration)
       at Sitecore.Analytics.Pipelines.SubmitSessionContext.RenumberInteractions.Process(SubmitSessionContextArgs args)
       at (Object , Object[] )
       at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
       at Sitecore.Analytics.Data.HttpSessionContextManager.Submit(Session session)
       at Sitecore.Analytics.Pipelines.CommitSession.SubmitSession.Process(CommitSessionPipelineArgs args)

    Nested Exception

    Exception: System.Net.Sockets.SocketException
    Message: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
    Source: System
       at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
  • To increase the query performance and avoid timeouts, you can add an index to the Interactions collection. You can do this manually by performing the following query to the Analytics database:

    db.getCollection('Interactions').createIndex( 
    {"ContactId": 1, "_t": 1, "StartDateTime": 1, "_id": 1}, 
    {background: true}
    )

Applies to:

CMS 8.1 Initial Release+

January 16, 2017
November 27, 2017

Reference number:

136108

Keywords: 

  • DMS
  • ,
  • Performance
  • ,
  • XDB