This is an automated email from the ASF dual-hosted git repository. alexr pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mesos.git
commit 2588d79eebb755ed8b1dc19374c385f72daf30e4 Author: Alexander Rukletsov <[email protected]> AuthorDate: Thu Sep 27 15:20:52 2018 +0200 Waited for TEARDOWN response in v1 Java scheduler shim. Destruction of the library is not always under our control. For example, the JVM can call JNI `finalize()` if the Java scheduler nullifies its reference to the V1Mesos library immediately after sending `TEARDOWN`. We want to make sure that `TEARDOWN` is sent before the Mesos library is destructed. Review: https://reviews.apache.org/r/68866 --- .../jni/org_apache_mesos_v1_scheduler_V1Mesos.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/java/jni/org_apache_mesos_v1_scheduler_V1Mesos.cpp b/src/java/jni/org_apache_mesos_v1_scheduler_V1Mesos.cpp index 2a5fbd7..e59f364 100644 --- a/src/java/jni/org_apache_mesos_v1_scheduler_V1Mesos.cpp +++ b/src/java/jni/org_apache_mesos_v1_scheduler_V1Mesos.cpp @@ -285,7 +285,24 @@ JNIEXPORT void JNICALL Java_org_apache_mesos_v1_scheduler_V1Mesos_send return; } - mesos->mesos->send(call); + // Destruction of the library is not always under our control. For example, + // the JVM can call JNI `finalize()` if the Java scheduler nullifies its + // reference to the V1Mesos library immediately after sending `TEARDOWN`, + // see MESOS-9274. + // + // We want to make sure that the `TEARDOWN` message is sent before the + // scheduler and the Mesos library are destructed (garbage collected). + // However we don't want to block forever if the message is dropped. + // + // TODO(alexr): Consider adding general support for `call()`. + if (call.type() == Call::TEARDOWN) { + const Duration timeout = Minutes(10); + bool timedout = !mesos->mesos->call(call).await(timeout); + LOG_IF(ERROR, timedout) + << "Received no response to call " << call.type() << " for " << timeout; + } else { + mesos->mesos->send(call); + } }
