Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .cursor/commands/create-improvement.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ When the planned code changes are complete, the agent should take the following
- Ensure changes are adequately tested

2. **Create Pull Request**
- Create a PR in draft mode
- Create a PR
- Rename the PR with a title that follows the Conventional Commits 1.0.0 format
- Update the PR description with:
- A clear description of the problem and solution
Expand Down
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Pinecone API Configuration
# Copy this file to .env and fill in your actual API key
# The .env file is gitignored and will not be committed

PINECONE_API_KEY=your-api-key-here
6 changes: 4 additions & 2 deletions .github/workflows/cleanup-test-resources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:
age_threshold_days:
description: 'Minimum age in days for resources to be deleted'
required: false
default: '1'
default: 1
type: number
dry_run:
description: 'Preview deletions without executing (dry-run mode)'
Expand Down Expand Up @@ -63,7 +63,9 @@ jobs:
echo "Running cleanup with: $ARGS"

# Run the cleanup utility
java -cp "build/libs/*:build/classes/java/main" \
# Use only the shadow JAR (-all.jar) which contains all dependencies
# This avoids classpath conflicts from mixing regular JAR, shadow JAR, and other artifacts
java -cp build/libs/*-all.jar \
io.pinecone.helpers.IndexCleanupUtility $ARGS

- name: Summary
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,6 @@ jobs:
continue-on-error: true
run: |
echo "Running IndexCleanupUtility to clean up test indexes..."
java -cp "build/libs/*" io.pinecone.helpers.IndexCleanupUtility
java -cp build/libs/*-all.jar io.pinecone.helpers.IndexCleanupUtility
env:
PINECONE_API_KEY: ${{ secrets.PINECONE_API_KEY }}
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,10 @@ nb-configuration.xml
##############################
.DS_Store

##############################
## Environment Variables
##############################
.env
.env.local

gen
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

[comment]: <> (When bumping [pc:VERSION_LATEST_RELEASE] create a new entry below)
### Unreleased version
- Improve default HTTP timeout configuration: Set default timeouts to 30s connect, 120s read, and 30s write to accommodate long-running control plane operations like index creation/deletion. Users can still override with custom OkHttpClient if needed.

### 6.1.0
- Add ResponseMetadataListener for dataplane operation observability

Expand Down
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,18 @@ public class InitializeClientExample {
}
```

#### Default HTTP Timeout Configuration

The Pinecone client uses default HTTP timeouts that are suitable for most operations:
- **Connect timeout**: 30 seconds
- **Read timeout**: 120 seconds (accommodates long-running operations like index creation/deletion)
- **Write timeout**: 30 seconds

These defaults are designed to handle operations that may take longer than typical HTTP requests, such as creating or deleting indexes which can take 30-120+ seconds.

#### Passing OkHttpClient for control plane operations

If you need to provide a custom `OkHttpClient`, you can do so by using the `withOkHttpClient()` method of the
If you need to provide a custom `OkHttpClient` with different timeout values or other custom configuration, you can do so by using the `withOkHttpClient()` method of the
`Pinecone.Builder` class to pass in your `OkHttpClient` object.

```java
Expand All @@ -74,10 +83,11 @@ import okhttp3.OkHttpClient;

public class InitializeClientExample {
public static void main(String[] args) {
// Example: Custom timeout configuration for specific use cases
OkHttpClient.Builder builder = new OkHttpClient.Builder()
.connectTimeout(10, java.util.concurrent.TimeUnit.SECONDS)
.readTimeout(30, java.util.concurrent.TimeUnit.SECONDS)
.writeTimeout(30, java.util.concurrent.TimeUnit.SECONDS);
.connectTimeout(60, java.util.concurrent.TimeUnit.SECONDS)
.readTimeout(180, java.util.concurrent.TimeUnit.SECONDS)
.writeTimeout(60, java.util.concurrent.TimeUnit.SECONDS);

OkHttpClient httpClient = builder.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import io.pinecone.exceptions.PineconeForbiddenException;
import io.pinecone.exceptions.PineconeNotFoundException;
import io.pinecone.helpers.TestResourcesManager;
import okhttp3.OkHttpClient;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
Expand All @@ -14,8 +13,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.concurrent.TimeUnit;

import static io.pinecone.helpers.AssertRetry.assertWithRetry;
import static org.junit.jupiter.api.Assertions.*;

Expand All @@ -25,11 +22,6 @@ public class ConfigureIndexTest {
private static final Pinecone controlPlaneClient = new Pinecone
.Builder(System.getenv("PINECONE_API_KEY"))
.withSourceTag("pinecone_test")
.withOkHttpClient(new OkHttpClient.Builder()
.connectTimeout(10, TimeUnit.SECONDS)
.readTimeout(60, TimeUnit.SECONDS)
.writeTimeout(30, TimeUnit.SECONDS)
.build())
.build();
private static String indexName;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@

import io.pinecone.clients.Pinecone;
import io.pinecone.helpers.RandomStringBuilder;
import okhttp3.OkHttpClient;
import org.junit.jupiter.api.*;
import org.openapitools.db_control.client.ApiException;
import org.openapitools.db_control.client.model.*;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;

import static io.pinecone.helpers.TestUtilities.waitUntilIndexIsReady;
import static io.pinecone.helpers.TestUtilities.waitUntilReadCapacityIsReady;
Expand All @@ -20,11 +18,6 @@ public class ReadCapacityAndSchemaTest {
private static final Pinecone controlPlaneClient = new Pinecone
.Builder(System.getenv("PINECONE_API_KEY"))
.withSourceTag("pinecone_test")
.withOkHttpClient(new OkHttpClient.Builder()
.connectTimeout(30, TimeUnit.SECONDS)
.readTimeout(120, TimeUnit.SECONDS)
.writeTimeout(30, TimeUnit.SECONDS)
.build())
.build();

@Test
Expand Down Expand Up @@ -64,7 +57,7 @@ public void createServerlessIndexWithDedicatedReadCapacity() throws InterruptedE
tags.put("read-capacity", "dedicated");

// Create index with Dedicated read capacity
ScalingConfigManual manual = new ScalingConfigManual().shards(2).replicas(2);
ScalingConfigManual manual = new ScalingConfigManual().shards(1).replicas(1);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Undocumented test configuration change reduces test coverage

Low Severity

The ScalingConfigManual configuration was changed from shards(2).replicas(2) to shards(1).replicas(1) in the createServerlessIndexWithDedicatedReadCapacity test. This change is not mentioned in the PR description and appears unrelated to the PR's stated purpose of fixing CI cleanup utility classpath issues and adding timeout configuration. The test now validates a minimal dedicated read capacity configuration instead of testing multi-shard/multi-replica setups.

Fix in Cursor Fix in Web

ReadCapacityDedicatedConfig dedicated = new ReadCapacityDedicatedConfig()
.nodeType("t1")
.scaling("Manual")
Expand Down
24 changes: 23 additions & 1 deletion src/main/java/io/pinecone/clients/Pinecone.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.util.Arrays;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;

/**
* The Pinecone class is the main entry point for interacting with Pinecone via the Java SDK.
Expand Down Expand Up @@ -1798,8 +1799,29 @@ public Pinecone build() {
}
}

/**
* Builds an OkHttpClient with default timeout configuration suitable for Pinecone operations.
* <p>
* Default timeout values:
* <ul>
* <li>Connect timeout: 30 seconds - sufficient for network connection establishment</li>
* <li>Read timeout: 120 seconds - accommodates long-running control plane operations like index creation/deletion</li>
* <li>Write timeout: 30 seconds - sufficient for request payload transmission</li>
* </ul>
* <p>
* These defaults are designed to handle operations that may take longer than typical HTTP requests,
* such as creating or deleting indexes which can take 30-120+ seconds. For operations requiring
* different timeout values, users can provide a custom OkHttpClient via {@link Builder#withOkHttpClient(OkHttpClient)}.
*
* @param proxyConfig Optional proxy configuration. If provided, the client will route requests through the specified proxy.
* @return A configured OkHttpClient instance with default timeouts suitable for Pinecone operations.
*/
static OkHttpClient buildOkHttpClient(ProxyConfig proxyConfig) {
OkHttpClient.Builder builder = new OkHttpClient.Builder();
OkHttpClient.Builder builder = new OkHttpClient.Builder()
.connectTimeout(30, TimeUnit.SECONDS)
.readTimeout(120, TimeUnit.SECONDS)
.writeTimeout(30, TimeUnit.SECONDS);

if(proxyConfig != null) {
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyConfig.getHost(), proxyConfig.getPort()));
builder.proxy(proxy);
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/io/pinecone/helpers/IndexCleanupUtility.java
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,9 @@ private boolean cleanupIndex(IndexModel index) throws Exception {
pinecone.deleteIndex(indexName);
logInfo("Successfully initiated deletion of index: %s", indexName);

// Add small delay to avoid rate limiting
Thread.sleep(1000);
// Add delay to avoid overwhelming the backend
logInfo("Waiting 30 seconds before next deletion...");
Thread.sleep(30000);
return true;
}

Expand Down Expand Up @@ -279,8 +280,9 @@ private boolean cleanupCollection(CollectionModel collection) throws Exception {
pinecone.deleteCollection(collectionName);
logInfo("Successfully initiated deletion of collection: %s", collectionName);

// Add small delay to avoid rate limiting
Thread.sleep(1000);
// Add delay to avoid overwhelming the backend
logInfo("Waiting 30 seconds before next deletion...");
Thread.sleep(30000);
return true;
}

Expand Down
Loading