valkey-io / valkey-glide

An open source Valkey client library that supports Valkey and Redis open source 6.2, 7.0 and 7.2. Valkey GLIDE is designed for reliability, optimized performance, and high-availability, for Valkey and Redis OSS based applications. GLIDE is a multi language client library, written in Rust with programming language bindings, such as Java and Python
Apache License 2.0
258 stars 53 forks source link

RuntimeException: Current platform supports no known thread pool resources on Amazon Linux 2023 #2589

Open kpramesh2212 opened 1 day ago

kpramesh2212 commented 1 day ago

Describe the bug

When attempting to connect to a Redis cluster using the Valkey Glide client in a Spring Boot 3 application on Amazon Linux 2023 (x86_64), I encounter the following error:

java.lang.RuntimeException: Current platform supports no known thread pool resources

java.lang.RuntimeException: Current platform supports no known thread pool resources
        at glide.connectors.resources.Platform.getThreadPoolResourceSupplier(Platform.java:67) ~[valkey-glide-1.1.0-linux-x86_64.jar!/:na]
         at glide.api.BaseClient.createClient(BaseClient.java:363) ~[valkey-glide-1.1.0-linux-x86_64.jar!/:na]
        at glide.api.GlideClient.createClient(GlideClient.java:90) ~[valkey-glide-1.1.0-linux-x86_64.jar!/:na]

This issue does not occur when running the same application on Ubuntu/Debian systems.

The following are system details

Amzona Linux 3:

NAME="Amazon Linux"
VERSION="2023"
ID="amzn"
ID_LIKE="fedora"
VERSION_ID="2023"
PLATFORM_ID="platform:al2023"
PRETTY_NAME="Amazon Linux 2023.6.20241010"
ANSI_COLOR="0;33"
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2023"
HOME_URL="https://aws.amazon.com/linux/amazon-linux-2023/"
DOCUMENTATION_URL="https://docs.aws.amazon.com/linux/"
SUPPORT_URL="https://aws.amazon.com/premiumsupport/"
BUG_REPORT_URL="https://github.com/amazonlinux/amazon-linux-2023"
VENDOR_NAME="AWS"
VENDOR_URL="https://aws.amazon.com/"
SUPPORT_END="2028-03-15"

Java version:

openjdk version "17.0.13" 2024-10-15
OpenJDK Runtime Environment Temurin-17.0.13+11 (build 17.0.13+11)
OpenJDK 64-Bit Server VM Temurin-17.0.13+11 (build 17.0.13+11, mixed mode, sharing)

Expected Behavior

The application should successfully connect to the Redis cluster using the Glide client without any runtime exceptions.

Current Behavior

The application fails to establish a connection to the Redis cluster and throws a RuntimeException indicating that no known thread pool resources are available for the current platform.

Reproduction Steps

  1. Set up a Spring Boot 3 application Java 17 with the Valkey Glide client.

Creating the bean as follows in spring boot 3

    @Bean
    @Lazy
    public GlideClient glideClient(ErebusJavaTestingServiceProperties properties, @Value("${redis.cluster.useSsl}") boolean useSsl) throws ExecutionException, InterruptedException {
        String host = properties.getRedisClusterNode();
        int port = properties.getRedisClusterPort();
        LOG.info("Glide Connection to Redis cluster {} at port {} using TLS {}", host, port, useSsl);
        var clientConfiguration = GlideClientConfiguration
                .builder()
                .address(NodeAddress.builder().host(host).port(port).build())
                .useTLS(useSsl)
                .build();
        return GlideClient.createClient(clientConfiguration).get();
    }
  1. Use the Glide client to attempt a connection to a Redis cluster on an Amazon Linux 2023 (x86_64) system.

  2. Observe the error message in the logs.

Possible Solution

No response

Additional Information/Context

The exact application works perfectly fine on debian/ubuntu machine

Client version used

valkey-glide-1.1.0-linux-x86_64.jar

Engine type and version

AWS::ElastiCache::ReplicationGroup 7.1.0

OS

Amazon Linux 2023 - X86_64

Language

Java

Language Version

OpenJDK Runtime Environment Temurin-17.0.13+11

Cluster information

No response

Logs

No response

Other information

No response

acarbonetto commented 1 day ago

If epoll and kqueue thread pools are not available (see https://github.com/valkey-io/valkey-glide/blob/main/java/client/build.gradle#L23-L26), you will need support for nio or io-ring thread pools. These are not yet supported by Glide.
see: https://github.com/valkey-io/valkey-glide/blob/main/java/client/src/main/java/glide/connectors/resources/Platform.java#L26-L30

Yury-Fridlyand commented 1 day ago

Do you use GLIDE as a maven artifact or as a local dependency?

kpramesh2212 commented 22 hours ago

I am using gradle to build

plugins {
    java
    id("org.springframework.boot") version "3.3.4"
    id("io.spring.dependency-management") version "1.1.6"
    id("com.google.cloud.tools.jib") version "3.4.4"
    id("com.avast.gradle.docker-compose") version "0.17.9"
    id("com.google.osdetector") version "1.7.3"
}

group = "com.genesys.sre"
version = "1.0.0-SNAPSHOT"

java {
    toolchain {
        languageVersion = JavaLanguageVersion.of(17)
    }
    sourceCompatibility = JavaVersion.VERSION_17
    sourceCompatibility = JavaVersion.VERSION_17
}

configurations {
    compileOnly {
        extendsFrom(configurations.annotationProcessor.get())
    }
}

dependencies {
    // Spring dependencies
    implementation("org.springframework.boot:spring-boot-starter")
    implementation("org.springframework.boot:spring-boot-starter-web")
    implementation("org.springframework.boot:spring-boot-starter-webflux")
    implementation("org.springframework.boot:spring-boot-starter-actuator")
    implementation("org.springframework.boot:spring-boot-starter-data-redis-reactive")
    implementation("org.springframework.boot:spring-boot-starter-data-redis")

    // Aws dependencies
    implementation(aws.sqs.v1)
    implementation(aws.s3.v1)
    implementation(aws.dynamodb.v1)

    // genesys dependencies
    implementation(genesys.logging.spring)
    implementation(genesys.properties.core)
    implementation(genesys.properties.dynamodb)

    // 3rd party
    implementation(thirdParty.jcabi.manifests)
    implementation(thirdParty.springdoc.openapi.ui)
    implementation(thirdParty.newrelic.api)
    implementation(thirdParty.jedis.client)

    // AWS valkey
    implementation(group="io.valkey", name="valkey-glide", version="1.+", classifier=osdetector.classifier)

    // compile only dependencies
    compileOnly("org.projectlombok:lombok")
    annotationProcessor("org.projectlombok:lombok")

    testImplementation("org.springframework.boot:spring-boot-starter-test")
    testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}

/**
 * Define tasks
 */
tasks.withType<Test> {
    useJUnitPlatform()
}

val bootJar by tasks.existing(Jar::class) {
    archiveVersion.set("")
}

val build by tasks.existing
val jibDockerBuild by tasks.existing
val composeUp by tasks.existing

val imagePrune by tasks.registering(Exec::class) {
    executable("docker")
    args("image", "prune", "--force")
}

val imageBuild by tasks.registering {
    dependsOn(build, jibDockerBuild)
    finalizedBy(imagePrune)
}

val buildComposeUp by tasks.registering {
    dependsOn(imageBuild)
    finalizedBy(composeUp)
}

/**
 *  Define repository
 */
val nexusRepoUrl: String by extra
val nexusUsername: String by extra
val nexusPassword: String by extra

repositories {
    mavenLocal()
    maven {
        url = uri(nexusRepoUrl)
        credentials {
            username = nexusUsername
            password = nexusPassword
        }
    }
}

jib {
    from {
        image = "openjdk:21-slim" // image openjdk:21 LTS is used because glide needs glibc 2.34 which is only available here
    }
    to {
        image = "java-testing-service"
    }
    container {
        mainClass = "com.test.cloud.bootsample.Server"
        creationTime.set("USE_CURRENT_TIMESTAMP")
    }
}
acarbonetto commented 12 hours ago

Would you be able to show dependencies? I'd like to know what the osclassifier is showing as your architecture: https://docs.gradle.org/current/userguide/viewing_debugging_dependencies.html

We are dependent on either kqueue or epoll libraries for netty.io. You can explicitly add those dependencies to the gradle file if it's not being pulled in automatically (depending on architecture).