| 1 |
# Analyzing Lock Issues |
| 2 |
|
| 3 |
<!-- |
| 4 |
Licensed to the Apache Software Foundation (ASF) under one |
| 5 |
or more contributor license agreements. See the NOTICE file |
| 6 |
distributed with this work for additional information |
| 7 |
regarding copyright ownership. The ASF licenses this file |
| 8 |
to you under the Apache License, Version 2.0 (the |
| 9 |
"License"); you may not use this file except in compliance |
| 10 |
with the License. You may obtain a copy of the License at |
| 11 |
|
| 12 |
http://www.apache.org/licenses/LICENSE-2.0 |
| 13 |
|
| 14 |
Unless required by applicable law or agreed to in writing, |
| 15 |
software distributed under the License is distributed on an |
| 16 |
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 17 |
KIND, either express or implied. See the License for the |
| 18 |
specific language governing permissions and limitations |
| 19 |
under the License. |
| 20 |
--> |
| 21 |
|
| 22 |
This guide will show you how to collect and analyze lock issues to report with us. |
| 23 |
|
| 24 |
## Prerequisites |
| 25 |
|
| 26 |
Make sure that the following applies: |
| 27 |
|
| 28 |
- Bash or Bash-compatible shell installed |
| 29 |
- BSD or GNU userland installed |
| 30 |
- SQLite installed |
| 31 |
- At least Maven 3.9.0 |
| 32 |
|
| 33 |
Prepare your environment: |
| 34 |
|
| 35 |
- Set Maven home to `MAVEN_HOME` |
| 36 |
- Select a lock factory, a name mapper, a parallel job count (processes), a build count and set |
| 37 |
`LOCK_FACTORY`, `NAME_MAPPER`, `JOB_COUNT`, `BUILD_COUNT` |
| 38 |
- Set your root working directory to `ROOT` |
| 39 |
- Set your project name with `PROJECT_NAME` |
| 40 |
- Obtain your project source into `$PROJECT_NAME-1` to `$PROJECT_NAME-$JOB_COUNT` |
| 41 |
- Decide whether each job and build will have its own distinct local repository or a shared one |
| 42 |
and set it to `LOCAL_REPO` |
| 43 |
- Download [`schema.sql`](./sql/schema.sql), [`create_lock_events.sql`](./sql/create_lock_events.sql), |
| 44 |
[`create_lock_workflows.sql`](./sql/create_lock_workflows.sql) and set `SCHEMA_FILE`, |
| 45 |
`CREATE_LOCK_EVENTS_FILE`, `CREATE_LOCK_WORKFLOWS_FILE` to their respective locations |
| 46 |
|
| 47 |
TIP: See [overview](./index.html) of possible values for `LOCK_FACTORY` and `NAME_MAPPER`. |
| 48 |
|
| 49 |
## Running Builds |
| 50 |
|
| 51 |
Open `$JOB_COUNT` terminals and change into the `$ROOT/$PROJECT_NAME-1` to `$ROOT/$PROJECT_NAME-$JOB_COUNT` |
| 52 |
directories. Now start each job in a build loop: |
| 53 |
``` |
| 54 |
$ for build in $(eval echo {1..$BUILD_COUNT}); do \ |
| 55 |
# Only if dedicated |
| 56 |
rm -rf $LOCAL_REPO; \ |
| 57 |
$MAVEN_HOME/bin/mvn clean compile -T1C -B -DskipTests -Dmaven.repo.local=$LOCAL_REPO \ |
| 58 |
-Dorg.slf4j.simpleLogger.showThreadName=true -Dorg.slf4j.simpleLogger.showDateTime=true \ |
| 59 |
-Dorg.slf4j.simpleLogger.log.org.eclipse.aether=trace -l $LOCK_FACTORY-$NAME_MAPPER-$build.log \ |
| 60 |
# Adjust to your needs |
| 61 |
-Daether.connector.basic.threads=8 -Daether.metadataResolver.threads=8 \ |
| 62 |
# If downloads take longer consider to increase |
| 63 |
-Daether.syncContext.named.time=120 \ |
| 64 |
-Daether.syncContext.named.factory=$LOCK_FACTORY -Daether.syncContext.named.nameMapper=$NAME_MAPPER; \ |
| 65 |
done |
| 66 |
``` |
| 67 |
|
| 68 |
Wait for all jobs to complete. |
| 69 |
|
| 70 |
TIP: If you don't need parallel (multiprocess) builds, you can set `JOB_COUNT` to 1. |
| 71 |
|
| 72 |
## Analyzing Builds |
| 73 |
|
| 74 |
We now need to extract, transform and load the data (ETL) into a SQLite database. |
| 75 |
|
| 76 |
Change back to the `$ROOT` directory and collect all log files with build failures: |
| 77 |
``` |
| 78 |
$ BUILD_FAILURE_LIST=$(mktemp) |
| 79 |
$ grep -l -r "BUILD FAILURE" $PROJECT_NAME-* > $BUILD_FAILURE_LIST |
| 80 |
``` |
| 81 |
Run extraction and transformation: |
| 82 |
``` |
| 83 |
$ while read log_file; do \ |
| 84 |
grep -e Acquiring -e Releasing -e "Failed to acquire" $log_file | \ |
| 85 |
sed -e 's# \[#;[#g' -e 's#\] #];#' -e "s#^#$log_file;#" | \ |
| 86 |
sed 's#\[TRACE\];##'; \ |
| 87 |
done < $BUILD_FAILURE_LIST > $LOCK_FACTORY-$NAME_MAPPER-locks.txt |
| 88 |
``` |
| 89 |
Load and process the data in SQLite: |
| 90 |
``` |
| 91 |
$ SCRIPT=$(mktemp) |
| 92 |
$ cat > $SCRIPT <<EOT |
| 93 |
.read $SCHEMA_FILE |
| 94 |
.separator ; |
| 95 |
.import $LOCK_FACTORY-$NAME_MAPPER-locks.txt lock_history |
| 96 |
.read $CREATE_LOCK_EVENTS_FILE |
| 97 |
.read $CREATE_LOCK_WORKFLOWS_FILE |
| 98 |
.save $LOCK_FACTORY-$NAME_MAPPER-locks.db |
| 99 |
EOT |
| 100 |
$ sqlite3 -batch < $SCRIPT |
| 101 |
$ rm -f $SCRIPT |
| 102 |
``` |
| 103 |
|
| 104 |
## Uploading Data |
| 105 |
|
| 106 |
Compress the SQLite database as well as the log files: |
| 107 |
``` |
| 108 |
$ tar -caf $LOCK_FACTORY-$NAME_MAPPER-locks.db.xz $LOCK_FACTORY-$NAME_MAPPER-locks.db |
| 109 |
$ tar -caf $LOCK_FACTORY-$NAME_MAPPER-logfiles.tar.xz -T $BUILD_FAILURE_LIST |
| 110 |
$ rm -f $BUILD_FAILURE_LIST |
| 111 |
``` |
| 112 |
and upload them to the JIRA issue. |