orientdb: "missing session and token" after a period of time without interacting with OrientDB

OrientDB Version: 3.0.19

Java Version: 1.8.0_212

OS: Alpine Linux

Expected behavior

Do required operations without an exception

Actual behavior

Get an exception when attempting to reach to OrientDB after a period of time without interacting with it.

Steps to reproduce

  1. Start the app
  2. The app will reach to the database for some initialization.
  3. Wait a bit (can’t say how long, but I think 5m should be more than enough)
  4. Do an operation that will make the app reach the database again

Relevant Issues

Issue #8772

Relevant Logs

com.orientechnologies.orient.enterprise.channel.binary.OTokenSecurityException: missing session and token
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_191]
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_191]
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_191]
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_191]
	at com.orientechnologies.orient.client.binary.OChannelBinaryAsynchClient.handleException(OChannelBinaryAsynchClient.java:338) ~[orientdb-client-3.0.18.jar:3.0.18]
	at com.orientechnologies.orient.client.binary.OChannelBinaryAsynchClient.handleStatus(OChannelBinaryAsynchClient.java:285) ~[orientdb-client-3.0.18.jar:3.0.18]
	at com.orientechnologies.orient.client.binary.OChannelBinaryAsynchClient.handleStatus(OChannelBinaryAsynchClient.java:307) ~[orientdb-client-3.0.18.jar:3.0.18]
	at com.orientechnologies.orient.client.binary.OChannelBinaryAsynchClient.beginResponse(OChannelBinaryAsynchClient.java:196) ~[orientdb-client-3.0.18.jar:3.0.18]
	at com.orientechnologies.orient.client.binary.OChannelBinaryAsynchClient.beginResponse(OChannelBinaryAsynchClient.java:158) ~[orientdb-client-3.0.18.jar:3.0.18]
	at com.orientechnologies.orient.client.remote.OStorageRemote.beginResponse(OStorageRemote.java:1953) ~[orientdb-client-3.0.18.jar:3.0.18]
	at com.orientechnologies.orient.client.remote.OStorageRemote.lambda$networkOperationRetryTimeout$2(OStorageRemote.java:348) ~[orientdb-client-3.0.18.jar:3.0.18]
	at com.orientechnologies.orient.client.remote.OStorageRemote.baseNetworkOperation(OStorageRemote.java:407) ~[orientdb-client-3.0.18.jar:3.0.18]
	at com.orientechnologies.orient.client.remote.OStorageRemote.networkOperationRetryTimeout(OStorageRemote.java:331) ~[orientdb-client-3.0.18.jar:3.0.18]
	at com.orientechnologies.orient.client.remote.OStorageRemote.networkOperation(OStorageRemote.java:365) ~[orientdb-client-3.0.18.jar:3.0.18]
	at com.orientechnologies.orient.client.remote.OStorageRemote.query(OStorageRemote.java:1011) ~[orientdb-client-3.0.18.jar:3.0.18]
	at com.orientechnologies.orient.core.db.document.ODatabaseDocumentRemote.query(ODatabaseDocumentRemote.java:368) ~[orientdb-client-3.0.18.jar:3.0.18]
	...

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 1
  • Comments: 16 (14 by maintainers)

Most upvoted comments

@wolf4ood ok managed to find it alone - you’re gonna love me.

The issue is on this line: https://github.com/orientechnologies/orientdb/blob/develop/server/src/main/java/com/orientechnologies/orient/server/OClientConnection.java#L165

The connection attempt to validate the session, and since all bytes are equal - it assumes valid. The method below it though ( https://github.com/orientechnologies/orientdb/blob/develop/server/src/main/java/com/orientechnologies/orient/server/OClientConnection.java#L182 ) is crucial - it not only validates the token and return the result, it also sets the validity field on the token class it self ( https://github.com/orientechnologies/orientdb/blob/develop/server/src/main/java/com/orientechnologies/orient/server/token/OTokenHandlerImpl.java#L163 ).

Since the method is never called, the isValid field of the token is never changed, and always stays at the default, false.

Then, in the client connection manager, when the token expiry has passed (happens after 1h of no communication), and the valid flag is false (always), it is removed from the connection manager: https://github.com/orientechnologies/orientdb/blob/develop/server/src/main/java/com/orientechnologies/orient/server/OClientConnectionManager.java#L117

Let me know if you need more information.

p.s. Thank you and/or love notes can be sent directly to my email 😉