orientdb icon indicating copy to clipboard operation
orientdb copied to clipboard

Raise OutOfMemoryError: Encoded size is too large when writing edge data on s390x Linux

Open kxc1573 opened this issue 1 year ago • 2 comments

OrientDB Version: 3.2.20

Java Version: OpenJDK Runtime Environment (Red_Hat-17.0.7.0.7-2) (build 17.0.7+7-LTS)

OS: Linux 4.18.0-477.15.1.el8_8.s390x

Expected behavior

Writes data into the OrientDB successfully in the docker both on x86 Linux and s390x Linux.

Actual behavior

In the docker on the S390X Linux, when we batch insert relationships data after batch inserting nodes data, about 18K edges, it raise error java.lang.OutOfMemoryError: Encoded size is too large.

But the same process with the same data runs OK on the x86 Linux.

Here is the logs at the first occurrence :

2023-08-24 07:31:39:102 WARNI {db=Demo} Invalid type index: 115 [OType]2023-08-24 07:31:39:103 SEVER {db=Demo} Error while binary response serialization [ONetworkProtocolBinary]java.lang.OutOfMemoryError: Encoded size is too large	at java.base/java.util.Base64$Encoder.encodedOutLength(Base64.java:270)	at java.base/java.util.Base64$Encoder.encode(Base64.java:291)	at java.base/java.util.Base64$Encoder.encodeToString(Base64.java:345)	at com.orientechnologies.orient.core.serialization.serializer.record.binary.ORecordSerializerBinary.fromStream(ORecordSerializerBinary.java:111)	at com.orientechnologies.orient.core.record.impl.ODocument.deserializeFields(ODocument.java:2490)	at com.orientechnologies.orient.client.remote.message.OMessageHelper.getRecordBytes(OMessageHelper.java:89)	at com.orientechnologies.orient.client.remote.message.OMessageHelper.writeRecord(OMessageHelper.java:69)	at com.orientechnologies.orient.client.remote.message.OMessageHelper.writeIdentifiable(OMessageHelper.java:57)	at com.orientechnologies.orient.client.remote.message.OMessageHelper.writeDocument(OMessageHelper.java:459)	at com.orientechnologies.orient.client.remote.message.OMessageHelper.writeVertex(OMessageHelper.java:440)	at com.orientechnologies.orient.client.remote.message.OMessageHelper.writeResult(OMessageHelper.java:468)	at com.orientechnologies.orient.client.remote.message.OQueryResponse.write(OQueryResponse.java:68)	at com.orientechnologies.orient.server.network.protocol.binary.ONetworkProtocolBinary.sessionRequest(ONetworkProtocolBinary.java:390)	at com.orientechnologies.orient.server.network.protocol.binary.ONetworkProtocolBinary.execute(ONetworkProtocolBinary.java:238)	at com.orientechnologies.common.thread.OSoftThread.run(OSoftThread.java:68)
2023-08-24 07:31:39:105 SEVER Uncaught exception in thread OrientDB (/127.0.0.1:2424) <- BinaryClient (/127.0.0.1:44414) [OUncaughtExceptionHandler]java.lang.OutOfMemoryError: Encoded size is too large	at java.base/java.util.Base64$Encoder.encodedOutLength(Base64.java:270)	at java.base/java.util.Base64$Encoder.encode(Base64.java:291)	at java.base/java.util.Base64$Encoder.encodeToString(Base64.java:345)	at com.orientechnologies.orient.core.serialization.serializer.record.binary.ORecordSerializerBinary.fromStream(ORecordSerializerBinary.java:111)	at com.orientechnologies.orient.core.record.impl.ODocument.deserializeFields(ODocument.java:2490)	at com.orientechnologies.orient.client.remote.message.OMessageHelper.getRecordBytes(OMessageHelper.java:89)	at com.orientechnologies.orient.client.remote.message.OMessageHelper.writeRecord(OMessageHelper.java:69)	at com.orientechnologies.orient.client.remote.message.OMessageHelper.writeIdentifiable(OMessageHelper.java:57)	at com.orientechnologies.orient.client.remote.message.OMessageHelper.writeDocument(OMessageHelper.java:459)	at com.orientechnologies.orient.client.remote.message.OMessageHelper.writeVertex(OMessageHelper.java:440)	at com.orientechnologies.orient.client.remote.message.OMessageHelper.writeResult(OMessageHelper.java:468)	at com.orientechnologies.orient.client.remote.message.OQueryResponse.write(OQueryResponse.java:68)	at com.orientechnologies.orient.server.network.protocol.binary.ONetworkProtocolBinary.sessionRequest(ONetworkProtocolBinary.java:390)	at com.orientechnologies.orient.server.network.protocol.binary.ONetworkProtocolBinary.execute(ONetworkProtocolBinary.java:238)	at com.orientechnologies.common.thread.OSoftThread.run(OSoftThread.java:68) 

And here is a log of several subsequent reproductions:

2023-08-25 01:59:49:644 SEVER Uncaught exception in thread OrientDB (/127.0.0.1:2424) <- BinaryClient (/127.0.0.1:35942) [OUncaughtExceptionHandler]
java.lang.OutOfMemoryError: Encoded size is too large
	at java.base/java.util.Base64$Encoder.encodedOutLength(Base64.java:270)
	at java.base/java.util.Base64$Encoder.encode(Base64.java:291)
	at java.base/java.util.Base64$Encoder.encodeToString(Base64.java:345)
	at com.orientechnologies.orient.core.serialization.serializer.record.binary.ORecordSerializerBinary.fromStream(ORecordSerializerBinary.java:111)
	at com.orientechnologies.orient.core.record.impl.ODocument.deserializeFields(ODocument.java:2490)
	at com.orientechnologies.orient.client.remote.message.OMessageHelper.getRecordBytes(OMessageHelper.java:89)
	at com.orientechnologies.orient.client.remote.message.OMessageHelper.writeRecord(OMessageHelper.java:69)
	at com.orientechnologies.orient.client.remote.message.OMessageHelper.writeIdentifiable(OMessageHelper.java:57)
	at com.orientechnologies.orient.client.remote.message.OMessageHelper.writeDocument(OMessageHelper.java:459)
	at com.orientechnologies.orient.client.remote.message.OMessageHelper.writeVertex(OMessageHelper.java:440)
	at com.orientechnologies.orient.client.remote.message.OMessageHelper.writeResult(OMessageHelper.java:468)
	at com.orientechnologies.orient.client.remote.message.OQueryResponse.write(OQueryResponse.java:68)
	at com.orientechnologies.orient.server.network.protocol.binary.ONetworkProtocolBinary.sessionRequest(ONetworkProtocolBinary.java:390)
	at com.orientechnologies.orient.server.network.protocol.binary.ONetworkProtocolBinary.execute(ONetworkProtocolBinary.java:238)
	at com.orientechnologies.common.thread.OSoftThread.run(OSoftThread.java:68)

2023-08-25 01:59:50:542 SEVER {db=Demo} Error while binary response serialization [ONetworkProtocolBinary]
java.lang.OutOfMemoryError: Encoded size is too large
	at java.base/java.util.Base64$Encoder.encodedOutLength(Base64.java:270)
	at java.base/java.util.Base64$Encoder.encode(Base64.java:291)
	at java.base/java.util.Base64$Encoder.encodeToString(Base64.java:345)
	at com.orientechnologies.orient.core.serialization.serializer.record.binary.ORecordSerializerBinary.fromStream(ORecordSerializerBinary.java:111)
	at com.orientechnologies.orient.core.record.impl.ODocument.deserializeFields(ODocument.java:2490)
	at com.orientechnologies.orient.client.remote.message.OMessageHelper.getRecordBytes(OMessageHelper.java:89)
	at com.orientechnologies.orient.client.remote.message.OMessageHelper.writeRecord(OMessageHelper.java:69)
	at com.orientechnologies.orient.client.remote.message.OMessageHelper.writeIdentifiable(OMessageHelper.java:57)
	at com.orientechnologies.orient.client.remote.message.OMessageHelper.writeDocument(OMessageHelper.java:459)
	at com.orientechnologies.orient.client.remote.message.OMessageHelper.writeVertex(OMessageHelper.java:440)
	at com.orientechnologies.orient.client.remote.message.OMessageHelper.writeResult(OMessageHelper.java:468)
	at com.orientechnologies.orient.client.remote.message.OQueryResponse.write(OQueryResponse.java:68)
	at com.orientechnologies.orient.server.network.protocol.binary.ONetworkProtocolBinary.sessionRequest(ONetworkProtocolBinary.java:390)
	at com.orientechnologies.orient.server.network.protocol.binary.ONetworkProtocolBinary.execute(ONetworkProtocolBinary.java:238)
	at com.orientechnologies.common.thread.OSoftThread.run(OSoftThread.java:68)

If you are vigilant enough, you will find that the log for subsequent reproduction lacks the Invalid type index: 115 [OType] message .

By the way, in my previous issue -- 9972, also on s390x Linux, I encountered nvalid type index: 97 [OType] while reading data.

Steps to reproduce

Just basic write operations

Here is the code for check and create Edge schema:

for (String relationship : relationships) {
            OClass edgeClass = db.getClass(relationship);
            if (edgeClass == null) {
                edgeClass = db.createEdgeClass(relationship);
            }
            if (edgeClass.getProperty("source_target") == null) {
                edgeClass.createProperty("source_target", OType.STRING);
                edgeClass.createIndex(relationship + "_idx", OClass.INDEX_TYPE.UNIQUE, "source_target");
            }
        }

And here is the final write operation code

OEdge relationship = this.db.newEdge(source, target, relationshipName);
relationship.setProperty("source_target", source_target);
relationship.save();

Also for the sake of data confidentiality, we cannot provide specific test data. But it runs OK on the x86 Linux with the same current test data. And it runs OK for our previous release on s390x Linux with the old test data.

My temporary solution now: When encountering an exception, skip the data and interrupt the current ODatabaseSession, and then create a new ODatabaseSession using the same link of OrientDB, subsequent data can continue to be written.

kxc1573 avatar Aug 28 '23 03:08 kxc1573