Repository navigation
Add a GCS external payload storage driver - #3151
Conversation
The README example used a bounded ThreadPoolExecutor with an abort policy. A store or retrieve submits one task per payload, so any batch larger than the pool and queue combined was rejected and failed as a whole, and failed again on every retry. Recommend Executors.newVirtualThreadPerTaskExecutor() instead, which runs each GCS call on its own virtual thread and never rejects work. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
store() built each claim before uploading and then read the object name back out of the claim map by key. Keep the object name and hash on PreparedPayload instead, and build the claim once the upload succeeds. retrieve() validated each hash with String.matches, which compiles the regex on every call. Use a precompiled Pattern. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@jmaeagle99 this java GCS support is ready for review now, thanks |
The README only covered virtual threads, which require Java 21, while the SDK supports Java 8. Testing against real GCS showed that a fixed thread pool sized to the worker's slots performs the same, and that a smaller pool queues storage calls and slows workflow tasks. Explain that worker slots, not the executor, limit concurrent GCS calls and payload memory, since the SDK waits on each storage operation from the worker thread. Warn against rejecting queues and CallerRunsPolicy. Recommend gRPC only for workers in Google Cloud, where DirectPath outperformed HTTP, and HTTP elsewhere, where gRPC uploads were much slower. Note that the gRPC client exports metrics to Cloud Monitoring by default and how to avoid the resulting permission warnings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tested against real GCSI ran this branch end to end against real Google Cloud Storage and Temporal, over both HTTP and gRPC. Tests ran from AWS and from a GCP VM in the same region as the bucket. No bugs found. Over 150,000 storage calls, nothing failed and every payload came back exactly as stored. Large payloads, unusual names, tampered files, cancelled uploads and worker restarts all behaved correctly. The main test was an AI agent that sends its whole conversation to each LLM call, 200 conversations at once. A 500k-token conversation is about 2 MB per call. On the GCP VM:
Running this on GCP
|
|
Hey @diwu-sf, I apologize for not having looked at this yet. I'll will get to it this week. |
…torage # Conflicts: # CHANGELOG.md
|
@jmaeagle99 please help review and appreciate any feedback, we're looking forward to using this on our Java backend. |
Move the future and hashing helpers out of temporal-sdk and back into the drivers. Drivers compile against the SDK but run with whatever SDK version the application uses, so depending on internal SDK classes could break when driver and SDK versions differ. The S3 driver is restored to match main, and the GCS driver keeps its own package-private copies.
Payloads are stored again during replay, and each store previously sent the full payload only for GCS to reject it as a duplicate. The driver now checks for the object first and skips the upload when it is already there, matching the S3 driver and the other SDKs' GCS drivers. The client interface gains objectExists, and cancellation reaches whichever request is in flight.
Add a describe() method to the GCS client interface, matching the S3 driver and the other SDKs' GCS drivers. The Google client adapter reports its project, and the driver adds it to existence check, upload, and download failure messages.
Add a BucketResolver, matching the S3 driver, so applications can pick the upload bucket from the payload and its workflow or activity context. setBucket remains as a shortcut for a single bucket. Downloads already use the bucket recorded in each reference, so they are unchanged.
Lower google-cloud-storage from 2.75.0 to 2.62.0, the newest release that stays on protobuf 3.25.x and gRPC 1.76.x. 2.75.0 forced protobuf 4.33 and gRPC 1.83, beyond the versions the SDK is built and tested against.
Applications no longer have to supply an executor. By default the adapter runs GCS calls on its own pool of up to 400 threads, matching the worker's default task slots. Threads start on demand, idle threads stop, and calls beyond the limit wait in a queue instead of failing. setThreadPoolMaxSize changes the limit, and setExecutor supplies a custom executor instead; setting both is an error. The adapter is now AutoCloseable and close() shuts down only the pool it created.
A store could wait forever when starting the upload threw an Error, such as failing to start a pool thread, or when a client returned a null future. These now fail the future, and the adapter reports any executor failure, not just rejection. Also name causes that have no message, fail the future when describe() throws, skip describe() for empty batches, skip an upload whose batch has already finished, and correct the README on how worker slots limit GCS calls.
The URL(String) constructor is deprecated since JDK 20. The Edge build targets Java 21 with -Xlint:deprecation -Werror, so the fake GCS server helper failed to compile there. Build the URL through URI.create(...) .toURL(), which works on Java 8 and matches other HTTP calls in the SDK.
1.41.0 was cut after this branch was created, so merging main left the entry inside the released 1.41.0 section.
What changed?
Added an experimental Google Cloud Storage driver for external payloads and an adapter for the official Google Cloud Storage Java client.
Object names follow the existing GCS drivers' encoding and namespace layout, with a namespace-preserving fallback for long names. Claims use
object_name. Uploads leave existing objects unchanged, and downloads verify SHA-256 before decoding the complete payload, including metadata.The application owns the Google client and executor. Includes setup documentation and automatic integration tests against
fsouza/fake-gcs-server. Gradle downloads and caches a checksum-verified native binary; JUnit starts the server on a free local port and cleans up afterward.The quickstart uses
StorageOptions.grpc()for automatic DirectPath selection and includes a short note on preserving Google's runtime dependencies, service registrations, and Conscrypt native libraries when packaging an application.Why?
Store large Temporal payloads in GCS without writing a custom storage driver.
Related to temporalio/sdk-java#3254.
Breaking changes?
No existing SDK API changes. The optional Google client adapter brings newer protobuf and gRPC dependencies.
Server PR
Not required.
Testing
./gradlew --offline spotlessApplypassed.build, including tests and Javadocs, with Java 21 and Java 8 release compatibility checks.