Exemplo n.º 1
0
        /// <summary>
        /// Primary: Process the logical log record.
        /// </summary>
        /// <param name="record"></param>
        /// <returns></returns>
        /// <remarks>
        /// Wait for the logical record to be flushed and replicated.
        /// If it is a barrier, increase stable lsn.
        /// If it is a operation record, unlock it.
        /// </remarks>
        private async Task ProcessLogicalRecordOnPrimaryAsync(TransactionLogRecord record)
        {
            Exception exception = null;

            this.ReplicateAndLogLogicalRecord(record);

            try
            {
                // Wait for the record to be flushed and replicated
                await Task.WhenAll(record.AwaitApply(), LoggingReplicator.AwaitReplication(record, this.replicatedLogManager)).ConfigureAwait(false);
            }
            catch (Exception e)
            {
                exception = e;
            }
            finally
            {
                this.InvokeUnlockCallback(record);
            }

            // Throw TransactionFaultedException if there has been any failure during replication and apply awaits.
            if (exception != null)
            {
                throw new TransactionFaultedException(exception.Message);
            }

            return;
        }
Exemplo n.º 2
0
        private void ProcessLogicalRecordOnPrimary(TransactionLogRecord record)
        {
            this.ReplicateAndLogLogicalRecord(record);

            Task.WhenAll(record.AwaitApply(), LoggingReplicator.AwaitReplication(record, this.replicatedLogManager)).IgnoreException().ContinueWith(
                task =>
            {
                // Simply retrieve task exception to mark it as handled
                if (task.Exception != null)
                {
                    Utility.Assert(task.IsFaulted == true, "task.IsFaulted == true");
                }

                this.InvokeUnlockCallback(record);
            }).IgnoreExceptionVoid();
        }