question

gamingbigfoot avatar image
gamingbigfoot asked

409 Conflict when calling GetContentUploadUrl

Hello! For our game, we have a PostProcess method, that we call from Unity Cloud Build, that does the following:

1. Gets a list of AssetBundles previously built by UCB to upload to playfab
2. For each one of those, it gets the content upload url

foreach(string bundle inthingsToUpload)
{
	string path= "AssetBundles/" + Utility.GetPlatformName() + "/"+bundle;
	var assetPath = Path.Combine(Directory.GetCurrentDirectory(),path);
	GetContentUploadURL(bundle,assetPath);
} 

static void GetContentUploadURL(string key, string path) { Debug.Log("FetchingContentURL.."); GetContentUploadUrlRequest request = new GetContentUploadUrlRequest(); request.Key = GetVersion() + "/" + Utility.GetPlatformName() + "/" +key;
request.ContentType = mimeType; PlayFabAdminAPI.GetContentUploadUrl(request,(GetContentUploadUrlResult result)=>{ Debug.Log("GOTURL.."+result.URL); byte[] fileContents = File.ReadAllBytes(path); PutFile(result. URL, fileContents); },OnPlayFabError); } static void OnPlayFabError(PlayFabError error) { Debug.Log(string.Format("UPLOAD BUNDLE ERROR: [{0}] -- {1}", error.Error, error.ErrorMessage)); }

Now this works I would say 75% of the time. There are times when nothing gets uploaded. When I go look at the logs for UCB, I see the following:

UPLOAD BUNDLE ERROR: [ServiceUnavailable] -- 409 Conflict

Any idea why this sometimes does not work ? Anything I can do to fix this issue?

apis
10 |1200

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

1 Answer

·
pfnathan avatar image
pfnathan answered

It appears that there were concurrent attempts to update the same data at the same time and that the second update was rejected thus creating 409 conflict, you should build it to upload one at the time.

4 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.

gamingbigfoot avatar image gamingbigfoot commented ·

Yea, I figured that, but it doesnt make much sense. It uploads different files, where is the conflict? And why does it work most of the time?

0 Likes 0 ·
brendan avatar image brendan gamingbigfoot commented ·

In general, you're going to run into this in cases where you're making multiple calls without waiting on the responses. Because we have many servers managing all the API calls, sometimes that'll work fine, as different servers are handling the calls. Sometimes, you'll wind up with both calls hitting the same server. And, of course, even if they're using different servers, if they're acting on the same data (not in this case, but for clarity) you'll have a problem regardless.

If this occurs when you're only making one call, it's possible that there was an unusual load condition that momentarily prevented the call from succeeding, but I would expect that to be very rare.

0 Likes 0 ·
gamingbigfoot avatar image gamingbigfoot brendan commented ·

I understand how the conflict works, for example, if they happen on a user data update, or something of the sort, but:

1. Why does this happen on File Upload? What is the shared thing thats 'conflicting' ?
2. Im not doing a single call, I get multiple '409' errors, but only put one up there as an example.

0 Likes 0 ·
Show more comments

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.