question

juergenoswald avatar image
juergenoswald asked

NullReferenceException in PluginManager.GetPluginInternal

Hello. First off: I'm deliberately trying to produce this issue in an Azure-Function unit-test in order to find a certain edge-case that I have observed on our Staging environment. I'm basically getting the above exception when running AddUserVirtualCurrencyAsync in parallel 3 times. The last call I do await which is the one throwing the exception. Here's a brief callstack:

  Nachricht: 
    System.NullReferenceException : Object reference not set to an instance of an object.
  Stapelüberwachung: 
    Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
    Dictionary`2.set_Item(TKey key, TValue value)
    PluginManager.GetPluginInternal(PluginContract contract, String instanceName)
    PluginManager.GetPlugin[T](PluginContract contract, String instanceName)
    PlayFabHttp._DoPost(String fullPath, PlayFabRequestCommon request, String authType, String authKey, Dictionary`2 extraHeaders, PlayFabApiSettings instanceSettings)
    PlayFabHttp.DoPost(String urlPath, PlayFabRequestCommon request, String authType, String authKey, Dictionary`2 extraHeaders, PlayFabApiSettings instanceSettings)
    PlayFabServerInstanceAPI.AddUserVirtualCurrencyAsync(AddUserVirtualCurrencyRequest request, Object customData, Dictionary`2 extraHeaders)

Is it expected that this can happen when invoking API-calls concurrently? Is there anything about this in the documentation?

Regards

2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Made Wang avatar image Made Wang commented ·

Can you provide detailed steps or code snippets that can reproduce this issue so that we can troubleshoot further?

0 Likes 0 ·
juergenoswald avatar image juergenoswald Made Wang commented ·

Here's my unit test:

[Test]
public async Task TestConcurrentOperationsInline() {
  //serverApi = new PlayFabServerInstanceAPI(TestUtils.CreatePlayFabApiSettings()); <- Done in initializer.
  //Provoke parallel requests and thus concurrent operations.
  const int parallelThreads = 5;
  for (int i = 0; i < parallelThreads; ++i) {
    Task.Run(() => serverApi.AddUserVirtualCurrencyAsync(new PlayFab.ServerModels.AddUserVirtualCurrencyRequest() { PlayFabId = playFabId, VirtualCurrency = "CO", Amount = 1 })).ConfigureAwait(false);
  }
  await serverApi.AddUserVirtualCurrencyAsync(new PlayFab.ServerModels.AddUserVirtualCurrencyRequest() { PlayFabId = playFabId, VirtualCurrency = "CO", Amount = 1 });
}

0 Likes 0 ·
Made Wang avatar image
Made Wang answered

I don't have the Azure-Function unit-test, so I test directly on the Azure Function. I have tested running AddUserVirtualCurrencyAsync 3 and 5 times in parallel but failed to reproduce the error you mentioned. It should also be noted that we do not recommend performing such parallel operations.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

juergenoswald avatar image
juergenoswald answered

Only now did I find a related bug that was reported 1.5 years ago:
https://community.playfab.com/questions/47531/playfabserverapi-gettitleinternaldataasync-duplica.html

Is PluginManager.GetPlugin part of the playfab-codebase, or is that some external SDK or API-call?

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Made Wang avatar image Made Wang commented ·

It's part of PlayFabAllSDK, but like mentioned above, we don't recommend doing such parallel operations.

I tried the steps in the thread you mentioned and still can't reproduce the issue.

Also, is your PlayFabAllSDK the latest version?

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.