suxiaogang223 opened a new pull request, #69670:
URL: https://github.com/apache/doris/pull/69670

   ### What problem does this PR solve?
   
   Issue Number: N/A
   
   Related PR: N/A
   
   Problem Summary:
   
   Repeated changes to explicit S3 credentials or session tokens create 
distinct factory cache entries. The factory previously retained every client 
strongly for its entire lifetime, so credential rotation could accumulate AWS 
SDK, connection and TLS resources. Concurrent misses for the same configuration 
could also construct duplicate clients.
   
   This change introduces a bounded LRU cache with a monotonic idle TTL, while 
preserving full configuration identity, including session tokens. A weak index 
reuses evicted clients that still have active owners, and per-key single-flight 
creation avoids duplicate construction without blocking unrelated keys.
   
   Eviction drops only the cache's reference. Holders, requests and lazy 
iterators keep their original shared ownership, including `shared_from_this()`. 
SDK construction and client destruction happen outside cache locks, holder 
replacement releases old clients outside holder locks, and shutdown waits for 
pending creators before AWS SDK teardown. The cache participates in periodic 
and memory-pressure GC and exposes retention, creation, eviction and 
client-lifetime counters.
   
   The capacity bounds cache-retained clients; it does not bound clients held 
by active work or measure SDK/TLS bytes or process RSS.
   
   ### Release note
   
   Bound BE S3 client cache retention to 128 clients with a 600-second idle TTL 
by default. The startup-only settings `s3_client_cache_capacity` and 
`s3_client_cache_idle_ttl_seconds` control these limits. A capacity of zero 
disables strong cache retention while preserving weak reuse and single-flight 
creation. Eviction preserves clients still used by active operations.
   
   ### Check List (For Author)
   
   - Test
       - [ ] Regression test
       - [x] Unit Test
       - [x] Manual test (steps below)
       - [ ] No need to test or manual test.
   
   Validation on Fedora with the final source tree:
   
   - ASAN BE build: `./build.sh --be --disable-dynamic-arch -j 6` — passed.
   - ASAN unit tests: `./run-be-ut.sh --run 
--filter='S3ClientCacheTest.*:S3ClientFactoryTest.*' -j 12` — all 53 tests 
passed, including process shutdown, with no ASAN/LSAN report.
   - Coverage includes single-flight concurrency, failed creation and retry, 
configuration collisions/token identity, LRU/TTL/zero-capacity behavior, 
weak-index cleanup, active holders and iterators surviving eviction/cache 
teardown, destruction outside locks, and SDK-member teardown ordering.
   - Built executable `doris_be --version` — passed with the JVM library path 
configured.
   - Repository clang-format 16 checks, build-hygiene checks and clang-tidy on 
changed C++ lines/headers — passed.
   - Local build used the official third-party prebuilt, disabled OpenBLAS 
dynamic architecture, and disabled BE Java-extension/CDC Java packaging.
   
   No live S3/TLS workload, regression cluster or customer 24-hour memory 
comparison was run. The unit tests verify ownership and lifecycle behavior; 
they do not establish production RSS savings.
   
   - Behavior changed:
       - [ ] No.
       - [x] Yes. S3 client retention is bounded and idle entries are eligible 
for eviction; active shared owners remain valid.
   
   - Does this need documentation?
       - [x] No. Internal cache lifecycle change; startup controls are 
described in the configuration declarations and release note.
       - [ ] Yes.
   
   ### Check List (For Reviewer who merge this PR)
   
   - [ ] Confirm the release note
   - [ ] Confirm test cases
   - [ ] Confirm document
   - [ ] Add branch pick label
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to