Skip to content

Defer abandoned connection trace formatting - #1048

Open
sainadh777 wants to merge 1 commit into
apache:mainfrom
sainadh777:fix/jdbc-pool-lazy-abandoned-trace
Open

Defer abandoned connection trace formatting#1048
sainadh777 wants to merge 1 commit into
apache:mainfrom
sainadh777:fix/jdbc-pool-lazy-abandoned-trace

Conversation

@sainadh777

Copy link
Copy Markdown
Contributor

Summary

Complete maintained TODO.md item 39.1 by retaining abandoned-connection stack frames and formatting them only when the trace is actually read.

Rationale and impact

When logAbandoned is enabled, each connection borrow currently captures and immediately formats an exception stack trace into a String. Most of those traces are replaced by a later borrow without ever being reported.

This change stores the captured StackTraceElement[] in PooledConnection and performs the existing string formatting lazily in getStackTrace(). The public String-based accessor methods remain compatible, and the text returned for a reported abandoned connection is unchanged. The regression test verifies both deferred formatting and the eventual trace contents.

Validation

All commands used JDK 25.

  • ant -f modules/jdbc-pool/build.xml onetest -Dtest=AbandonedTraceTest -Dtomcat.xsl.loc=file:/private/tmp/tomcat-weekly.cfR2QA/webapps/docs/tomcat-docs.xsl -Dtomcat.project.loc=file:/private/tmp/tomcat-weekly.cfR2QA/modules/jdbc-pool/doc/project.xml — passed: 1 test, 0 failures, 0 errors, 0 skipped.
  • ant -f modules/jdbc-pool/build.xml test -Dtomcat.xsl.loc=file:/private/tmp/tomcat-weekly.cfR2QA/webapps/docs/tomcat-docs.xsl -Dtomcat.project.loc=file:/private/tmp/tomcat-weekly.cfR2QA/modules/jdbc-pool/doc/project.xml — passed: all JDBC-pool functional, fairness, performance, and validation suites; 0 failures and 0 errors.
  • ant validate -Dexecute.validate=true — passed Checkstyle over 7,690 files.
  • ant clean deploy — passed clean source/distribution build.
  • ant clean test in an isolated Ubuntu 24.04 arm64 container (eclipse-temurin:25-jdk-noble, Ant 1.10.14, host networking) — passed the complete unfiltered suite in 31m38s: 41,264 tests, 0 failures, 0 errors, 315 skipped across 650 reports.
  • output/build/bin/startup.sh; curl http://127.0.0.1:8080/; output/build/bin/shutdown.sh in the same Linux container — HTTP 200 received and the generated Tomcat process stopped cleanly.

For completeness, an initial unfiltered ant test on macOS was not used as the release gate because it hit platform-specific multicast routing failures, LibreSSL cipher mismatches, and pathological timing. The identical source snapshot subsequently passed the complete Linux run above.

@sainadh777

Copy link
Copy Markdown
Contributor Author

Hi @markt-asf, when you have time, would you be willing to review this JDBC-pool change? I selected you because you are a leading recent contributor to these paths and were the requested reviewer on the closest merged JDBC-pool PR. Thank you.

@sainadh777
sainadh777 marked this pull request as ready for review August 19, 2026 04:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant