Skip to content

Commit

Permalink
Merge pull request #93 from ubirch/fix/remove-dynamic-query-for-oom
Browse files Browse the repository at this point in the history
add -XX:+ExitOnOutOfMemoryError in event-log-service and verification…
  • Loading branch information
Hiroki6 authored Feb 14, 2023
2 parents bb1bcf2 + 98b95e0 commit 5aaec60
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion event-log-chainer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<ubirch-kafka-envelope.version>1.0.1</ubirch-kafka-envelope.version>
<guice.version>4.1.0</guice.version>
<guice.ext.version>4.1.0</guice.ext.version>
<quill.cassandra.version>3.12.0</quill.cassandra.version>
<quill.cassandra.version>4.6.0</quill.cassandra.version>
<joda-time.version>2.10</joda-time.version>
<kafka-clients.version>2.3.0</kafka-clients.version>
<json4s-native.version>3.6.0</json4s-native.version>
Expand Down
2 changes: 1 addition & 1 deletion event-log-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<event-log-kafka.version>1.2.12-SNAPSHOT</event-log-kafka.version>
<guice.version>4.1.0</guice.version>
<guice.ext.version>4.1.0</guice.ext.version>
<quill.cassandra.version>3.12.0</quill.cassandra.version>
<quill.cassandra.version>4.6.0</quill.cassandra.version>
<joda-time.version>2.10</joda-time.version>
<kafka-clients.version>2.3.0</kafka-clients.version>
<json4s-native.version>3.6.0</json4s-native.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ import scala.concurrent.{ ExecutionContext, Future }

/**
* Represents the queries linked to the EventLogRow case class and to the Events Table
*
* @important
* Since at least quill 3.12, dynamic query might leads to OutOfMemory.
* Therefore, we need to avoid using it.
* @see [[https://github.com/zio/zio-quill/issues/2484]]
*/
trait EventLogQueries extends CassandraBase with CustomEncodings[EventLogRow] {

Expand All @@ -22,7 +27,7 @@ trait EventLogQueries extends CassandraBase with CustomEncodings[EventLogRow] {
}

def insertQ(eventLogRow: EventLogRow) = quote {
querySchema[EventLogRow]("events").insert(lift(eventLogRow))
querySchema[EventLogRow]("events").insertValue(lift(eventLogRow))
}

def deleteQ(eventLogRow: EventLogRow) = quote {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ trait LookupKeyQueries extends CassandraBase with CustomEncodings[LookupKeyRow]
}

def insertQ(lookupKeyRow: LookupKeyRow) = quote {
querySchema[LookupKeyRow]("lookups").insert(lift(lookupKeyRow))
querySchema[LookupKeyRow]("lookups").insertValue(lift(lookupKeyRow))
}

}
Expand Down
3 changes: 2 additions & 1 deletion event-log-service/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ ENTRYPOINT [ \
"-c", \
"exec /usr/bin/java \
-XX:MaxRAM=$(( $(cat /sys/fs/cgroup/memory/memory.limit_in_bytes) - 254*1024*1024 )) \
-XX:+ExitOnOutOfMemoryError \
-Djava.awt.headless=true \
-Djava.security.egd=file:/dev/./urandom \
-Djava.rmi.server.hostname=localhost \
Expand All @@ -40,4 +41,4 @@ ENTRYPOINT [ \
# Add Maven dependencies (not shaded into the artifact; Docker-cached)
COPY ${JAR_LIBS} /usr/share/service/lib
# Add the service itself
COPY ${JAR_FILE} /usr/share/service/main.jar
COPY ${JAR_FILE} /usr/share/service/main.jar
5 changes: 3 additions & 2 deletions event-log-verification-service/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ ENTRYPOINT [ \
"/bin/bash", \
"-c", \
"exec /usr/bin/java \
-XX:MaxRAM=$(($(cat /sys/fs/cgroup/memory/memory.limit_in_bytes) * 95 / 100 )) \
-XX:MaxRAMFraction=1 \
-XX:MaxRAM=$(($(cat /sys/fs/cgroup/memory/memory.limit_in_bytes) * 95 / 100 )) \
-XX:MaxRAMFraction=1 \
-XX:+ExitOnOutOfMemoryError \
-Djava.awt.headless=true \
-Djava.security.egd=file:/dev/./urandom \
-Djava.rmi.server.hostname=localhost \
Expand Down

0 comments on commit 5aaec60

Please sign in to comment.