This is an automated email from the ASF dual-hosted git repository.

diqiu50 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gravitino.git


The following commit(s) were added to refs/heads/main by this push:
     new 0bef4f0553 [#11221] fix(bin): Scope launcher PID lookup by home 
(#11222)
0bef4f0553 is described below

commit 0bef4f0553fa25a6c6e440eb7b782bc265db111a
Author: Qi Yu <[email protected]>
AuthorDate: Wed May 27 09:56:26 2026 +0800

    [#11221] fix(bin): Scope launcher PID lookup by home (#11222)
    
    ### What changes were proposed in this pull request?
    
    This PR scopes launcher PID detection to the current `GRAVITINO_HOME`
    in:
    
    - `bin/gravitino.sh.template`
    - `bin/gravitino-iceberg-rest-server.sh.template`
    - `bin/gravitino-lance-rest-server.sh.template`
    
    The PID lookup now matches both the server process name and the current
    installation path, and uses `ps xww` to avoid truncated command lines.
    
    ### Why are the changes needed?
    
    The old lookup only matched the server class name, so sibling Gravitino
    installations on the same host could be mistaken for the current
    installation. This could make `start`, `stop`, `restart`, and `status`
    operate on the wrong JVM.
    
    Fix: #11221
    
    ### Does this PR introduce _any_ user-facing change?
    
    Yes. Launcher scripts now detect only JVMs started from the same
    Gravitino installation directory.
    
    ### How was this patch tested?
    
    - `bash -n bin/gravitino.sh.template
    bin/gravitino-iceberg-rest-server.sh.template
    bin/gravitino-lance-rest-server.sh.template`
    - `git diff --check`
---
 .github/workflows/backend-integration-test-action.yml               | 2 +-
 bin/gravitino-iceberg-rest-server.sh.template                       | 4 +++-
 bin/gravitino-lance-rest-server.sh.template                         | 4 +++-
 bin/gravitino.sh.template                                           | 4 +++-
 .../gravitino/stats/storage/LancePartitionStatisticStorage.java     | 3 ++-
 .../gravitino/stats/storage/TestLancePartitionStatisticStorage.java | 6 ++++++
 .../integration/test/util/IcebergRESTServerManagerForDeploy.java    | 6 +++++-
 7 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/.github/workflows/backend-integration-test-action.yml 
b/.github/workflows/backend-integration-test-action.yml
index 09992506b1..0c507fc25c 100644
--- a/.github/workflows/backend-integration-test-action.yml
+++ b/.github/workflows/backend-integration-test-action.yml
@@ -30,7 +30,7 @@ jobs:
   start-runner:
     name: JDK${{ inputs.java-version }}-${{ inputs.test-mode }}-${{ 
inputs.backend }}
     runs-on: ubuntu-22.04
-    timeout-minutes: 90
+    timeout-minutes: 120
     env:
       PLATFORM: ${{ inputs.architecture }}
     steps:
diff --git a/bin/gravitino-iceberg-rest-server.sh.template 
b/bin/gravitino-iceberg-rest-server.sh.template
index 1c87a3a72a..df26c3e812 100755
--- a/bin/gravitino-iceberg-rest-server.sh.template
+++ b/bin/gravitino-iceberg-rest-server.sh.template
@@ -54,7 +54,9 @@ function check_process_status() {
 
 function found_iceberg_rest_server_pid() {
   process_name='GravitinoIcebergRESTServer';
-  RUNNING_PIDS=$(ps x | grep ${process_name} | grep -v grep | awk '{print 
$1}');
+  RUNNING_PIDS=$(
+    ps xww | grep -F "${process_name}" | grep -F "${GRAVITINO_HOME}" | grep -v 
grep | awk '{print $1}'
+  );
 
   if [[ -z "${RUNNING_PIDS}" ]]; then
     return
diff --git a/bin/gravitino-lance-rest-server.sh.template 
b/bin/gravitino-lance-rest-server.sh.template
index d0883a1536..87f6f1deb4 100644
--- a/bin/gravitino-lance-rest-server.sh.template
+++ b/bin/gravitino-lance-rest-server.sh.template
@@ -54,7 +54,9 @@ function check_process_status() {
 
 function found_lance_rest_server_pid() {
   process_name='GravitinoLanceRESTServer';
-  RUNNING_PIDS=$(ps x | grep ${process_name} | grep -v grep | awk '{print 
$1}');
+  RUNNING_PIDS=$(
+    ps xww | grep -F "${process_name}" | grep -F "${GRAVITINO_HOME}" | grep -v 
grep | awk '{print $1}'
+  );
 
   if [[ -z "${RUNNING_PIDS}" ]]; then
     return
diff --git a/bin/gravitino.sh.template b/bin/gravitino.sh.template
index 259694b570..d6ca1a8957 100755
--- a/bin/gravitino.sh.template
+++ b/bin/gravitino.sh.template
@@ -54,7 +54,9 @@ function check_process_status() {
 
 function found_gravitino_server_pid() {
   process_name='GravitinoServer';
-  RUNNING_PIDS=$(ps x | grep ${process_name} | grep -v grep | awk '{print 
$1}');
+  RUNNING_PIDS=$(
+    ps xww | grep -F "${process_name}" | grep -F "${GRAVITINO_HOME}" | grep -v 
grep | awk '{print $1}'
+  );
 
   if [[ -z "${RUNNING_PIDS}" ]]; then
     return
diff --git 
a/core/src/main/java/org/apache/gravitino/stats/storage/LancePartitionStatisticStorage.java
 
b/core/src/main/java/org/apache/gravitino/stats/storage/LancePartitionStatisticStorage.java
index ec2579f7a7..5755d1bd56 100644
--- 
a/core/src/main/java/org/apache/gravitino/stats/storage/LancePartitionStatisticStorage.java
+++ 
b/core/src/main/java/org/apache/gravitino/stats/storage/LancePartitionStatisticStorage.java
@@ -21,6 +21,7 @@ package org.apache.gravitino.stats.storage;
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.github.benmanes.caffeine.cache.Cache;
 import com.github.benmanes.caffeine.cache.Caffeine;
+import com.github.benmanes.caffeine.cache.RemovalCause;
 import com.github.benmanes.caffeine.cache.RemovalListener;
 import com.github.benmanes.caffeine.cache.Scheduler;
 import com.google.common.annotations.VisibleForTesting;
@@ -207,7 +208,7 @@ public class LancePartitionStatisticStorage implements 
PartitionStatisticStorage
                   .removalListener(
                       (RemovalListener<Long, DatasetHolder>)
                           (key, value, cause) -> {
-                            if (value != null) {
+                            if (value != null && cause != 
RemovalCause.EXPLICIT) {
                               closeDatasetHolder(value);
                             }
                           })
diff --git 
a/core/src/test/java/org/apache/gravitino/stats/storage/TestLancePartitionStatisticStorage.java
 
b/core/src/test/java/org/apache/gravitino/stats/storage/TestLancePartitionStatisticStorage.java
index 5a6ae16e98..79d3525700 100644
--- 
a/core/src/test/java/org/apache/gravitino/stats/storage/TestLancePartitionStatisticStorage.java
+++ 
b/core/src/test/java/org/apache/gravitino/stats/storage/TestLancePartitionStatisticStorage.java
@@ -662,6 +662,12 @@ public class TestLancePartitionStatisticStorage {
     properties.put("location", location);
     properties.put("datasetCacheSize", "10");
 
+    EntityStore entityStore = mock(EntityStore.class);
+    TableEntity tableEntity = mock(TableEntity.class);
+    when(entityStore.get(any(), any(), any())).thenReturn(tableEntity);
+    when(tableEntity.id()).thenReturn(1L);
+    FieldUtils.writeField(GravitinoEnv.getInstance(), "entityStore", 
entityStore, true);
+
     LancePartitionStatisticStorage storage = new 
LancePartitionStatisticStorage(properties);
 
     try {
diff --git 
a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/integration/test/util/IcebergRESTServerManagerForDeploy.java
 
b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/integration/test/util/IcebergRESTServerManagerForDeploy.java
index 943acde5c7..c283a19d2a 100644
--- 
a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/integration/test/util/IcebergRESTServerManagerForDeploy.java
+++ 
b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/integration/test/util/IcebergRESTServerManagerForDeploy.java
@@ -94,6 +94,10 @@ public class IcebergRESTServerManagerForDeploy extends 
IcebergRESTServerManager
   @Override
   public void doStopIcebergRESTServer() {
     String cmd = String.format("%s/bin/%s stop", 
icebergRESTServerHome.toString(), SCRIPT_NAME);
-    CommandExecutor.executeCommandLocalHost(cmd, false, TypesOfData.ERROR);
+    CommandExecutor.executeCommandLocalHost(
+        cmd,
+        false,
+        TypesOfData.ERROR,
+        ImmutableMap.of("GRAVITINO_HOME", icebergRESTServerHome.toString()));
   }
 }

Reply via email to