Fallback when index.bin loading fails

Continuing the discussion from Error : The path must be absolute. (Parameter 'root') after updating HTML5 server to version 1924 (IIS):

Server startup should fallback to go without index.bin when an error occurs while loading it. A warning should appear in a log so it is clear what happened.

So is the problem just the lack of logging? Or is there a problem when handling the errors while loading the index.bin?

We should handle the error and write to the log that we did it. I guess Architect also handles the error/recreates the index.bin.

I’ve just tried to simulate an error when reading from the index.bin and the logging is actually there.

2021-05-06 14:35:56,907 [1] WARN Origam.DA.Service.BinFileLoader - Could not read index file: C:\OrigamProjects\master\proj\index.bin. Removing it...
ProtoBuf.ProtoException: TestMessage
   at Origam.DA.Service.BinFileLoader.LoadBinFile() in C:\Repos\origam-source\Origam.DA.Service\BinFileLoader.cs:line 174

We are only cathing exceptions of type ProtoException. Which I think is ok. Should we catch and not propagate everything there?

Not sure what caused it but such error messages don’t help anyone – the only solution is deleting an index.bin anyway. So I would guess that any kind of an unexpected exception should be handled when touching index.bin.

2021-05-06 09:52:46,417 [1] FATAL Microsoft.AspNetCore.Hosting.WebHost - Application startup exception
System.Collections.Generic.KeyNotFoundException: The given key '1' was not present in the dictionary.
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at Origam.DA.Service.AutoIncrementedIntIndex`1.get_Item(Int32 id) in D:\a\1\s\Origam.DA.Service\FileTracking\ItemTracker.cs:line 395
   at Origam.DA.Service.TrackerSerializationData.OrigamFileSerializedForm.<>c__DisplayClass14_0.<GetOrigamFile>b__0(KeyValuePair`2 entry) in D:\a\1\s\Origam.DA.Service\FileTracking\TrackerSerializationData.cs:line 167
   at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
   at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector)
   at Origam.DA.Service.TrackerSerializationData.OrigamFileSerializedForm.GetOrigamFile(TrackerSerializationData trackerData, OrigamFileFactory origamFileFactory) in D:\a\1\s\Origam.DA.Service\FileTracking\TrackerSerializationData.cs:line 162
   at Origam.DA.Service.TrackerSerializationData.<>c__DisplayClass18_0.<TransformBack>b__0(OrigamFileSerializedForm serForm) in D:\a\1\s\Origam.DA.Service\FileTracking\TrackerSerializationData.cs:line 101
   at System.Linq.Enumerable.SelectListIterator`2.ToList()
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at Origam.DA.Service.TrackerSerializationData.TransformBack(OrigamFileFactory origamFileFactory) in D:\a\1\s\Origam.DA.Service\FileTracking\TrackerSerializationData.cs:line 99
   at Origam.DA.Service.TrackerSerializationData.GetOrigamFiles(OrigamFileFactory origamFileFactory) in D:\a\1\s\Origam.DA.Service\FileTracking\TrackerSerializationData.cs:line 35
   at Origam.DA.Service.BinFileLoader.LoadInto(ItemTracker itemTracker) in D:\a\1\s\Origam.DA.Service\BinFileLoader.cs:line 140
   at Origam.DA.Service.FilePersistenceIndex.<>c__DisplayClass32_0.<InitItemTracker>b__0() in D:\a\1\s\Origam.DA.Service\FilePersistenceIndex.cs:line 213
   at Origam.Extensions.ReaderWriterLockSlimExtensions.RunWriter(ReaderWriterLockSlim rwLock, Action action) in D:\a\1\s\Origam.Common\Extensions\ReaderWriterLockSlimExtensions.cs:line 35
   at Origam.DA.Service.FilePersistenceIndex.InitItemTracker(TrackerLoaderFactory trackerLoaderFactory, Boolean tryUpgrade) in D:\a\1\s\Origam.DA.Service\FilePersistenceIndex.cs:line 208
   at Origam.Workbench.Services.FilePersistenceService..ctor(IMetaModelUpgradeService metaModelUpgradeService, IList`1 defaultFolders, String pathToRuntimeModelConfig, String basePath, Boolean watchFileChanges, Boolean useBinFile, Boolean checkRules, Boolean tryUpgrade) in D:\a\1\s\Origam.Workbench.Services\FilePersistenceService.cs:line 102
   at Origam.OrigamEngine.FilePersistenceBuilder.CreateNewPersistenceService(Boolean watchFileChanges, Boolean checkRules, Boolean useBinFile) in D:\a\1\s\Origam.OrigamEngine\FilePersistenceBuilder.cs:line 75
   at Origam.OrigamEngine.FilePersistenceBuilder.GetPersistenceService(Boolean watchFileChanges, Boolean checkRules, Boolean useBinFile) in D:\a\1\s\Origam.OrigamEngine\FilePersistenceBuilder.cs:line 50
   at Origam.OrigamEngine.FilePersistenceBuilder.GetPersistenceService() in D:\a\1\s\Origam.OrigamEngine\FilePersistenceBuilder.cs:line 44
   at Origam.OrigamEngine.RuntimeServiceFactory.CreatePersistenceService() in D:\a\1\s\Origam.OrigamEngine\RuntimeServiceFactory.cs:line 91
   at Origam.OrigamEngine.RuntimeServiceFactory.InitializeServices() in D:\a\1\s\Origam.OrigamEngine\RuntimeServiceFactory.cs:line 42
   at Origam.OrigamEngine.OrigamEngine.ConnectRuntime(String configName, Boolean runRestartTimer, Boolean loadDeploymentScripts, IRuntimeServiceFactory customServiceFactory) in D:\a\1\s\Origam.OrigamEngine\OrigamEngine.cs:line 129
   at Origam.ServerCore.Startup.Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) in D:\a\1\s\Origam.ServerCore\Startup.cs:line 263
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Microsoft.AspNetCore.Hosting.ConfigureBuilder.Invoke(Object instance, IApplicationBuilder builder)
   at Microsoft.AspNetCore.Hosting.ConfigureBuilder.<>c__DisplayClass4_0.<Build>b__0(IApplicationBuilder builder)
   at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.Configure(IApplicationBuilder app)
   at Microsoft.AspNetCore.Mvc.Filters.MiddlewareFilterBuilderStartupFilter.<>c__DisplayClass0_0.<Configure>g__MiddlewareFilterBuilder|0(IApplicationBuilder builder)
   at Microsoft.AspNetCore.Server.IIS.Core.IISServerSetupFilter.<>c__DisplayClass2_0.<Configure>b__0(IApplicationBuilder app)
   at Microsoft.AspNetCore.HostFilteringStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder app)
   at Microsoft.AspNetCore.Hosting.WebHost.BuildApplication()

Ok. I just thought that exceptions like this should not be ignored

If not it must be clear what to do if one occurs. And if there is only one possible way to get out of it (deleting a file) then we should just do it so the user doesn’t. But we should log the warning, just in case.

What we can do is to ignore in release but throw the exception in DEBUG. What do you think?

I’m not sure it would help not to ignore the exceptions in DEBUG. I is the users with the RELEASE version who encounter this kind of problems

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.