Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-4897

Index was outside the bounds of the array on changestream cursor

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Gone away
    • Icon: Major - P3 Major - P3
    • None
    • None
    • None
    • None
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

    Description

      Summary

      We are using changestream using c# mongodb driver to do some realtime work. We received an error randomly after connection to the events.

      $Index was outside the bounds of the array.

      var options = new ChangeStreamOptions { ResumeAfter = resumeToken, BatchSize = 5 };

      CancellationTokenSource cancelTokenSource = new CancellationTokenSource();
      CancellationToken token = cancelTokenSource.Token;

      try {
        using(var cursor = await mongoclient.WatchAsync(pipeline, options, cancellationToken: token)) {
          await cursor.ForEachAsync(async change =>

      {            }

      , cancellationToken: token);
        }
      } catch (Exception ex) {

      }

       

      On this line 109 await cursor.ForEachAsync we receive this error. This happens after sometime like 8,9 hours every time.  Sharing the stacktrace

      at Microsoft.Extensions.Logging.LogValuesFormatter.GetValue(Object[] values, Int32 index) at Microsoft.Extensions.Logging.FormattedLogValues.GetEnumerator()+MoveNext() at Serilog.Extensions.Logging.SerilogLogger.Log[TState](LogLevel logLevel, EventId eventId, TState state, Exception exception, Func`3 formatter) at Microsoft.Extensions.Logging.Logger`1.Microsoft.Extensions.Logging.ILogger.Log[TState](LogLevel logLevel, EventId eventId, TState state, Exception exception, Func`3 formatter) at Microsoft.Extensions.Logging.LoggerExtensions.Log(ILogger logger, LogLevel logLevel, EventId eventId, Exception exception, String message, Object[] args) at SyncServer.Services.MultiDatabaseChangeStreamManager.<>cDisplayClass9_0.<<StartChangeStreams>b6>d.MoveNext() in /app/jenkins/workspace/flecx-prod-changestream/src/Host/SyncServer/Services/MultiDatabaseChangeStreamManager.cs:line 167 — End of stack trace from previous location — at MongoDB.Driver.IAsyncCursorExtensions.ForEachAsync[TDocument](IAsyncCursor`1 source, Func`3 processor, CancellationToken cancellationToken) at SyncServer.Services.MultiDatabaseChangeStreamManager.StartChangeStreams() in /app/jenkins/workspace/flecx-prod-changestream/src/Host/SyncServer/Services/MultiDatabaseChangeStreamManager.cs:line 109

      Attachments

        Activity

          People

            boris.dogadov@mongodb.com Boris Dogadov
            kghazanfar4@gmail.com Ghazanfar Khan
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: