runtime icon indicating copy to clipboard operation
runtime copied to clipboard

[CI Failure] System.Transactions.Tests hung and timed out build

Open jamesqo opened this issue 9 years ago • 26 comments

Found this in a code coverage build, which did not complete due to this. See https://ci.dot.net/job/dotnet_corefx/job/master/job/code_coverage_windows_prtest/24/consoleFull#10606384068101fac1-935e-4556-95f9-7a0e25ca0b52; note the difference in times on the left.

jamesqo avatar Feb 18 '17 04:02 jamesqo

Sorry for my lack of knowledge. Where do I find the testresults.xml for this?

jimcarley avatar Feb 19 '17 00:02 jimcarley

Again - https://ci.dot.net/job/dotnet_corefx/job/master/job/code_coverage_windows/106/consoleText

@mmitche - do we archive testresults.xml anywhere? @jimcarley meanwhile you could try looping it overnight locally. I am not sure if there is a better way than putting the xunit command line in a batch file with a loop.

danmoseley avatar Feb 21 '17 00:02 danmoseley

@danmosemsft Probably not. It's unlikely to show anything too interesting anyway. I copied the build to a new version which will not abort after 2 hours. When we see the issue we can login and take a look live on the machine:

https://ci.dot.net/job/dotnet_corefx/job/master/job/code_coverage_windows_hangdebug/

mmitche avatar Feb 21 '17 18:02 mmitche

@danmosemsft It will run every hour, not concurrently. We should see a failure today.

mmitche avatar Feb 21 '17 18:02 mmitche

Adding @qizhanMS for visibility.

It's not clear to me. Is this an intermittent problem? Do we have an idea of when the problem started happening? Since this only seems to be happening for coverage builds, could there be something we are missing in the initialization of our tests that could cause this?

jimcarley avatar Feb 21 '17 20:02 jimcarley

Our code coverage runs appear to be hanging because of this. I logged on to one of the CI machines and grabbed some data from the hung process. https://ci.dot.net/job/dotnet_corefx/job/master/job/code_coverage_windows/109/consoleText

There are two threads that are stuck: image Both of them are blocked waiting for a Monitor to be signaled inside of CommitableTransaction.Commit: image

One of them is coming from from CloneTxTests.Run with these options: image

The other is coming from the TransactionScopeTest.RMFail2 test.

In the first case, here's the state of the transaction:

? _internalTransaction
{System.Transactions.InternalTransaction}
    AbsoluteTimeout: 21
    CreationTime: 636233650690232020
    DistributedTxId: {00000000-0000-0000-0000-000000000000}
    PromotedTransaction: null
    State: {System.Transactions.TransactionStatePhase0}
    TransactionHash: 78
    TransactionTraceId: {System.Transactions.TransactionTraceIdentifier}
    _abortingDependentClone: null
    _abortingDependentCloneCount: 0
    _absoluteTimeout: 21
    _asyncCallback: null
    _asyncCommit: false
    _asyncResultEvent: null
    _asyncState: null
    _attemptingPSPEPromote: false
    _bucketIndex: 2
    _cloneCount: 2
    _committableTransaction: {System.Transactions.CommittableTransaction}
    _creationTime: 636233650690232020
    _currentStateHist: 2
    _distributedTransactionIdentifierNonMSDTC: {00000000-0000-0000-0000-000000000000}
    _durableEnlistment: null
    _enlistmentCount: 0
    _finalizedObject: null
    _innerException: null
    _needPulse: true
    _outcomeSource: {System.Transactions.CommittableTransaction}
    _phase0VolatileWaveCount: 0
    _phase0Volatiles: {System.Transactions.VolatileEnlistmentSet}
    _phase0WaveDependentClone: null
    _phase0WaveDependentCloneCount: 0
    _phase1Volatiles: {System.Transactions.VolatileEnlistmentSet}
    _promoteState: {System.Transactions.TransactionStatePromoted}
    _promotedTransaction: null
    _promoter: null
    _promoterType: {00000000-0000-0000-0000-000000000000}
    _stateHistory: {System.Transactions.TransactionState[20]}
    _tableBucket: {System.Transactions.Bucket}
    _traceIdentifier: {System.Transactions.TransactionTraceIdentifier}
    _traceIdentifierInited: true
    _transactionCompletedDelegate: null
    _transactionHash: 78
    _transactionInformation: {System.Transactions.TransactionInformation}
    _transactionState: {System.Transactions.TransactionStatePhase0}
    promotedToken: null
? _internalTransaction.State.IsCompleted(_internalTransaction)
false

stephentoub avatar Feb 22 '17 13:02 stephentoub

Both of these tests expect the transaction to timeout, but apparently it is not.

Is there any chance to get a dump when this happens? We need to see what is going on with the TransactionTable, which is used to timeout transactions. We have had issues with this previously, but those issues were the reverse - transactions were timing out up to half a second too early. The TransactionTable uses a timer to trigger timeouts. I don't know if there is an issue with processing timer wake ups or if the timer is misbehaving in some way.

Note that this might also explain the intermittent failures of the NonMsdtcPromoterTest that we have seen due to transactions not timing out.

jimcarley avatar Feb 22 '17 16:02 jimcarley

@jimcarley, I'll follow-up with you offline.

stephentoub avatar Feb 22 '17 17:02 stephentoub

@jimcarley, I'll share a dump with you.

I took a look at the TransactionTable. Not sure exactly what I'm looking for, but there don't appear to be any transactions in the table:

? System.Transactions.TransactionManager.TransactionTable
{System.Transactions.TransactionTable}
    CurrentTime: Cannot evaluate expression because a thread is stopped at a point where garbage collection is impossible, possibly because the code is optimized.
    _headBucketSet: {System.Transactions.BucketSet}
    _lastTimerTime: 636233767260197969
    _rwLock: {System.Transactions.CheapUnfairReaderWriterLock}
    _ticks: 144
    _timer: {System.Threading.Timer}
    _timerEnabled: false
    _timerInterval: 512
? System.Transactions.TransactionManager.TransactionTable._headBucketSet
{System.Transactions.BucketSet}
    AbsoluteTimeout: 9223372036854775807
    _absoluteTimeout: 9223372036854775807
    _table: {System.Transactions.TransactionTable}
    headBucket: {System.Transactions.Bucket}
    nextSetWeak: null
    prevSet: null
? System.Transactions.TransactionManager.TransactionTable._headBucketSet.headBucket
{System.Transactions.Bucket}
    _index: 0
    _owningSet: {System.Transactions.BucketSet}
    _previous: null
    _size: 1024
    _timedOut: false
    _transactions: {System.Transactions.InternalTransaction[1024]}
    nextBucketWeak: null
? System.Linq.Enumerable.Count(System.Transactions.TransactionManager.TransactionTable._headBucketSet.headBucket._transactions, t => t != null)
0

stephentoub avatar Feb 22 '17 17:02 stephentoub

I tried to run the tests using "build -Coverage -BuildTests", all System.Transactions tests passed. What command should I use to get repro on my dev machine?

qizhanMS avatar Feb 22 '17 22:02 qizhanMS

I don't believe any of us have repro'd it locally. But it's been happening frequently in the lab. I sent Jim a dump earlier.

stephentoub avatar Feb 22 '17 22:02 stephentoub

@jimcarley any luck?

danmoseley avatar Mar 10 '17 21:03 danmoseley

Not yet.

In the dump we found that the data structures surrounding the transaction timeout processing were in an "unexpected" state, but we have not yet found how that statecould happen. We had one theory revolving around the single half-second timer we use to wake up and check to see if any transactions needed to be timed out. I hypothesized that we could get the data structures into the state in the dump if a second timer wakeup occurred while the thread that was processing the previous wake up was still processing AND the second wakeup caused the thread of the first wakeup to get "canceled" at an inopportune time. But experimentation with multiple timer wake ups like this showed that the first wakeup thread is not canceled when the second wakeup thread gets started.

I may still put in code that tries to avoid having two timer wakeup threads from running at the same time.

I have also experimented with changes that would help to avoid the "hang" by using asynchronous commit, but the tests would still fail if the transactions did not time out. But this approach would be "ugly" for the TransactionScope test because the commit call is made inside the product code for TransactionScope rather than in the test code. So I would need to run the test on a separate thread and then wait for that thread to set an event indicating that it is done. That wait for event would then have a timeout that is a bit longer than the transaction timeout and it would fail the test if it timed out waiting for the thread executing the test to complete.

jimcarley avatar Mar 10 '17 21:03 jimcarley

This hit CI again. Thanks for your work on this -- especially since it might be a product issue

danmoseley avatar Mar 14 '17 17:03 danmoseley

Is this time also failed when running code coverage?

qizhanMS avatar Mar 14 '17 17:03 qizhanMS

Yes

stephentoub avatar Mar 14 '17 18:03 stephentoub

Hi @jimcarley @qizhanMS any further progress on this one? Did you end up doing this:

I may still put in code that tries to avoid having two timer wakeup threads from running at the same time.

Given this is code coverage only, I'm going to move to Future. Please correct if you wish.

danmoseley avatar Apr 19 '17 15:04 danmoseley

@qizhanMS failed a CI job:

https://ci.dot.net/job/dotnet_corefx/job/master/job/netfx_windows_nt_debug_prtest/752/testReport/junit/System.Transactions.Tests/CloneTxTests/Run_cloneType__BlockingDependent__isoLevel__Snapshot__forcePromote__False__completeClone__False__expectedStatus__Aborted_/

System.Transactions.Tests.CloneTxTests.Run(cloneType: BlockingDependent, isoLevel: Snapshot, forcePromote: False, completeClone: False, expectedStatus: Aborted) (from System.Transactions.Local.Tests)

Failing for the past 1 build (Since Failed#752 )
Took 6 ms.
Stacktrace

MESSAGE:
Assert.Equal() Failure\r\nExpected: Active\r\nActual: Aborted
+++++++++++++++++++
STACK TRACE:
at System.Transactions.Tests.CloneTxTests.Run(CloneType cloneType, IsolationLevel isoLevel, Boolean forcePromote, Boolean completeClone, TransactionStatus expectedStatus) in D:\j\workspace\netfx_windows---8c0e8fba\src\System.Transactions.Local\tests\CloneTxTests.cs:line 116

[edit] Actually, that's a netfx run -- CoreFX tests on full framework. So not a bug in corefx implementation. Leaving this here in case that's relevant.

danmoseley avatar May 26 '17 04:05 danmoseley

AGain https://ci.dot.net/job/dotnet_corefx/job/master/job/code_coverage_windows/331/consoleFull#-9314352818101fac1-935e-4556-95f9-7a0e25ca0b52

danmoseley avatar Sep 27 '17 20:09 danmoseley

Hi, Dan,

Do you have more detail on this failure?

Thanks,

Qi

From: Dan Moseley [mailto:[email protected]] Sent: Wednesday, September 27, 2017 1:25 PM To: dotnet/corefx [email protected] Cc: Qi Zhang (APPPLAT FUN) [email protected]; Mention [email protected] Subject: Re: [dotnet/corefx] [CI Failure] System.Transactions.Tests hung and timed out build (#16283)

AGain https://ci.dot.net/job/dotnet_corefx/job/master/job/code_coverage_windows/331/consoleFull#-9314352818101fac1-935e-4556-95f9-7a0e25ca0b52https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fci.dot.net%2Fjob%2Fdotnet_corefx%2Fjob%2Fmaster%2Fjob%2Fcode_coverage_windows%2F331%2FconsoleFull%23-9314352818101fac1-935e-4556-95f9-7a0e25ca0b52&data=02%7C01%7Cqizhan%40microsoft.com%7Cdb5bc920290040f12cbc08d505e5c902%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636421406836167434&sdata=31IQFb5BqEsuLyun012Rpxto8RWFA14vvyVdARi45DM%3D&reserved=0

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fdotnet%2Fcorefx%2Fissues%2F16283%23issuecomment-332643872&data=02%7C01%7Cqizhan%40microsoft.com%7Cdb5bc920290040f12cbc08d505e5c902%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636421406836167434&sdata=WzDDaaAFEarkz8cNNOrP5ON8tRSYIh1WFs%2BxxtFsj48%3D&reserved=0, or mute the threadhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAVJfU6XXmd5_oaU9Pn7Xk92XOW9lnF2Oks5smq8IgaJpZM4ME_rZ&data=02%7C01%7Cqizhan%40microsoft.com%7Cdb5bc920290040f12cbc08d505e5c902%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636421406836167434&sdata=xot05B3uoSr%2F8YgdpDkFjHXpxy4ZA81quI2DIxIyfYY%3D&reserved=0.

qizhanMS avatar Sep 27 '17 20:09 qizhanMS