|
| 1 | +// |
| 2 | +// Licensed to the Apache Software Foundation (ASF) under one or more |
| 3 | +// contributor license agreements. See the NOTICE file distributed with |
| 4 | +// this work for additional information regarding copyright ownership. |
| 5 | +// The ASF licenses this file to You under the Apache License, Version 2.0 |
| 6 | +// (the "License"); you may not use this file except in compliance with |
| 7 | +// the License. You may obtain a copy of the License at |
| 8 | +// |
| 9 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +// |
| 11 | +// Unless required by applicable law or agreed to in writing, software |
| 12 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +// See the License for the specific language governing permissions and |
| 15 | +// limitations under the License. |
| 16 | +// |
| 17 | + |
| 18 | += Pipes Troubleshooting |
| 19 | + |
| 20 | +This page covers diagnosing problems with the forked `PipesServer` processes |
| 21 | +that Tika Pipes uses for per-document isolation. The most common symptom is a |
| 22 | +forked process that dies during startup, or one that becomes unresponsive |
| 23 | +mid-run. |
| 24 | + |
| 25 | +== When a forked server fails to start |
| 26 | + |
| 27 | +The Tika parent process always logs the exit code of a failed fork. You will |
| 28 | +see something like: |
| 29 | + |
| 30 | +[source] |
| 31 | +---- |
| 32 | +ERROR clientId=2: Process exited with code 1 before connecting to socket |
| 33 | +ERROR Shared server process exited with code 1 before becoming ready |
| 34 | +---- |
| 35 | + |
| 36 | +For most failures (bad JVM args, missing classpath entry, OOM at boot), the |
| 37 | +parent logger additionally prints the tail of the child's stderr immediately |
| 38 | +after the exit-code line: |
| 39 | + |
| 40 | +[source] |
| 41 | +---- |
| 42 | +ERROR clientId=2: child stderr tail: |
| 43 | +Error: Could not find or load main class org.apache.tika.pipes.core.server.PipesServer |
| 44 | +---- |
| 45 | + |
| 46 | +For native crashes (segfault in a JNI parser, JVM bug), the JVM writes an |
| 47 | +`hs_err_pid<N>.log` file to the child's working directory. The parent logger |
| 48 | +will read and print that file too: |
| 49 | + |
| 50 | +[source] |
| 51 | +---- |
| 52 | +ERROR clientId=2: JVM crash log hs_err_pid12345.log: |
| 53 | +# |
| 54 | +# A fatal error has been detected by the Java Runtime Environment: |
| 55 | +# |
| 56 | +# SIGSEGV (0xb) at pc=0x00007f... |
| 57 | +... |
| 58 | +---- |
| 59 | + |
| 60 | +In short: read the *parent* application's log first. The diagnostics from the |
| 61 | +dead child are inlined there, so you don't have to find anything on disk. |
| 62 | + |
| 63 | +== Keeping child log files for post-mortem analysis |
| 64 | + |
| 65 | +By default, each forked server's stdout, stderr, and any JVM crash logs are |
| 66 | +written into a per-server temp directory. The temp directory is cleaned up |
| 67 | +when the manager shuts the server down. If you need to keep those files |
| 68 | +around -- for example, to diff stderr across multiple failed restart attempts, |
| 69 | +or to ship crash logs to a support contact -- set the |
| 70 | +`tika.pipes.server.logDir` system property on the *parent* JVM: |
| 71 | + |
| 72 | +[source,bash] |
| 73 | +---- |
| 74 | +java -Dtika.pipes.server.logDir=/var/log/tika-pipes-crashes \ |
| 75 | + -jar your-app.jar ... |
| 76 | +---- |
| 77 | + |
| 78 | +When set, the manager copies the child's `server-stdout.log`, |
| 79 | +`server-stderr.log`, and any `hs_err_pid*.log` files to that directory on |
| 80 | +every abnormal exit, with a timestamp prefix: |
| 81 | + |
| 82 | +[source] |
| 83 | +---- |
| 84 | +/var/log/tika-pipes-crashes/ |
| 85 | + 1748307123456-server-stderr.log |
| 86 | + 1748307123456-hs_err_pid12345.log |
| 87 | + 1748307145001-server-stderr.log # later restart attempt |
| 88 | +---- |
| 89 | + |
| 90 | +The property is off by default. Leave it off in steady-state production; turn |
| 91 | +it on when you are actively debugging a recurring fork failure. |
| 92 | + |
| 93 | +== What does *not* go to those files |
| 94 | + |
| 95 | +Steady-state log output from the parser (every parse, every emitter, every |
| 96 | +embedded-document warning) does **not** go to `server-stderr.log`. It goes |
| 97 | +through SLF4J inside the child JVM and lands in whatever your `log4j2.xml` or |
| 98 | +`logback.xml` directs it to. The child's stderr is only useful for things the |
| 99 | +JVM writes before logging is wired up, or that bypass logging entirely: |
| 100 | + |
| 101 | +* JVM startup errors (bad classpath, unrecognized flag, "could not find main |
| 102 | + class"). |
| 103 | +* Uncaught throwables on the main thread that never reached an SLF4J logger. |
| 104 | +* Output from `System.err.println` calls (if any). |
| 105 | + |
| 106 | +For native crash investigation, the JVM-generated `hs_err_pid<N>.log` is the |
| 107 | +primary artifact, and it is collected automatically as described above. |
0 commit comments