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

ConventionRegistry growing with duplicate values

    • Dotnet Drivers

      Summary

      It looks like the same EnumRepresentationConvention is being registered to the ConventionRegistry over and over again, even if its only set up once in the application lifecycle.

      Please provide the version of the driver. If applicable, please provide the MongoDB server version and topology (standalone, replica set, or sharded cluster).

      MongoDB.Driver Version="2.24.0"

      How to Reproduce

      In the Startup.cs class, add EnumRepresentationConvention to the ConventionRegistry

      Eg.

      var pack = new ConventionPack { new EnumRepresentationConvention(BsonType.String) };
      ConventionRegistry.Register("EnumStringConvention", pack, t => true);
      Make any call to the desired repository, observe the ConventionRegistry growing with more than one of the same value by using the following command

      Log.Information(JsonConvert.SerializeObject(ConventionRegistry.Lookup(typeof(EnumRepresentationConvention))));

      Additional Background

      We initially started an investigation around an OOM exception, and after some profiling we noticed that the ConvetionRegistry kept growing - on inspection of the items that it contains, it was found that the EnumRepresentation value was repeated.

        1. ConventionPack_Profile.png
          ConventionPack_Profile.png
          146 kB
        2. CreateConvention_Startup.png
          CreateConvention_Startup.png
          149 kB
        3. EnumRepresentation.png
          EnumRepresentation.png
          101 kB

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            dedre.olwage@digiata.com Dedre Olwage
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: