[JAVA-2448] Spurious exception in maintenance task Created: 13/Feb/17  Updated: 06/Apr/23  Resolved: 25/Apr/17

Status: Closed
Project: Java Driver
Component/s: Connection Management
Affects Version/s: 3.4.1
Fix Version/s: 3.5.0

Type: Bug Priority: Minor - P4
Reporter: Christian Finckler Assignee: Ross Lawley
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

I use version 3.4.1 and get the following exception during restart of the application:
exception thrown during connection pool background maintenance task

java.lang.InterruptedException: null
	at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(Unknown Source)
	at java.util.concurrent.Semaphore.acquire(Unknown Source)
	at com.mongodb.internal.connection.ConcurrentPool.acquirePermit(ConcurrentPool.java:182)
	... 38 common frames omitted
Wrapped by: com.mongodb.MongoInterruptedException: Interrupted acquiring a permit to retrieve an item from the pool 
	at com.mongodb.internal.connection.ConcurrentPool.acquirePermit(ConcurrentPool.java:186)
	at com.mongodb.internal.connection.ConcurrentPool.get(ConcurrentPool.java:126)
	at com.mongodb.internal.connection.ConcurrentPool.get(ConcurrentPool.java:109)
	at com.mongodb.internal.connection.PowerOfTwoBufferPool.getBuffer(PowerOfTwoBufferPool.java:76)
	at com.mongodb.connection.SocketStream.getBuffer(SocketStream.java:69)
	at com.mongodb.connection.InternalStreamConnection.getBuffer(InternalStreamConnection.java:514)
	at com.mongodb.connection.ByteBufferBsonOutput.getByteBufferAtIndex(ByteBufferBsonOutput.java:91)
	at com.mongodb.connection.ByteBufferBsonOutput.getCurrentByteBuffer(ByteBufferBsonOutput.java:80)
	at com.mongodb.connection.ByteBufferBsonOutput.writeByte(ByteBufferBsonOutput.java:75)
	at org.bson.io.OutputBuffer.write(OutputBuffer.java:150)
	at org.bson.io.OutputBuffer.writeInt32(OutputBuffer.java:56)
	at com.mongodb.connection.RequestMessage.writeMessagePrologue(RequestMessage.java:171)
	at com.mongodb.connection.RequestMessage.encodeWithMetadata(RequestMessage.java:159)
	at com.mongodb.connection.RequestMessage.encode(RequestMessage.java:147)
	at com.mongodb.connection.CommandHelper.sendMessage(CommandHelper.java:88)
	at com.mongodb.connection.CommandHelper.executeCommand(CommandHelper.java:32)
	at com.mongodb.connection.SaslAuthenticator.sendSaslContinue(SaslAuthenticator.java:121)
	at com.mongodb.connection.SaslAuthenticator.access$100(SaslAuthenticator.java:37)
	at com.mongodb.connection.SaslAuthenticator$1.run(SaslAuthenticator.java:63)
	... 20 common frames omitted
Wrapped by: com.mongodb.MongoSecurityException: Exception authenticating MongoCredential{mechanism=null, userName='composing', source='composing', password=<hidden>, mechanismProperties={}}
	at com.mongodb.connection.SaslAuthenticator.wrapInMongoSecurityException(SaslAuthenticator.java:157)
	at com.mongodb.connection.SaslAuthenticator.access$200(SaslAuthenticator.java:37)
	at com.mongodb.connection.SaslAuthenticator$1.run(SaslAuthenticator.java:66)
	at com.mongodb.connection.SaslAuthenticator$1.run(SaslAuthenticator.java:44)
	at com.mongodb.connection.SaslAuthenticator.doAsSubject(SaslAuthenticator.java:162)
	at com.mongodb.connection.SaslAuthenticator.authenticate(SaslAuthenticator.java:44)
	at com.mongodb.connection.DefaultAuthenticator.authenticate(DefaultAuthenticator.java:32)
	at com.mongodb.connection.InternalStreamConnectionInitializer.authenticateAll(InternalStreamConnectionInitializer.java:109)
	at com.mongodb.connection.InternalStreamConnectionInitializer.initialize(InternalStreamConnectionInitializer.java:46)
	at com.mongodb.connection.InternalStreamConnection.open(InternalStreamConnection.java:116)
	at com.mongodb.connection.UsageTrackingInternalConnection.open(UsageTrackingInternalConnection.java:47)
	at com.mongodb.connection.DefaultConnectionPool$UsageTrackingInternalConnectionItemFactory.create(DefaultConnectionPool.java:494)
	at com.mongodb.connection.DefaultConnectionPool$UsageTrackingInternalConnectionItemFactory.create(DefaultConnectionPool.java:482)
	at com.mongodb.internal.connection.ConcurrentPool.createNewAndReleasePermitIfFailure(ConcurrentPool.java:164)
	at com.mongodb.internal.connection.ConcurrentPool.ensureMinSize(ConcurrentPool.java:158)
	at com.mongodb.connection.DefaultConnectionPool$3.run(DefaultConnectionPool.java:302)
	at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
	at java.util.concurrent.FutureTask.runAndReset(Unknown Source)
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(Unknown Source)
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
Exception thrown during connection pool background maintenance task

There exists already the issue JAVA-2123. But the solution does not seem to work here. In that solution the provided bugfix catched the MongoInteruptedException. But in this exception the MongoInteruptedException gets wrapped inside a securityException. Thats why the catch block in the defaultConnectionPool is not working.



 Comments   
Comment by Githook User [ 25/Apr/17 ]

Author:

{u'username': u'rozza', u'name': u'Ross Lawley', u'email': u'ross.lawley@gmail.com'}

Message: Ensure that MongoInterruptedExceptions are not wrapped in a MongoSecurityException

JAVA-2448
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/1bd198eb87e3f398afed770dc654f104a82af318

Comment by Ross Lawley [ 25/Apr/17 ]

PR: https://github.com/rozza/mongo-java-driver/pull/189

Generated at Thu Feb 08 08:57:15 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.