Skip to content

Commit

Permalink
Merge pull request #6621 from srbaker/move-and-improve-gc-log
Browse files Browse the repository at this point in the history
Move and improve gc log
  • Loading branch information
srbaker committed Mar 8, 2016
2 parents 51063e1 + f136a87 commit 86899fa
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 32 deletions.
13 changes: 9 additions & 4 deletions community/server/src/docs/ops/server-configuration.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,19 @@ Failure to transmit both `X-Forwarded-Host` and `X-Forwarded-Proto` headers will

== Enabling logging from the garbage collector ==

To get garbage collection logging output you have to pass the corresponding option to the server JVM executable by setting the following value in _conf/neo4j-wrapper.conf_:
To get garbage collection logging output you have to enable GC logging by setting the following value in _neo4j.conf_:
[source,properties]
----
dbms.jvm.additional=-Xloggc:data/log/neo4j-gc.log
dbms.logs.gc.enabled=true
----
This line is already present and needs uncommenting.
Note also that logging is not directed to console.
You will find the logging statements in _data/log/ne4j-gc.log_ or whatever directory you set the option to.
You will find the logging statements in _data/log/gc.log_ or whatever directory you set the option to.

To set specific options for garbage collection logging, use the setting _dbms.logs.gc.options_ and pass the options that should be passed to the JVM. The following example shows the default value:
[source,properties]
----
dbms.logs.gc.options=-XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCApplicationStoppedTime -XX:+PrintPromotionFailure -XX:+PrintTenuringDistribution
----

[[server-browser-config]]
== Web Interface configuration settings ==
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,7 @@
import org.neo4j.kernel.configuration.Internal;
import org.neo4j.kernel.configuration.Settings;

import static org.neo4j.kernel.configuration.Settings.BOOLEAN;
import static org.neo4j.kernel.configuration.Settings.DURATION;
import static org.neo4j.kernel.configuration.Settings.EMPTY;
import static org.neo4j.kernel.configuration.Settings.FALSE;
import static org.neo4j.kernel.configuration.Settings.INTEGER;
import static org.neo4j.kernel.configuration.Settings.NORMALIZED_RELATIVE_URI;
import static org.neo4j.kernel.configuration.Settings.NO_DEFAULT;
import static org.neo4j.kernel.configuration.Settings.STRING_LIST;
import static org.neo4j.kernel.configuration.Settings.TRUE;
import static org.neo4j.kernel.configuration.Settings.min;
import static org.neo4j.kernel.configuration.Settings.port;
import static org.neo4j.kernel.configuration.Settings.setting;
import static org.neo4j.kernel.configuration.Settings.*;

@Description("Settings used by the server configuration")
public interface ServerSettings
Expand Down Expand Up @@ -155,6 +144,20 @@ private ThirdPartyJaxRsPackage createThirdPartyJaxRsPackage( String packageAndMo
Setting<File> http_log_config_file = setting( "org.neo4j.server.http.log.config", new HttpLogSetting(),
NO_DEFAULT );

@Description("Enable GC Logging")
Setting<Boolean> gc_logging_enabled = setting("dbms.logs.gc.enabled", BOOLEAN, FALSE);

@Description("GC Logging Options")
Setting<String> gc_logging_options = setting("dbms.logs.gc.options", STRING, "" +
"-XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCApplicationStoppedTime " +
"-XX:+PrintPromotionFailure -XX:+PrintTenuringDistribution");

@Description("Number of GC logs to keep.")
Setting<Integer> gc_logging_rotation_keep_number = setting("dbms.logs.gc.rotation.keep_number", INTEGER, "5");

@Description("Size of each GC log that is kept.")
Setting<Long> gc_logging_rotation_size = setting("dbms.logs.rotation.gc.size", BYTES, "20m", min(0L), max( Long.MAX_VALUE ) );

@Description("Timeout for idle transactions.")
Setting<Long> transaction_timeout = setting( "dbms.transaction_timeout", DURATION, "60s" );

Expand Down
11 changes: 11 additions & 0 deletions packaging/standalone/src/main/distribution/shell-scripts/bin/neo4j
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,20 @@ setup_java_opts() {
[[ "${dbms_memory_heap_initial_size:-}" ]] && JAVA_MEMORY_OPTS="${JAVA_MEMORY_OPTS} -Xms${dbms_memory_heap_initial_size}m"
[[ "${dbms_memory_heap_max_size:-}" ]] && JAVA_MEMORY_OPTS="${JAVA_MEMORY_OPTS} -Xmx${dbms_memory_heap_max_size}m"

JAVA_GC_LOGGING_OPTS=""
if [ "${dbms_logs_gc_enabled:-}" = "true" ]; then
[[ ${dbms_logs_gc_options:-} ]] || dbms_logs_gc_options="-XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCApplicationStoppedTime -XX:+PrintPromotionFailure -XX:+PrintTenuringDistribution -XX:+UseGCLogFileRotation"
[[ ${dbms_logs_gc_rotation_size:-} ]] || dbms_logs_gc_rotation_size="20m"
[[ ${dbms_logs_gc_rotation_keep_number:-} ]] || dbms_logs_gc_rotation_keep_number="5"

JAVA_GC_LOGGING_OPTS="-Xloggc:${NEO4J_LOG}/gc.log ${dbms_logs_gc_options} -XX:NumberOfGCLogFiles=${dbms_logs_gc_rotation_keep_number} -XX:GCLogFileSize=${dbms_logs_gc_rotation_size}";
fi

JAVA_OPTS="-server"
[[ "${JAVA_MEMORY_OPTS}" ]] && JAVA_OPTS="${JAVA_OPTS} ${JAVA_MEMORY_OPTS}"
[[ "${dbms_jvm_additional:-}" ]] && JAVA_OPTS="${JAVA_OPTS} ${dbms_jvm_additional}"
[[ "${JAVA_GC_LOGGING_OPTS}" ]] && JAVA_OPTS="${JAVA_OPTS} ${JAVA_GC_LOGGING_OPTS}"

return 0
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,33 @@ for run_command in run_console run_daemon; do
${run_command} &&
test_expect_java_arg ':$(neo4j_home)/plugins/*'
"

test_expect_success "should set gc logging options when gc log is enabled" "
clear_config &&
set_config 'dbms.logs.gc.enabled' 'true' neo4j.conf &&
set_config 'dbms.logs.gc.options' '-XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCApplicationStoppedTime -XX:+PrintPromotionFailure -XX:+PrintTenuringDistribution' neo4j.conf &&
${run_command} &&
test_expect_java_arg '-Xloggc:$(neo4j_home)/data/log/gc.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCApplicationStoppedTime -XX:+PrintPromotionFailure -XX:+PrintTenuringDistribution'
"

test_expect_success "should set default gc logging options when none are provided" "
clear_config &&
set_config 'dbms.logs.gc.enabled' 'true' neo4j.conf &&
${run_command} &&
test_expect_java_arg '-Xloggc:$(neo4j_home)/data/log/gc.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCApplicationStoppedTime -XX:+PrintPromotionFailure -XX:+PrintTenuringDistribution -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=20m'
"

test_expect_success "should set gc logging rotation options" "
clear_config &&
set_config 'dbms.logs.gc.rotation.size' '10m' neo4j.conf &&
set_config 'dbms.logs.gc.rotation.keep_number' '8' neo4j.conf &&
set_config 'dbms.logs.gc.enabled' 'true' neo4j.conf &&
set_config 'dbms.logs.gc.options' '-XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCApplicationStoppedTime -XX:+PrintPromotionFailure -XX:+PrintTenuringDistribution -XX:+UseGCLogFileRotation' neo4j.conf &&
${run_command} &&
test_expect_java_arg '-Xloggc:$(neo4j_home)/data/log/gc.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCApplicationStoppedTime -XX:+PrintPromotionFailure -XX:+PrintTenuringDistribution'
test_expect_java_arg '-XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=8 -XX:GCLogFileSize=10m'
"
done

test_expect_success "should set heap size constraints when checking version" "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,6 @@ dbms.jvm.additional=-XX:+TrustFinalNonStaticFields
# Disable explicit garbage collection, which is occasionally invoked by the JDK itself.
dbms.jvm.additional=-XX:+DisableExplicitGC

# Uncomment the following lines to enable garbage collection logging
#dbms.jvm.additional=-Xloggc:data/log/neo4j-gc.log
#dbms.jvm.additional=-XX:+PrintGCDetails
#dbms.jvm.additional=-XX:+PrintGCDateStamps
#dbms.jvm.additional=-XX:+PrintGCApplicationStoppedTime
#dbms.jvm.additional=-XX:+PrintPromotionFailure
#dbms.jvm.additional=-XX:+PrintTenuringDistribution

# Remote JMX monitoring, uncomment and adjust the following lines as needed.
# Also make sure to update the jmx.access and jmx.password files with appropriate permission roles and passwords,
# the shipped configuration contains only a read only role called 'monitor' with password 'Neo4j'.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,24 @@ org.neo4j.server.http.log.enabled=false
# ubiquitous common log format
org.neo4j.server.http.log.config=conf/neo4j-http-logging.xml

#***************************************************************
# GC Logging
#***************************************************************

# Enable GC Logging by uncommenting this line.
#dbms.logs.gc.enabled=true

# GC Logging Options
# see http://docs.oracle.com/cd/E19957-01/819-0084-10/pt_tuningjava.html#wp57013 for more information.
#dbms.logs.gc.options=-XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCApplicationStoppedTime -XX:+PrintPromotionFailure -XX:+PrintTenuringDistribution

# Number of GC logs to keep.
#dbms.logs.gc.rotation.keep_number=5

# Size of each GC log that is kept.
#dbms.logs.rotation.gc.size=20m


# Enable this to be able to upgrade a store from an older version.
#dbms.allow_format_migration=true

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,6 @@ dbms.jvm.additional=-XX:+TrustFinalNonStaticFields
# Disable explicit garbage collection, which is occasionally invoked by the JDK itself.
dbms.jvm.additional=-XX:+DisableExplicitGC

# Uncomment the following lines to enable garbage collection logging
#dbms.jvm.additional=-Xloggc:data/log/neo4j-gc.log
#dbms.jvm.additional=-XX:+PrintGCDetails
#dbms.jvm.additional=-XX:+PrintGCDateStamps
#dbms.jvm.additional=-XX:+PrintGCApplicationStoppedTime
#dbms.jvm.additional=-XX:+PrintPromotionFailure
#dbms.jvm.additional=-XX:+PrintTenuringDistribution

# Remote JMX monitoring, uncomment and adjust the following lines as needed.
# Also make sure to update the jmx.access and jmx.password files with appropriate permission roles and passwords,
# the shipped configuration contains only a read only role called 'monitor' with password 'Neo4j'.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,23 @@ org.neo4j.server.http.log.enabled=false
# ubiquitous common log format
org.neo4j.server.http.log.config=conf/neo4j-http-logging.xml

#***************************************************************
# GC Logging
#***************************************************************

# Enable GC Logging by uncommenting this line.
#dbms.logs.gc.enabled=true

# GC Logging Options
# see http://docs.oracle.com/cd/E19957-01/819-0084-10/pt_tuningjava.html#wp57013 for more information.
#dbms.logs.gc.options=-XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCApplicationStoppedTime -XX:+PrintPromotionFailure -XX:+PrintTenuringDistribution

# Number of GC logs to keep.
#dbms.logs.gc.rotation.keep_number=5

# Size of each GC log that is kept.
#dbms.logs.rotation.gc.size=20m

# Enable this to be able to upgrade a store from an older version.
#dbms.allow_format_migration=true

Expand Down

0 comments on commit 86899fa

Please sign in to comment.