question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

EntityDefinition.CollectionName becoming "randomly" null.

See original GitHub issue

I’m scratching my head to understand why EntityDefinition.CollectionName is becoming “randomly” null. I say randomly, because it seems like 1 in 3 runs the issue crops up.

Happens when doing a basic query on a collection:

    public IList<Contact> GetAll(Guid organizationId)
    {
        var contacts = _context.Contacts
            .Where(b => b.OrganizationId == organizationId)
            .ToList();

        return contacts;
    }

System.ArgumentNullException: Value cannot be null. (Parameter ‘name’) at MongoDB.Driver.Core.Misc.Ensure.IsNotNullOrEmpty(String value, String paramName) at MongoDB.Driver.MongoDatabaseImpl.GetCollection[TDocument](String name, MongoCollectionSettings settings) at MongoFramework.Infrastructure.Linq.MongoFrameworkQueryProvider1.GetCollection() in C:\Users\dthk\Source\Repos\MongoFramework\src\MongoFramework\Infrastructure\Linq\MongoFrameworkQueryProvider.cs:line 87 at MongoFramework.Infrastructure.Linq.MongoFrameworkQueryProvider1.GetBaseExpression() in C:\Users\dthk\Source\Repos\MongoFramework\src\MongoFramework\Infrastructure\Linq\MongoFrameworkQueryProvider.cs:line 38 at MongoFramework.Infrastructure.Linq.MongoFrameworkQueryable1..ctor(IMongoFrameworkQueryProvider provider) in C:\Users\dthk\Source\Repos\MongoFramework\src\MongoFramework\Infrastructure\Linq\MongoFrameworkQueryable.cs:line 23 at MongoFramework.Infrastructure.EntityReader1.AsQueryable() in C:\Users\dthk\Source\Repos\MongoFramework\src\MongoFramework\Infrastructure\EntityReader.cs:line 23 at MongoFramework.MongoDbSet1.GetQueryable() in C:\Users\dthk\Source\Repos\MongoFramework\src\MongoFramework\MongoDbSet.cs:line 191 at MongoFramework.MongoDbSet1.get_Provider() in C:\Users\dthk\Source\Repos\MongoFramework\src\MongoFramework\MongoDbSet.cs:line 201 at System.Linq.Queryable.Where[TSource](IQueryable1 source, Expression1 predicate) at RuleEngine.Infrastructure.Repositories.ContactRepository.GetAll(Guid organizationId) in C:\Users\dthk\Source\Repos\AdvocacySolutions\RuleEngine.Infrastructure\Repositories\ContactRepository.cs:line 78 at RuleEngine.API.Jobs.ProcessRules.ProcessContactRules.BeginJob(Guid organizationId) in C:\Users\dthk\Source\Repos\AdvocacySolutions\RuleEngine.BackgroundTasks\Application\Jobs\ProcessRules\ProcessContactRules.cs:line 40 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
dthk-cogmatixcommented, Jan 14, 2020

Hey @dthk-cogmatix - have you had a chance to look at #124 to see if that solves your problem?

I have a key milestone coming up and had to leverage my hack/fix. I should be able to test and provide feedback in the next day or so.

1reaction
Turnerjcommented, Dec 29, 2019

Great debugging and very interesting. While it is interesting that using Lazy is the way the ASP.NET team went, it feels a little hacky to me.

Instead, I might look at changing a bit internally of how the locking system I already use works (the ReadWriteSlim used to work around problems in the MongoDB driver).

This wouldn’t be thread safe because by the time EntityMapping.IsRegistered returns, it’s very possible the entity could be registered…

I’m thinking maybe having an EntityMapping.TryRegister method used for cases like that instead. Would be quite similar to GetOrCreate though instead of returning the definition, it just returns true/false.

I’ll try and get this done over the next few days.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tooling API Query (FieldDefinition) for null EntityDefinition. ...
I need to run a ToolingAPI query of FieldDefinition, where the SObjectName and NamespacePrefix will be passed as parameters.
Read more >
Release notes — JaVers Documentation
Writing to the head_id collection is now skipped when RANDOM commitId generator is selected. The fix requires enabling the RANDOM CommitId generator. RANDOM...
Read more >
2886297-18-add-code_of_conduct-txt.patch
@param array|null $options * The constraint options as required by the constraint plugin, ... diff --git a/core/lib/Drupal/Component/Utility/Random.php ...
Read more >
Core Data objects become null - ios
The problem is that (as I wrote in a comment) that the objects are fetched on a background thread, but used on the...
Read more >
Messages and Codes: General Messages - Set 2
The command you wish to execute is already being executed by someone else, but the command cannot be executed in parallel.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found