orientdb icon indicating copy to clipboard operation
orientdb copied to clipboard

OrientDB 1.7.8 - ArrayIndexOutOfBoundsException during the export procedure

Open giastfader opened this issue 12 years ago • 18 comments

Hi, I have a problem with the export API using OrientDB 1.7.8 The database uses the plocal engine and the OrientDB core is embedded. It has almost 1M record in a class named "test" and almost 900 users. When I export the DB there are several ArrayIndexOutOfBoundsException and OutOfMemoryError (I don't know if they are in some way related to each other).

Here is my Java code used to export the DB:

        ODatabaseRecordTx db = null;
        try{
            ODatabaseDocumentTx db = new ODatabaseDocumentTx("plocal:" + dbDirName);
            db.open(username,password);

            ODatabaseExport oe = new ODatabaseExport(db, os, new OCommandOutputListener() {
                @Override
                public void onMessage(String m) {
                    Logger.info(m);
                }
            });
            oe.setUseLineFeedForRecords(true);
            oe.setIncludeManualIndexes(true);
            oe.exportDatabase();
            oe.close();
        }catch(Exception ioe){
            throw new UnableToExportDbException(ioe);
        }finally{
            if(db!=null && !db.isClosed()){
                db.close();
            }
        }

Here is the output:

.........CUT.........
2014-09-27 10:29:56,255 - [info] - OK (records=50/50) 
2014-09-27 10:29:56,255 - [info] - 
- Cluster 'test' (id=23)... 
2014-09-27 10:30:06,006 - [info] - . 
2014-09-27 10:30:16,274 - [info] - . 
2014-09-27 10:30:25,532 - [info] - . 
2014-09-27 10:30:35,219 - [info] - . 
2014-09-27 10:30:47,317 - [info] - . 
2014-09-27 10:30:57,701 - [info] - . 
2014-09-27 10:31:06,679 - [info] - . 
2014-09-27 10:31:15,598 - [info] - . 
2014-09-27 10:31:16,217 - [error] - com.orientechnologies.orient.core.db.tool.ODatabaseExport: 
Error on exporting record #23:661256. It seems corrupted; size: 289 bytes, raw content (as string):
==========
test@count:812,random:16229,pid:"17690",value:"value_16229",key:"key_16229",class:"test",id:"129d025d-ff33-43c6-ae78-566d979e0777",_links:#11:661928,_audit:#3:661257,_allow:<#5:671>,_allowRead:,_allowWrite:,_allowUpdate:,_allowDelete:,_creation_date:1411805834468t,_author:"user_337_20413"
========== 
java.lang.OutOfMemoryError: Java heap space
    at org.apache.commons.io.output.ByteArrayOutputStream.needNewBuffer(ByteArrayOutputStream.java:122) ~[commons-io.jar:2.4]
    at org.apache.commons.io.output.ByteArrayOutputStream.write(ByteArrayOutputStream.java:153) ~[commons-io.jar:2.4]
    at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:221) ~[na:1.8.0_05]
    at sun.nio.cs.StreamEncoder.implWrite(StreamEncoder.java:282) ~[na:1.8.0_05]
    at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:125) ~[na:1.8.0_05]
    at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:135) ~[na:1.8.0_05]
    at java.io.OutputStreamWriter.write(OutputStreamWriter.java:220) ~[na:1.8.0_05]
    at java.io.Writer.write(Writer.java:157) ~[na:1.8.0_05]
    at java.io.Writer.append(Writer.java:227) ~[na:1.8.0_05]
    at com.orientechnologies.orient.core.serialization.serializer.OJSONWriter.append(OJSONWriter.java:429) ~[orientdb-core-1.7.8.jar:1.7.8]
    at com.orientechnologies.orient.core.db.tool.ODatabaseExport.exportRecord(ODatabaseExport.java:537) [orientdb-core-1.7.8.jar:1.7.8]
    at com.orientechnologies.orient.core.db.tool.ODatabaseExport.exportRecords(ODatabaseExport.java:201) [orientdb-core-1.7.8.jar:1.7.8]
    at com.orientechnologies.orient.core.db.tool.ODatabaseExport.exportDatabase(ODatabaseExport.java:126) [orientdb-core-1.7.8.jar:1.7.8]
....... 
2014-09-27 10:31:16,222 - [error] - com.orientechnologies.orient.core.db.tool.ODatabaseExport: Error on exporting record #23:661275. It seems corrupted; size: 289 bytes, raw content (as string):
==========
test@count:822,random:11897,pid:"17690",value:"value_11897",key:"key_11897",class:"test",id:"311e6af3-e02e-456f-88a9-73137f842b8c",_links:#11:661947,_audit:#3:661276,_allow:<#5:671>,_allowRead:,_allowWrite:,_allowUpdate:,_allowDelete:,_creation_date:1411805834528t,_author:"user_337_20413"
========== 
java.lang.ArrayIndexOutOfBoundsException: null
    at org.apache.commons.io.output.ByteArrayOutputStream.write(ByteArrayOutputStream.java:150) ~[commons-io.jar:2.4]
    at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:221) ~[na:1.8.0_05]
    at sun.nio.cs.StreamEncoder.implWrite(StreamEncoder.java:282) ~[na:1.8.0_05]
    at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:125) ~[na:1.8.0_05]
    at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:135) ~[na:1.8.0_05]
    at java.io.OutputStreamWriter.write(OutputStreamWriter.java:220) ~[na:1.8.0_05]
    at java.io.Writer.write(Writer.java:157) ~[na:1.8.0_05]
    at java.io.Writer.append(Writer.java:227) ~[na:1.8.0_05]
    at com.orientechnologies.orient.core.serialization.serializer.OJSONWriter.append(OJSONWriter.java:429) ~[orientdb-core-1.7.8.jar:1.7.8]
    at com.orientechnologies.orient.core.db.tool.ODatabaseExport.exportRecord(ODatabaseExport.java:537) [orientdb-core-1.7.8.jar:1.7.8]
    at com.orientechnologies.orient.core.db.tool.ODatabaseExport.exportRecords(ODatabaseExport.java:201) [orientdb-core-1.7.8.jar:1.7.8]
    at com.orientechnologies.orient.core.db.tool.ODatabaseExport.exportDatabase(ODatabaseExport.java:126) [orientdb-core-1.7.8.jar:1.7.8]
.....
2014-09-27 10:31:16,225 - [error] - com.orientechnologies.orient.core.db.tool.ODatabaseExport: Error on exporting record #23:661294. It seems corrupted; size: 289 bytes, raw content (as string):
==========
test@count:831,random:23571,pid:"17690",value:"value_23571",key:"key_23571",class:"test",id:"b056dc73-6a38-4af2-8cec-7ccf26d5b24b",_links:#11:661966,_audit:#3:661295,_allow:<#5:671>,_allowRead:,_allowWrite:,_allowUpdate:,_allowDelete:,_creation_date:1411805834579t,_author:"user_337_20413"
========== 
java.lang.ArrayIndexOutOfBoundsException: null
    at org.apache.commons.io.output.ByteArrayOutputStream.write(ByteArrayOutputStream.java:150) ~[commons-io.jar:2.4]
    at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:221) ~[na:1.8.0_05]
    at sun.nio.cs.StreamEncoder.implWrite(StreamEncoder.java:282) ~[na:1.8.0_05]
    at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:125) ~[na:1.8.0_05]
    at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:135) ~[na:1.8.0_05]
    at java.io.OutputStreamWriter.write(OutputStreamWriter.java:220) ~[na:1.8.0_05]
    at java.io.Writer.write(Writer.java:157) ~[na:1.8.0_05]
    at java.io.Writer.append(Writer.java:227) ~[na:1.8.0_05]
    at com.orientechnologies.orient.core.serialization.serializer.OJSONWriter.append(OJSONWriter.java:429) ~[orientdb-core-1.7.8.jar:1.7.8]
    at com.orientechnologies.orient.core.db.tool.ODatabaseExport.exportRecord(ODatabaseExport.java:537) [orientdb-core-1.7.8.jar:1.7.8]
    at com.orientechnologies.orient.core.db.tool.ODatabaseExport.exportRecords(ODatabaseExport.java:201) [orientdb-core-1.7.8.jar:1.7.8]
    at com.orientechnologies.orient.core.db.tool.ODatabaseExport.exportDatabase(ODatabaseExport.java:126) [orientdb-core-1.7.8.jar:1.7.8]
......

2014-09-27 10:31:16,228 - [error] - application-akka.actor.default-dispatcher-2  
Error on exporting record #23:661313. It seems corrupted; size: 287 bytes, raw content (as string):
==========
test@count:74,random:12399,pid:"17710",value:"value_12399",key:"key_12399",class:"test",id:"4e0d00a7-d37f-48bc-b370-9d8b8abfdc71",_links:#11:661985,_audit:#3:661314,_allow:<#5:672>,_allowRead:,_allowWrite:,_allowUpdate:,_allowDelete:,_creation_date:1411805834655t,_author:"user_331_2793"
========== 
java.lang.ArrayIndexOutOfBoundsException: null
    at org.apache.commons.io.output.ByteArrayOutputStream.write(ByteArrayOutputStream.java:150) ~[commons-io.jar:2.4]
    at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:221) ~[na:1.8.0_05]
    at sun.nio.cs.StreamEncoder.implWrite(StreamEncoder.java:282) ~[na:1.8.0_05]
    at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:125) ~[na:1.8.0_05]
    at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:135) ~[na:1.8.0_05]
    at java.io.OutputStreamWriter.write(OutputStreamWriter.java:220) ~[na:1.8.0_05]
    at java.io.Writer.write(Writer.java:157) ~[na:1.8.0_05]
    at java.io.Writer.append(Writer.java:227) ~[na:1.8.0_05]
    at com.orientechnologies.orient.core.serialization.serializer.OJSONWriter.append(OJSONWriter.java:429) ~[orientdb-core-1.7.8.jar:1.7.8]
    at com.orientechnologies.orient.core.db.tool.ODatabaseExport.exportRecord(ODatabaseExport.java:537) [orientdb-core-1.7.8.jar:1.7.8]
    at com.orientechnologies.orient.core.db.tool.ODatabaseExport.exportRecords(ODatabaseExport.java:201) [orientdb-core-1.7.8.jar:1.7.8]
    at com.orientechnologies.orient.core.db.tool.ODatabaseExport.exportDatabase(ODatabaseExport.java:126) [orientdb-core-1.7.8.jar:1.7.8]
....
2014-09-27 10:31:16,231 - [error] - com.orientechnologies.orient.core.db.tool.ODatabaseExport:Error on exporting record #23:661332. It seems corrupted; size: 289 bytes, raw content (as string):
==========
....CUT...

- Index ORole.name... 
2014-09-27 10:31:39,937 - [info] - OK 
2014-09-27 10:31:39,937 - [info] - 
OK (11 indexes) 
2014-09-27 10:31:39,937 - [info] - 
Exporting manual indexes content... 
2014-09-27 10:31:39,941 - [info] - 
- Exporting index dictionary ... 
2014-09-27 10:31:39,943 - [info] - OK (entries=0) 
2014-09-27 10:31:39,943 - [info] - 
OK (1 manual indexes) 
2014-09-27 10:31:39,943 - [info] - 

Database export completed in 188384ms 
2014-09-27 10:31:39,944 - [error] -  Error on exporting database 'testdb' to: streaming.json 
java.lang.ArrayIndexOutOfBoundsException: null
    at org.apache.commons.io.output.ByteArrayOutputStream.write(ByteArrayOutputStream.java:150) ~[commons-io.jar:2.4]
    at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:221) ~[na:1.8.0_05]
    at sun.nio.cs.StreamEncoder.implFlushBuffer(StreamEncoder.java:291) ~[na:1.8.0_05]
    at sun.nio.cs.StreamEncoder.implFlush(StreamEncoder.java:295) ~[na:1.8.0_05]
    at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:141) ~[na:1.8.0_05]
    at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:229) ~[na:1.8.0_05]
    at com.orientechnologies.orient.core.serialization.serializer.OJSONWriter.flush(OJSONWriter.java:419) ~[orientdb-core-1.7.8.jar:1.7.8]
    at com.orientechnologies.orient.core.db.tool.ODatabaseExport.exportDatabase(ODatabaseExport.java:134) ~[orientdb-core-1.7.8.jar:1.7.8]

giastfader avatar Sep 29 '14 23:09 giastfader

Hi, But you have OOM exception , after that results are unpredictable.

Could send me your database so I can play with it ?

andrii0lomakin avatar Oct 09 '14 14:10 andrii0lomakin

I sent you an email, thanks

giastfader avatar Oct 09 '14 18:10 giastfader

Hi, I have found that you have issue with ouser.name index but it is already fixed in new version. Could you drop ouser.name, create it again and try ?

andrii0lomakin avatar Oct 13 '14 10:10 andrii0lomakin

Hi, Did you try this trick ?

andrii0lomakin avatar Oct 14 '14 19:10 andrii0lomakin

not yet @laa . Do you mean to drop ouser.name index? Actually I had to create an index against ouser.name property AND, since I have another class that references OUser, another one to the same property but with different path. Oh my... I mean: class: _BB_User: has a property "user" that is a link to OUser. If I execute a query like: select from _bb_user where user.name = "john" the index defined on ouser.name it is not used.

So I had to create an index as: create index _bb_user.user.name unique to avoid OUser class scan.

giastfader avatar Oct 16 '14 07:10 giastfader

I have just opened #2947 Are these two issue related?

giastfader avatar Oct 16 '14 07:10 giastfader

Hi @laa , I tried with 2.0-M2, dropping ouser.name index and recreating it. I have the same OOM:

- Cluster 'test' (id=23)... 
2014-10-20 01:53:08,695 - [info] - . 
2014-10-20 01:53:24,900 - [info] - . 
2014-10-20 01:53:41,092 - [info] - . 
2014-10-20 01:54:00,090 - [info] - . 
2014-10-20 01:54:16,336 - [info] - . 
2014-10-20 01:54:33,074 - [info] - . 
2014-10-20 01:54:50,889 - [info] - . 
2014-10-20 01:55:08,051 - [info] - . 
2014-10-20 01:55:09,382 - [error] - com.orientechnologies.orient.core.db.tool.ODatabaseExport: application-akka.actor.default-dispatcher-2  
Error on exporting record #23:660550. It seems corrupted; size: 289 bytes, raw content (as string):
==========
test@count:693,random:20720,pid:"17710",value:"value_20720",key:"key_20720",class:"test",id:"fdcd103f-c75b-427e-95d9-aa8016cdf03a",_links:#11:661221,_audit:#3:660551,_allow:<#5:670>,_allowRead:,_allowWrite:,_allowUpdate:,_allowDelete:,_creation_date:1411805831907t,_author:"user_330_15652"
========== 
java.lang.OutOfMemoryError: Java heap space
    at org.apache.commons.io.output.ByteArrayOutputStream.needNewBuffer(ByteArrayOutputStream.java:122) ~[commons-io.jar:2.4]
    at org.apache.commons.io.output.ByteArrayOutputStream.write(ByteArrayOutputStream.java:153) ~[commons-io.jar:2.4]
    at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:221) ~[na:1.8.0_05]
    at sun.nio.cs.StreamEncoder.implWrite(StreamEncoder.java:282) ~[na:1.8.0_05]
    at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:125) ~[na:1.8.0_05]
    at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:135) ~[na:1.8.0_05]
    at java.io.OutputStreamWriter.write(OutputStreamWriter.java:220) ~[na:1.8.0_05]
    at java.io.Writer.write(Writer.java:157) ~[na:1.8.0_05]
    at java.io.Writer.append(Writer.java:227) ~[na:1.8.0_05]
    at com.orientechnologies.orient.core.serialization.serializer.OJSONWriter.append(OJSONWriter.java:433) ~[orientdb-core-2.0-M2.jar:2.0-M2]
    at com.orientechnologies.orient.core.db.tool.ODatabaseExport.exportRecord(ODatabaseExport.java:538) [orientdb-core-2.0-M2.jar:2.0-M2]
    at com.orientechnologies.orient.core.db.tool.ODatabaseExport.exportRecords(ODatabaseExport.java:203) [orientdb-core-2.0-M2.jar:2.0-M2]
    at com.orientechnologies.orient.core.db.tool.ODatabaseExport.exportDatabase(ODatabaseExport.java:128) [orientdb-core-2.0-M2.jar:2.0-M2]

giastfader avatar Oct 20 '14 00:10 giastfader

@giastfader this issue has milestone 2.0-final, so have you tried with 2.0-SNAPSHOT?

lvca avatar Oct 20 '14 04:10 lvca

@giastfader because I do not have such problems , could you send me memory dump ?

andrii0lomakin avatar Oct 20 '14 05:10 andrii0lomakin

@giastfader do you have any updates , probably memory dumps for this issue ?

andrii0lomakin avatar Oct 28 '14 08:10 andrii0lomakin

Hi @laa , I will give you a feedback asap

giastfader avatar Oct 28 '14 16:10 giastfader

@laa I sent you the dump via email, thanks

giastfader avatar Oct 29 '14 12:10 giastfader

What is email title ?

andrii0lomakin avatar Oct 29 '14 12:10 andrii0lomakin

got it

andrii0lomakin avatar Oct 29 '14 12:10 andrii0lomakin

This thread consumes all memory in " org.apache.commons.io.output.ByteArrayOutputStream [Stack Local] 536864176 32"

akka.dispatch.MonitorableThreadFactory$AkkaForkJoinWorkerThread [Thread, Stack Local] "application-akka.actor.default-dispatcher-4"

does it make any sense for you. OrinentDB objects do not consume much memory.

andrii0lomakin avatar Oct 29 '14 13:10 andrii0lomakin

93% of memory is consumed by this object.

andrii0lomakin avatar Oct 29 '14 13:10 andrii0lomakin

That object is used internally by the Play Framework, but it seems that the problem occurs only in dev mode. In production I just tested several configurations and I do not be able to reproduce that. So I think that at the moment this issue is not blocking for us.

giastfader avatar Oct 29 '14 13:10 giastfader

ok. I close it because honestly do not see any memory consumption problem on orientdb side.

andrii0lomakin avatar Oct 29 '14 13:10 andrii0lomakin