Cannot change the schema while a transaction is active

511 views
Skip to first unread message

Riccardo Tasso

unread,
Sep 18, 2013, 5:05:09 AM9/18/13
to orient-...@googlegroups.com
Hi, with orient 1.6.0-SNAPSHOT I would like import a dump from API.

I'd like something like:
OrientGraph graph;
try {
   graph
= new OrientGraph(dbUrl, user, password);
   
OrientUtils.importFromFile(graph, dumpFile);

   letsWorkWithGraph
(graph);
} finally {
   graph
.shutdown();
}

Where my import is as follows:
public static void importFromFile(OrientGraph graph, String fileName) {
ODatabaseImport importManager = null;
OCommandOutputListener listener = new CollectOCommandOutputListener();
try {
importManager = new ODatabaseImport(graph.getRawGraph(), fileName, listener);
importManager.importDatabase();
importManager.close();
} catch (Exception e) {
e.printStackTrace();
}
}

But I receive an exception:
com.orientechnologies.orient.core.exception.OSchemaException: Cannot change the schema while a transaction is active. Schema changes are not transactional

Which is the right way to implement the importFromFile function?

Cheers,
   Riccardo

Luca Garulli

unread,
Sep 18, 2013, 5:20:02 AM9/18/13
to orient-database
Hi Riccardo,
try to use OrientGraphNoTx as graph implementation: it's faster because doesn't use tx.

Lvc@


--
 
---
You received this message because you are subscribed to the Google Groups "OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to orient-databa...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Riccardo Tasso

unread,
Sep 18, 2013, 6:02:31 AM9/18/13
to orient-...@googlegroups.com
Hi Artem, I changed my function to be:

public static void importFromFile(OrientGraph graph, String fileName) {
graph.getRawGraph().commit();
graph.getRawGraph().begin();
ODatabaseImport importManager = null;
OCommandOutputListener listener = new CollectOCommandOutputListener();
try {
importManager = new ODatabaseImport(graph.getRawGraph(), fileName, listener);
importManager.importDatabase();
importManager.close();
} catch (Exception e) {
log.error("Exception during the import of the file " + fileName + " into the database " + graph.getRawGraph().getURL(), e);
}
graph.getRawGraph().commit();
}

But the error is the same. Am I wrong in anything?

Cheers,
   Riccardo


2013/9/18 Artem Orobets <eni...@gmail.com>
Hi Riccardo,

If you do need transactions, you can try commit transaction with RawGraph API, execute import and open new transaction. 

Best regards,
Artem Orobets

Orient Technologies

the Company behind OrientDB



2013/9/18 Luca Garulli <l.ga...@gmail.com>

Artem Orobets

unread,
Sep 18, 2013, 5:27:45 AM9/18/13
to orient-...@googlegroups.com
Hi Riccardo,

If you do need transactions, you can try commit transaction with RawGraph API, execute import and open new transaction. 

Best regards,
Artem Orobets

Orient Technologies

the Company behind OrientDB



2013/9/18 Luca Garulli <l.ga...@gmail.com>
Hi Riccardo,

Artem Orobets

unread,
Sep 18, 2013, 7:48:38 AM9/18/13
to orient-...@googlegroups.com
Hi Riccardo,

The problem is that you have active transaction during import.

Try following:

public static void importFromFile(OrientGraph graph, String fileName) {
graph.getRawGraph().commit();
//without starting of new transaction
ODatabaseImport importManager = null;
OCommandOutputListener listener = new CollectOCommandOutputListener();
try {
importManager = new ODatabaseImport(graph.getRawGraph(), fileName, listener);
importManager.importDatabase();
importManager.close();
} catch (Exception e) {
log.error("Exception during the import of the file " + fileName + " into the database " + graph.getRawGraph().getURL(), e);
}
graph.getRawGraph().commit();
}
Best regards,
Artem Orobets

Orient Technologies

the Company behind OrientDB



2013/9/18 Riccardo Tasso <riccard...@gmail.com>

Riccardo Tasso

unread,
Sep 18, 2013, 9:40:41 AM9/18/13
to orient-...@googlegroups.com
Thank you both. Now I am an import / export ninja!

Cheers,
   Riccardo

Riccardo Tasso

unread,
Sep 19, 2013, 4:06:17 AM9/19/13
to orient-...@googlegroups.com
Still with some problem. The reference is always Orient 1.6.0-SNAPSHOT (updated this morning).

My export / import tests works well with a very simple example (3 vertices and 1 edge).
With a bigger graph the export goes well.
Anyway I receive the following exception from the importer:

Running it.celi.orient.util.ImportOrientTest
com.orientechnologies.orient.core.exception.ODatabaseException: Error on retrieving record #5:0 (cluster: ouser)
at com.orientechnologies.orient.core.db.raw.ODatabaseRaw.read(ODatabaseRaw.java:244)
at com.orientechnologies.orient.core.db.record.ODatabaseRecordAbstract.executeReadRecord(ODatabaseRecordAbstract.java:682)
at com.orientechnologies.orient.core.tx.OTransactionNoTx.loadRecord(OTransactionNoTx.java:63)
at com.orientechnologies.orient.core.db.record.ODatabaseRecordTx.load(ODatabaseRecordTx.java:202)
at com.orientechnologies.orient.core.db.record.ODatabaseRecordTx.load(ODatabaseRecordTx.java:38)
at com.orientechnologies.orient.core.id.ORecordId.getRecord(ORecordId.java:296)
at com.orientechnologies.orient.core.sql.OCommandExecutorSQLSelect.fillSearchIndexResultSet(OCommandExecutorSQLSelect.java:822)
at com.orientechnologies.orient.core.sql.OCommandExecutorSQLSelect.searchForIndexes(OCommandExecutorSQLSelect.java:706)
at com.orientechnologies.orient.core.sql.OCommandExecutorSQLSelect.searchInClasses(OCommandExecutorSQLSelect.java:610)
at com.orientechnologies.orient.core.sql.OCommandExecutorSQLResultsetAbstract.assignTarget(OCommandExecutorSQLResultsetAbstract.java:137)
at com.orientechnologies.orient.core.sql.OCommandExecutorSQLSelect.assignTarget(OCommandExecutorSQLSelect.java:360)
at com.orientechnologies.orient.core.sql.OCommandExecutorSQLSelect.executeSearch(OCommandExecutorSQLSelect.java:338)
at com.orientechnologies.orient.core.sql.OCommandExecutorSQLSelect.execute(OCommandExecutorSQLSelect.java:327)
at com.orientechnologies.orient.core.sql.OCommandExecutorSQLDelegate.execute(OCommandExecutorSQLDelegate.java:57)
at com.orientechnologies.orient.core.storage.OStorageEmbedded.executeCommand(OStorageEmbedded.java:99)
at com.orientechnologies.orient.core.storage.OStorageEmbedded.command(OStorageEmbedded.java:88)
at com.orientechnologies.orient.core.sql.query.OSQLQuery.run(OSQLQuery.java:69)
at com.orientechnologies.orient.core.sql.query.OSQLSynchQuery.run(OSQLSynchQuery.java:82)
at com.orientechnologies.orient.core.query.OQueryAbstract.execute(OQueryAbstract.java:29)
at com.orientechnologies.orient.core.metadata.security.OSecurityShared.getUser(OSecurityShared.java:179)
at com.orientechnologies.orient.core.metadata.security.OSecurityShared.authenticate(OSecurityShared.java:148)
at com.orientechnologies.orient.core.metadata.security.OSecurityProxy.authenticate(OSecurityProxy.java:83)
at com.orientechnologies.orient.core.db.record.ODatabaseRecordAbstract.open(ODatabaseRecordAbstract.java:128)
at com.orientechnologies.orient.core.db.ODatabaseWrapperAbstract.open(ODatabaseWrapperAbstract.java:49)
at com.tinkerpop.blueprints.impls.orient.OrientBaseGraph.openOrCreate(OrientBaseGraph.java:885)
at com.tinkerpop.blueprints.impls.orient.OrientBaseGraph.<init>(OrientBaseGraph.java:102)
at com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx.<init>(OrientGraphNoTx.java:32)
at it.celi.orient.util.ImportOrientTest.importOrientTest(ImportOrientTest.java:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:264)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:124)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray2(ReflectionUtils.java:208)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:159)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:87)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:95)
Caused by: com.orientechnologies.common.io.OIOException: You cannot access outside the file size (0 bytes). You have requested portion 0-2 bytes. File: File: ouser.0.ocl os-size=1001024, stored=1000000, filled=0, max=524287995
at com.orientechnologies.orient.core.storage.fs.OAbstractFile.checkRegions(OAbstractFile.java:514)
at com.orientechnologies.orient.core.storage.fs.OFileMMap.readShort(OFileMMap.java:213)
at com.orientechnologies.orient.core.storage.impl.local.OClusterLocal.getPhysicalPosition(OClusterLocal.java:287)
at com.orientechnologies.orient.core.storage.impl.local.OStorageLocal.readRecord(OStorageLocal.java:1800)
at com.orientechnologies.orient.core.storage.impl.local.OStorageLocal.readRecord(OStorageLocal.java:1157)
at com.orientechnologies.orient.core.db.raw.ODatabaseRaw.read(ODatabaseRaw.java:238)
... 56 more

I don't have custom users right now. Do you have any idea about it?

Luca Garulli

unread,
Sep 19, 2013, 4:11:35 AM9/19/13
to orient-database
Hi Riccardo,
could you import the new database using plocal as engine rather than local? Starting from 1.5.1 plocal is the suggested engine with no such errors anymore.

Lvc@



--

Riccardo Tasso

unread,
Sep 19, 2013, 8:11:27 AM9/19/13
to orient-...@googlegroups.com
Ok Luca, it worked!

Thanks,
   Riccardo


2013/9/19 Luca Garulli <l.ga...@gmail.com>
Reply all
Reply to author
Forward
0 new messages