MantisBT - opensim
View Issue Details
0004544opensim[MISC] Compiling / Buildingpublic2010-01-23 22:162011-08-20 07:40
VikingErik 
justincc 
normaltweakalways
patch feedbackopen 
master (dev code) 
 
48776b4a06a92a3428d2abf964cdb301017f2c55
Standalone (1 Region)
BasicPhysics
.NET / Windows64
None
0004544: Added async updates of Asset and Estates in SQLite storage mode
Saw a comment while browsing the source requesting async updates to data tier. The attached patch adds initial support for SQLite updates in Asset (and Estate since it was a similar change.) On local development box the startup time was reduced from over 30 seconds consistently to under 10 seconds consistently. The changes use the OpenMetavers ThreadUtil.FireAndForget method.
No tags attached.
patch async.patch (2,301) 2010-01-23 22:16
http://opensimulator.org/mantis/file_download.php?file_id=2263&type=bug
patch sqlite-storeasset-async.patch (2,435) 2010-01-31 12:02
http://opensimulator.org/mantis/file_download.php?file_id=2273&type=bug
Issue History
2010-01-23 22:16VikingErikNew Issue
2010-01-23 22:16VikingErikFile Added: async.patch
2010-01-23 22:16VikingErikGit Revision => 48776b4a06a92a3428d2abf964cdb301017f2c55
2010-01-23 22:16VikingErikSVN Revision => 0
2010-01-23 22:16VikingErikRun Mode => Standalone (1 Region)
2010-01-23 22:16VikingErikPhysics Engine => BasicPhysics
2010-01-23 22:16VikingErikEnvironment => .NET / Windows64
2010-01-23 22:16VikingErikMono Version => None
2010-01-23 22:17VikingErikStatusnew => patch included
2010-01-29 13:58justinccNote Added: 0014898
2010-01-29 13:58justinccStatuspatch included => patch feedback
2010-01-29 19:53VikingErikNote Added: 0014914
2010-01-31 12:02VikingErikFile Added: sqlite-storeasset-async.patch
2010-01-31 12:09VikingErikNote Added: 0014924
2010-01-31 12:09VikingErikStatuspatch feedback => patch included
2010-02-12 14:59justinccNote Added: 0014968
2011-08-20 07:39makopoppoStatuspatch included => patch feedback
2011-08-20 07:40makopoppoAssigned To => justincc

Notes
(0014898)
justincc   
2010-01-29 13:58   
I believe that asynchronous execution here would hide any exception. Could we catch and log anything that does get thrown?
(0014914)
VikingErik   
2010-01-29 19:53   
Looking at the existing code, the class isn't doing any catching and reporting of exceptions right now. The events are bubbling up the call stack and waiting to be caught elsewhere. With Fire and Forget it's true the specific exception could be lost and an error would happen elsewhere up the stack.

This can be changed to catch the callback when the thread ends and log any exceptions that come with it. (Exceptions thrown while a delegate is executing asynchronously is caught and returned with the IAsyncResult on EndInvoke call.)

If this is desired, I suggest an alteration to the class for more robust error handling (such as attempting a reconnect, printing a specific message to the log, etc.)

How would you suggest handling the errors? Refactoring to grab the exception is possible but since the calling code would have already returned all we can do is log it (and will trail an error up the chain of events because of this.)
(0014924)
VikingErik   
2010-01-31 12:09   
New patch, sqlite-storeasset-async.patch, adds support for asynchronous calls to StoreAsset in the SQLite project. A delegate useable in the other modules is added to the OpenSim.Data.AssetDataBase base class.

This version is an alternate to the other patch which used the FireAndForget method to start the thread and forget about it. This version uses a callback which calls EndInvoke on the thread when it's complete in order to catch any exceptions that may have been thrown while the thread was executing. Right now the exception is logged. There seems to be no uniform way of catching and reporting exceptions so for now we just log it.

This patch is just preliminary support to get community feedback. If the format is acceptable, more updates will be made.
(0014968)
justincc   
2010-02-12 14:59   
I have to confess that I'm still a little scared of this. All the database connectors currently execute this code synchronously and switching to async under the covers breaks the implict contract. There is so much room within OpenSim to introduce subtle race conditions.

I'm still happy to experiment here but if you don't mind, I'd really rather that application of this patch to Master be left until immediately after we branch the 0.7 line.