Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Invalidating cached asset on Unity Accelerator

Discussion in 'Unity Accelerator' started by alexvector, Mar 9, 2020.

  1. alexvector

    alexvector

    Joined:
    Oct 9, 2019
    Posts:
    26
    Hello.

    Is it possible to replace/invalidate the cached version of an asset?

    This is our issue:

    There is probably a bug somewhere (probably not related the Accelerator) that caused one of our prefab to be imported with some of its references as null. However when we open that prefab the data is ok and if we do a "Reimport" it turns back to normal.

    What makes the prefab bug worse, is that this invalid prefab seems to have been stored in the Accelerator. Now everyone that opens the Unity project will get the invalid prefab import. If I open the project without the accelerator, the prefab is imported correctly.

    So I was wondering if there was a way to update/clear the cache for that particular prefab. Note that I do not want to clear the entire cache as it takes many hours to rebuild.

    One workaround for the moment is to modify that prefab slightly (like slightly changing a value somewhere) this seems to create a new "version" of the asset in the cache and that one works ok. But if we ever go back to the previous values we get the error again.

    Thanks
     
    futurlab_xbox likes this.
  2. bradunity

    bradunity

    Unity Technologies

    Joined:
    Nov 12, 2013
    Posts:
    195
    Yes, @alexvector, it is possible to remove any items in the Accelerator, though it's not an easy process (yet). Here's what you'll want to do:
    1. When you go back to the original settings for your asset and reimport it, you should find a log that looks something like the following in your Editor.log:
    2. With the above information, you can use the Accelerator's tooling to have that artifact removed from its cache by executing something like this:
      Code (Csharp):
      1. unity-accelerator tool delete 192.168.0.114:10080 78b2fdc254b0a4f8a4693a81bb96598a 7bd4d20d898b2064c9ce47b5073e92f3
    3. Now, you should be able establish all the correct settings for your asset and reimport it which should populate the Accelerator's cache with the artifact you want preserved.
     
    littledwarf and alexvector like this.
  3. alexvector

    alexvector

    Joined:
    Oct 9, 2019
    Posts:
    26
    Thanks for the help. That delete command worked and it fixed the issue for that prefab for now.

    I think I know what happened, but it raised another issue.

    We have two Unity projects (a client and a server) that share some assets using symlinks. The client and the server share the same scrips, but with different Define Symbols in the project. A MonoBehavior has some of the code inside a #ifdef SERVER where some of the serialized fields are defined (not an ideal design, but it is what we have at the moment). If that prefab happened to be first loaded and cached by the server project, it would cache an "incorrect" version.

    We use the command line to enable the cache so I tried to add "-cacheServerNamespacePrefix GameServer" to the command line (as documented here https://forum.unity.com/threads/usage-in-batchmode.819543/) but it does not appear to work. The namespace hash in the log appears the same, whatever the prefix I set, and it still downloads assets where I would expect it to upload a new version of it for the new namespace.

    Am I understanding the use of cacheServerNamespacePrefix correctly?

    I tried "-cacheServerEnableUpload false". This one appears to work but I would rather use the namespace prefix if possible.

    Thanks again,
    Alex
     
  4. alexvector

    alexvector

    Joined:
    Oct 9, 2019
    Posts:
    26
    A bit more info:

    When I setup the cache server in the Project Settings and set a Namespace Prefix there, it works as expected. However when I set it through the cacheServerNamespacePrefix command line, it has no effect.
     
    bradunity likes this.
  5. bradunity

    bradunity

    Unity Technologies

    Joined:
    Nov 12, 2013
    Posts:
    195
    You found a bug, @alexvector. Sure enough, in 2019.3 our logic only uses the value set in the Project Settings. The command line option is effectively ignored. I suspect it's not helpful for your case, but it has been fixed in 2020.1 and that team is evaluating if it can be backported to 2019.3 (or possibly for the 2019 LTS release).
     
    alexvector likes this.
  6. alexvector

    alexvector

    Joined:
    Oct 9, 2019
    Posts:
    26
    Thanks for the info. It would be nice if it is back-ported to 2019.3 since we don't plan on moving to 2020 anytime soon. But in the mean time I "unshared" the EditorSettings for the game server project to set the prefix manually.
     
  7. Kichang-Kim

    Kichang-Kim

    Joined:
    Oct 19, 2010
    Posts:
    952
    @bradunity Hi, I have same issue that Accelerator distributes broken asset caches. Is there any method for updating broken asset cache from Unity? If I manually re-import broken asset in unity, it fixed only that Unity project and Accelerator still has broken cache (even editor log says RemoteAssetCache Add Artifacts true). So other projects still downloads broken cache.

    Only possible way is deleting cachedb* and restart Accelerator from white then it needs 1+day for re-creating cache.

    The old Unity-Cache-Server updates its cache if asset is reimported but Accelerator doesn't. Is it intended behaviour or bug? If it is intended, is there any plan to improve handling broken cache?
     
  8. bradunity

    bradunity

    Unity Technologies

    Joined:
    Nov 12, 2013
    Posts:
    195
    @Kichang-Kim, it should definitely be the same behavior when using the new Asset Import Pipeline (v2) as the legacy pipeline (v1). When you reimport an asset it should update the local database and, if in use, the Accelerator. If this does not happen for your use case, then I'd recommend opening a bug, or, if you'd prefer, you can send me your Editor.log privately and we can try to determine what might be tripping things up in your project.
     
  9. Kichang-Kim

    Kichang-Kim

    Joined:
    Oct 19, 2010
    Posts:
    952
    Unfortunately, I lost my editor log when trying manual re-import. For now, I reset my all cache and everything works without problem. If the issue occurs again, I'll open the bug ticket.
     
    bradunity likes this.