Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OrientDB database cannot be opened after trying to access it through sample code. #359

Closed
lihost opened this issue Mar 10, 2016 · 31 comments
Assignees
Labels

Comments

@lihost
Copy link

lihost commented Mar 10, 2016

OrientDB database getting corrupted after trying to access it through sample code.

Steps to reproduce --
Step1 - Create a database through Studio
Step2 - access it through any sample code[java]
Step3 - Now try to access it through Studio - Gets Err

Sample Code -

OrientGraphFactory oGraphFactory = new OrientGraphFactory("plocal:C:/Users/sam/Documents/Couture/orientdb-2.1.12/databases/StudioDemo2").setupPool(1, 10);
OrientGraph graph = oGraphFactory.getTx();

try{
        System.out.println("Getting OrientDB graph data");
        System.out.println("No. of Edges: "+graph.countEdges());
        System.out.println("No. of Vertices: "+graph.countVertices());
    } catch(Exception e){
        e.printStackTrace();
    } finally {
        graph.shutdown();
    }`

NOTE - Still able to access through code but Studio is throwing error.

CONSOLE ERROR --

2016-03-10 15:49:54:507 SEVER {db=StudioDemo2} Internal server error: com.orientechnologies.orient.core.exception.OStorageException: Cannot open local storage 'C:/Users/sam/Documents/Couture/orientdb-2.1.12/databases/StudioDemo2' with mode=rw --> com.orientechnologies.orient.core.exception.OSerializationException: Cannot load database's configuration. The database seems corrupted --> java.io.IOException: The process cannot access the file because another process has locked a portion of the file [ONetworkProtocolHttpDb]

Current OrientDB version -- Running on Windows 7
Studio version : 2.1
OrientDB version : 2.1.12

@wolf4ood
Copy link
Member

hi @tsohil

the DB is not corrupted. You are trying to open a database from a different JVM process meanwhile the db is locked by the server process.

If you shutdown the server you will be able to run your code.

Thanks

@lihost
Copy link
Author

lihost commented Mar 10, 2016

Hi @maggiolo00,

I have mentioned that I am able to access database through code, but not able to login through OrientDB Studio and during that login its throwing errors[mentioned in previous comment].

What to do if I want to access database again through Studio?
thanks,

@wolf4ood
Copy link
Member

hi @tsohil
one java process can hold the lock on the db. In your code you should use remote instead of plocal.
If your code hold the lock to the db the server cannot open the db so you cannot login with studio.

@lihost
Copy link
Author

lihost commented Mar 10, 2016

Hi @maggiolo00 ,

I tried using remote as per what you suggested. Here are the combinations of urls I tried[as mentioned in one of groups Here], please correct me if I am wrong anywhere.

remote:localhost:2480/StudioDemo2
remote:localhost:2424/StudioDemo2
remote:0.0.0.0:2424/StudioDemo2
remote:0.0.0.0:2480/StudioDemo2

Still no luck!

@wolf4ood
Copy link
Member

which exception do you get with remote?

@lihost
Copy link
Author

lihost commented Mar 10, 2016

Here is a console out.

### INFO: Registered the new available server '0.0.0.0:2480' Exception in thread "main" com.orientechnologies.orient.core.exception.OStorageException: Cannot open a connection to remote server: 0.0.0.0:2480/StudioDemo3 Storage URL="remote:0.0.0.0:2480/StudioDemo3" at com.orientechnologies.orient.client.remote.OStorageRemote.getAvailableNetwork(OStorageRemote.java:2195) at com.orientechnologies.orient.client.remote.OStorageRemote.openRemoteDatabase(OStorageRemote.java:1909) at com.orientechnologies.orient.client.remote.OStorageRemote.openRemoteDatabase(OStorageRemote.java:1848) at com.orientechnologies.orient.client.remote.OStorageRemote.open(OStorageRemote.java:228) at com.orientechnologies.orient.client.remote.OStorageRemoteThread.open(OStorageRemoteThread.java:86) at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.open(ODatabaseDocumentTx.java:247) at com.orientechnologies.orient.core.db.OPartitionedDatabasePool$DatabaseDocumentTxPolled.internalOpen(OPartitionedDatabasePool.java:150) at com.orientechnologies.orient.core.db.OPartitionedDatabasePool.openDatabase(OPartitionedDatabasePool.java:378) at com.orientechnologies.orient.core.db.OPartitionedDatabasePool.acquire(OPartitionedDatabasePool.java:342) at com.tinkerpop.blueprints.impls.orient.OrientBaseGraph.<init>(OrientBaseGraph.java:163) at com.tinkerpop.blueprints.impls.orient.OrientTransactionalGraph.<init>(OrientTransactionalGraph.java:77) at com.tinkerpop.blueprints.impls.orient.OrientGraph.<init>(OrientGraph.java:135) at com.tinkerpop.blueprints.impls.orient.OrientGraphFactory.getTx(OrientGraphFactory.java:75) at tinkerpopSample.App.main(App.java:14) Caused by: com.orientechnologies.common.io.OIOException: Error on connecting to 0.0.0.0:2480/StudioDemo3 at com.orientechnologies.orient.client.remote.ORemoteConnectionPool.createNetworkConnection(ORemoteConnectionPool.java:65) at com.orientechnologies.orient.client.remote.ORemoteConnectionPool.createNewResource(ORemoteConnectionPool.java:71) at com.orientechnologies.orient.client.remote.ORemoteConnectionPool.createNewResource(ORemoteConnectionPool.java:19) at com.orientechnologies.common.concur.resource.OResourcePool.getResource(OResourcePool.java:96) at com.orientechnologies.orient.client.remote.ORemoteConnectionPool.acquire(ORemoteConnectionPool.java:95) at com.orientechnologies.orient.client.remote.ORemoteConnectionManager.acquire(ORemoteConnectionManager.java:88) at com.orientechnologies.orient.client.remote.OStorageRemote.getAvailableNetwork(OStorageRemote.java:2182) ... 13 more Caused by: java.io.IOException: Cannot connect to host 0.0.0.0:2480 at com.orientechnologies.orient.enterprise.channel.binary.OChannelBinaryAsynchClient.<init>(OChannelBinaryAsynchClient.java:89) at com.orientechnologies.orient.client.remote.ORemoteConnectionPool.createNetworkConnection(ORemoteConnectionPool.java:53) ... 19 more Caused by: java.net.SocketTimeoutException: connect timed out at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method) at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:204) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:589) at com.orientechnologies.orient.enterprise.channel.binary.OChannelBinaryAsynchClient.<init>(OChannelBinaryAsynchClient.java:85) ... 20 more Mar 10, 2016 6:20:00 PM com.orientechnologies.common.log.OLogManager log INFO: Orient Engine is shutting down...

@wolf4ood
Copy link
Member

hi @tsohil

can you try with 2424 port.

@lihost
Copy link
Author

lihost commented Mar 10, 2016

Here you go @maggiolo00

###INFO: Registered the new available server '0.0.0.0:2424' Mar 10, 2016 11:01:49 PM com.orientechnologies.common.log.OLogManager log INFO: Registered the new available server '0.0.0.0:2424' Exception in thread "main" com.orientechnologies.orient.core.exception.OStorageException: Cannot open a connection to remote server: 0.0.0.0:2424/StudioDemo3 Storage URL="remote:0.0.0.0:2424/StudioDemo3" at com.orientechnologies.orient.client.remote.OStorageRemote.getAvailableNetwork(OStorageRemote.java:2195) at com.orientechnologies.orient.client.remote.OStorageRemote.openRemoteDatabase(OStorageRemote.java:1909) at com.orientechnologies.orient.client.remote.OStorageRemote.openRemoteDatabase(OStorageRemote.java:1848) at com.orientechnologies.orient.client.remote.OStorageRemote.open(OStorageRemote.java:228) at com.orientechnologies.orient.client.remote.OStorageRemoteThread.open(OStorageRemoteThread.java:86) at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.open(ODatabaseDocumentTx.java:247) at com.orientechnologies.orient.core.db.OPartitionedDatabasePool$DatabaseDocumentTxPolled.internalOpen(OPartitionedDatabasePool.java:150) at com.orientechnologies.orient.core.db.OPartitionedDatabasePool.openDatabase(OPartitionedDatabasePool.java:378) at com.orientechnologies.orient.core.db.OPartitionedDatabasePool.acquire(OPartitionedDatabasePool.java:342) at com.tinkerpop.blueprints.impls.orient.OrientBaseGraph.<init>(OrientBaseGraph.java:163) at com.tinkerpop.blueprints.impls.orient.OrientTransactionalGraph.<init>(OrientTransactionalGraph.java:77) at com.tinkerpop.blueprints.impls.orient.OrientGraph.<init>(OrientGraph.java:135) at com.tinkerpop.blueprints.impls.orient.OrientGraphFactory.getTx(OrientGraphFactory.java:75) at tinkerpopSample.App.main(App.java:14) Caused by: com.orientechnologies.common.io.OIOException: Error on connecting to 0.0.0.0:2424/StudioDemo3 at com.orientechnologies.orient.client.remote.ORemoteConnectionPool.createNetworkConnection(ORemoteConnectionPool.java:65) at com.orientechnologies.orient.client.remote.ORemoteConnectionPool.createNewResource(ORemoteConnectionPool.java:71) at com.orientechnologies.orient.client.remote.ORemoteConnectionPool.createNewResource(ORemoteConnectionPool.java:19) at com.orientechnologies.common.concur.resource.OResourcePool.getResource(OResourcePool.java:96) at com.orientechnologies.orient.client.remote.ORemoteConnectionPool.acquire(ORemoteConnectionPool.java:95) at com.orientechnologies.orient.client.remote.ORemoteConnectionManager.acquire(ORemoteConnectionManager.java:88) at com.orientechnologies.orient.client.remote.OStorageRemote.getAvailableNetwork(OStorageRemote.java:2182) ... 13 more Caused by: java.io.IOException: Cannot connect to host 0.0.0.0:2424 at com.orientechnologies.orient.enterprise.channel.binary.OChannelBinaryAsynchClient.<init>(OChannelBinaryAsynchClient.java:89) at com.orientechnologies.orient.client.remote.ORemoteConnectionPool.createNetworkConnection(ORemoteConnectionPool.java:53) ... 19 more Caused by: java.net.SocketTimeoutException: connect timed out at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method) at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:204) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:589) at com.orientechnologies.orient.enterprise.channel.binary.OChannelBinaryAsynchClient.<init>(OChannelBinaryAsynchClient.java:85) ... 20 more Mar 10, 2016 11:01:49 PM com.orientechnologies.common.log.OLogManager log INFO: Orient Engine is shutting down... Mar 10, 2016 11:01:49 PM com.orientechnologies.common.log.OLogManager log INFO: Shutdown handler OShutdownWorkersHandler is going to be called Mar 10, 2016 11:01:49 PM com.orientechnologies.common.log.OLogManager log INFO: Shutdown handler OShutdownWorkersHandler completed

@wolf4ood
Copy link
Member

is the server running?

can you post here the log of the server?

@lihost
Copy link
Author

lihost commented Mar 10, 2016

Here is dump from orient-server.log.0

2016-03-10 23:01:25:981 INFO OrientDB auto-config DISKCACHE=5,385MB (heap=455MB os=7,888MB disk=20,601MB) [orientechnologies] 2016-03-10 23:01:26:137 INFO Loading configuration from: C:/Users/sotrived/Documents/Couture/orientdb-2.1.12/config/orientdb-server-config.xml... [OServerConfigurationLoaderXml] 2016-03-10 23:01:26:455 INFO OrientDB Server v2.1.12 (build 2.1.x@rb2f496fd6baa3b845b8f442c0ade5505249336cb; 2016-03-01 08:10:48+0000) is starting up... [OServer] 2016-03-10 23:01:26:464 INFO Databases directory: C:\Users\sotrived\Documents\Couture\orientdb-2.1.12\databases [OServer] 2016-03-10 23:01:26:520 INFO Listening binary connections on 0.0.0.0:2424 (protocol v.32, socket=default) [OServerNetworkListener] 2016-03-10 23:01:26:525 INFO Listening http connections on 0.0.0.0:2480 (protocol v.10, socket=default) [OServerNetworkListener] 2016-03-10 23:01:26:546 INFO Installing dynamic plugin 'studio-2.1.zip'... [OServerPluginManager] 2016-03-10 23:01:26:643 INFO Installing GREMLIN language v.2.6.0 - graph.pool.max=50 [OGraphServerHandler] 2016-03-10 23:01:26:644 INFO [OVariableParser.resolveVariables] Error on resolving property: distributed [orientechnologies] 2016-03-10 23:01:26:646 INFO Installing Script interpreter. WARN: authenticated clients can execute any kind of code into the server by using the following allowed languages: [sql] [OServerSideScriptInterpreter] 2016-03-10 23:01:26:646 INFO OrientDB Server v2.1.12 (build 2.1.x@rb2f496fd6baa3b845b8f442c0ade5505249336cb; 2016-03-01 08:10:48+0000) is active. [OServer]

@wolf4ood
Copy link
Member

did you try to connect with console.sh?

./console.sh

then

connect remote:localhost/StudioDemo3 admin admin

fill your credential if you changed it

@lihost
Copy link
Author

lihost commented Mar 10, 2016

Yes through ./console.bat its getting connected

orientdb> connect remote:localhost/StudioDemo3 admin admin

Disconnecting from the database [null]...OK Connecting to database [remote:localhost/StudioDemo3] with user 'admin'...OK orientdb {db=StudioDemo3}>

@lvca lvca changed the title OrientDB database getting corrupted after trying to access it through sample code. OrientDB database cannot be opened after trying to access it through sample code. Mar 10, 2016
@wolf4ood
Copy link
Member

mmm strange.

can you try with the same url in GraphApi

remote:localhost/StudioDemo3

@lihost
Copy link
Author

lihost commented Mar 11, 2016

Seems like going into endless loop, tried with GraphApi... here is code part and console out.

OrientGraph graph = new OrientGraph("remote:localhost/StudioDemo3");

    try{
        System.out.println("Getting OrientDB graph data");
        System.out.println("No. of Edges: "+graph.countEdges());
        System.out.println("No. of Vertices: "+graph.countVertices());
    } catch(Exception e){
        e.printStackTrace();
    } finally {
        graph.shutdown();
        Orient.instance().shutdown();
    }

Console out -- not printing anything and never ending, I had to kill it

Mar 11, 2016 11:09:18 AM com.orientechnologies.common.log.OLogManager log WARNING: MaxDirectMemorySize option is not set. It may cause OutOfMemoryError. Please set the option -XX:MaxDirectMemorySize=7888m when you start the JVM Mar 11, 2016 11:09:18 AM com.orientechnologies.common.log.OLogManager log INFO: OrientDB auto-config DISKCACHE=4,085MB (heap=1,755MB os=7,888MB disk=20,614MB) Mar 11, 2016 11:09:18 AM com.orientechnologies.common.log.OLogManager log INFO: Registered the new available server '127.0.0.1:2424' Mar 11, 2016 11:09:18 AM com.orientechnologies.common.log.OLogManager log WARNING: The Client driver version is different than Server version: client=33, server=32. You could not use the full features of the newer version. Assure to have the same versions on both

@wolf4ood
Copy link
Member

hi @tsohil

which version are you using on the client?

Do you have a pom based project?

@wolf4ood
Copy link
Member

Seems that you are using 2.2.x client
with 2.1.x server

@lihost
Copy link
Author

lihost commented Mar 11, 2016

Here is dependency hierarchy from my pom.

<dependencies>
    <dependency>
        <groupId>com.tinkerpop.gremlin</groupId>
        <artifactId>gremlin</artifactId>
        <version>2.6.0</version>
        <type>pom</type>
    </dependency>
    <dependency>
        <groupId>com.orientechnologies</groupId>
        <artifactId>orientdb-core</artifactId>
        <version>2.2.0-beta</version>
    </dependency>
    <dependency>
        <groupId>com.orientechnologies</groupId>
        <artifactId>orientdb-graphdb</artifactId>
        <version>2.2.0-beta</version>
    </dependency>
    <dependency>
        <groupId>com.tinkerpop.blueprints</groupId>
        <artifactId>blueprints-core</artifactId>
        <version>2.6.0</version>
    </dependency>
    <dependency>
        <groupId>com.tinkerpop.gremlin</groupId>
        <artifactId>gremlin-java</artifactId>
        <version>2.6.0</version>
    </dependency>
    <dependency>
        <groupId>net.java.dev.jna</groupId>
        <artifactId>jna</artifactId>
        <version>4.2.1</version>
    </dependency>
    <dependency>
        <groupId>net.java.dev.jna</groupId>
        <artifactId>jna-platform</artifactId>
        <version>4.2.1</version>
    </dependency>
  </dependencies>

@wolf4ood
Copy link
Member

you should change the version of Orientdb in 2.1.12

@lihost
Copy link
Author

lihost commented Mar 11, 2016

Thanks @maggiolo00 I made changes and also added some more dependencies required for REMOTE, I created fresh database and able to access it but still not able to access old database which I once accessed with plocal.

<dependencies>
    <dependency>
        <groupId>com.tinkerpop.gremlin</groupId>
        <artifactId>gremlin</artifactId>
        <version>2.6.0</version>
        <type>pom</type>
    </dependency>
    <dependency>
        <groupId>com.orientechnologies</groupId>
        <artifactId>orientdb-core</artifactId>
        <version>2.1.12</version>
    </dependency>
    <dependency>
        <groupId>com.orientechnologies</groupId>
        <artifactId>orientdb-graphdb</artifactId>
        <version>2.1.12</version>
    </dependency>
    <dependency>
        <groupId>com.tinkerpop.blueprints</groupId>
        <artifactId>blueprints-core</artifactId>
        <version>2.6.0</version>
    </dependency>
    <dependency>
        <groupId>com.tinkerpop.gremlin</groupId>
        <artifactId>gremlin-java</artifactId>
        <version>2.6.0</version>
    </dependency>
    <dependency>
        <groupId>net.java.dev.jna</groupId>
        <artifactId>jna</artifactId>
        <version>4.2.1</version>
    </dependency>
    <dependency>
        <groupId>net.java.dev.jna</groupId>
        <artifactId>jna-platform</artifactId>
        <version>4.2.1</version>
    </dependency>
    <dependency>
        <groupId>com.orientechnologies</groupId>
        <artifactId>orientdb-client</artifactId>
        <version>2.1.8</version>
    </dependency>
    <dependency>
        <groupId>com.orientechnologies</groupId>
        <artifactId>orientdb-enterprise</artifactId>
        <version>2.1.8</version>
    </dependency>
    <dependency>
        <groupId>com.googlecode.concurrentlinkedhashmap</groupId>
        <artifactId>concurrentlinkedhashmap-lru</artifactId>
        <version>1.4.2</version>
    </dependency>
  </dependencies>

@wolf4ood
Copy link
Member

what do you mean you are not able to access it in plocal?

@lihost
Copy link
Author

lihost commented Mar 11, 2016

I said

still not able to access old database which I once accessed with plocal.

i.e. If you can recall initially I started this thread saying I am not able to access database. Then after looking at my code you suggested I should use remote instead of plocal. Even using remote has not resolved that issue.

But if I create fresh new database then I am able to access it with remote. Therefore problem remains same just that dependency issues resolved.

@wolf4ood
Copy link
Member

@tsohil

if you have opened once the db with 2.2. client in plocal you will not able to open it again with 2.1.12 as the format probably changed

@lihost
Copy link
Author

lihost commented Mar 11, 2016

Ohh Ok, got it.

@maggiolo00 , does this also means there is no way to recover it or use it through client with different version.

@wolf4ood
Copy link
Member

In plocal and in the server you can open a db created with a previous version of OrientDB as we guarantee backwards compatibility at binary level.

http://orientdb.com/docs/2.1/Backward-compatibility.html

But if you create a db with a newer version of ODB probably you cannot open it with a old version as some structure could have been changed.

@wolf4ood
Copy link
Member

i Think you created the db with studio with version 2.1.12 then from your code you opened it with 2.2.0-beta and then again you tried to open it with 2.1.12

@lihost
Copy link
Author

lihost commented Mar 11, 2016

i Think you created the db with studio with version 2.1.12 then from your code you opened it with 2.2.0-beta and then again you tried to open it with 2.1.12

@maggiolo00 you are right at above comment, so due to this particular approach current state of that db can safely be called as corrupted ? since I am also not able to access it with Studio ver 2.1.12.

@wolf4ood
Copy link
Member

It is not corrupted, you should be able to open it by downloading OrientDB 2.2.0-beta and copy the db folder under the databases folder of the distribution.

@lihost
Copy link
Author

lihost commented Mar 11, 2016

Yes I am able to access it with OrientDB 2.2.0-beta.

Thanks @maggiolo00

@rajpushpa1
Copy link

@maggiolo00 I am able to connect from my java code to orient db please help me out.
my java code:-
OrientDB orient = new OrientDB("remote:localhost:2480", OrientDBConfig.defaultConfig());
ODatabaseSession db1 = orient.open("test", "root", "root");
System.out.println(db1.getName());
System.out.println(db1.getUser());

my pom.xml:-


4.0.0

test
test
0.0.1-SNAPSHOT
jar

test
http://maven.apache.org

UTF-8 junit junit 3.8.1 test com.orientechnologies orientdb-core 2.1.12 com.orientechnologies orientdb-graphdb 2.1.12 com.tinkerpop.blueprints blueprints-core 2.6.0 com.tinkerpop.gremlin gremlin-java 2.6.0 net.java.dev.jna jna 4.2.1 net.java.dev.jna jna-platform 4.2.1 com.orientechnologies orientdb-client 2.1.8 com.orientechnologies orientdb-enterprise 2.1.8 com.googlecode.concurrentlinkedhashmap concurrentlinkedhashmap-lru 1.4.2

please help

@rajpushpa1
Copy link

sorry I am not able to connect

@rajpushpa1
Copy link

@maggiolo00

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

4 participants