Ejemplo n.º 1
0
        internal async Task <ExecuteResponse> executeOrAbort(StoreConnection c, ExecuteRequest ex)
        {
            if (c == null)
            {
                connsMu.EnterReadLock();
                try
                {
                    c = conns[defaultConnID];
                }
                finally
                {
                    connsMu.ExitReadLock();
                }
            }
            bool errored = false;

            try
            {
                var f = await c.Store.execute(c, ex);

                errored = f.Results.Any(r => !string.IsNullOrEmpty(r.Error));
                return(f);
            }
            catch (Exception e)
            {
                errored = true;
                c.Logger.LogError(e.ToString());
                throw;
            }
            finally
            {
                if (errored)
                {
                    try
                    {
                        await c.AbortTransaction();
                    }
                    catch (Exception e)
                    {
                        c.Logger.LogWarning($"WARNING: failed to abort transaction on {c}: {e.Message}");
                    }
                }
            }
        }