Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDK will deadlock for no apparent reason too! #624

Open
balckduck opened this issue Aug 8, 2024 · 3 comments
Open

SDK will deadlock for no apparent reason too! #624

balckduck opened this issue Aug 8, 2024 · 3 comments
Labels
SDK Issue pertains to the SDK itself and not specific to any service

Comments

@balckduck
Copy link

Please see the corresponding code. After listShapes gets the result, all threads should be terminated. However, the line in the picture is still not destroyed. Continuous triggering will cause the server to freeze.
https://imgur.com/a/Ll4F8Q5
iShot_2024-08-08_18 50 46

    <dependencies>
        <dependency>
            <groupId>com.oracle.oci.sdk</groupId>
            <artifactId>oci-java-sdk-common-httpclient-jersey</artifactId>
        </dependency>

        <dependency>
            <groupId>com.oracle.oci.sdk</groupId>
            <artifactId>oci-java-sdk-core</artifactId>
        </dependency>

        <dependency>
            <groupId>com.oracle.oci.sdk</groupId>
            <artifactId>oci-java-sdk-identity</artifactId>
        </dependency>
    </dependencies>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.oracle.oci.sdk</groupId>
                <artifactId>oci-java-sdk-bom</artifactId>
                <version>3.42.0</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    public List<String> listShapes(String region, String domain) {
        OciUtils ociUtils = new OciUtils(Region.valueOf(region), oracleConfig.getComptentId());
        return ociUtils.listShapes(domain);
    }
import com.oracle.bmc.ConfigFileReader;
import com.oracle.bmc.Region;
import com.oracle.bmc.auth.AuthenticationDetailsProvider;
import com.oracle.bmc.auth.ConfigFileAuthenticationDetailsProvider;
import com.oracle.bmc.core.ComputeClient;
import com.oracle.bmc.core.ComputeWaiters;
import com.oracle.bmc.core.VirtualNetworkClient;
import com.oracle.bmc.core.model.*;
import com.oracle.bmc.core.requests.*;
import com.oracle.bmc.core.responses.*;
import com.oracle.bmc.identity.IdentityClient;
import com.oracle.bmc.identity.model.AvailabilityDomain;
import com.oracle.bmc.identity.requests.ListAvailabilityDomainsRequest;
import com.oracle.bmc.identity.responses.ListAvailabilityDomainsResponse;
import com.oracle.bmc.workrequests.WorkRequestClient;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Async;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.*;
import java.util.stream.Collectors;

@Slf4j
public class OciUtils {
    private ComputeClient computeClient;
    
    private WorkRequestClient workRequestClient;

    private ComputeWaiters computeWaiters;

    private IdentityClient identityClient;

    private VirtualNetworkClient virtualNetworkClient;

    private String sshPubKeyFilePath;
    private String compartentId;
    private Region region;

    private static final Logger OCI_MANAGER_LOGGER = LoggerFactory.getLogger("ociManagerAppender");

    public OciUtils(Region region, String compartentId) {
        this.compartentId = compartentId;

        final ConfigFileReader.ConfigFile configFile;
        try {
            configFile = ConfigFileReader.parseDefault();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        final AuthenticationDetailsProvider provider = new ConfigFileAuthenticationDetailsProvider(configFile);

        this.computeClient = ComputeClient.builder().region(region).build(provider);

        this.workRequestClient = WorkRequestClient.builder().build(provider);
        workRequestClient.setRegion(region);

        this.computeWaiters = computeClient.newWaiters(workRequestClient);

        this.identityClient = IdentityClient.builder().build(provider);
        identityClient.setRegion(region);

        this.virtualNetworkClient = VirtualNetworkClient.builder().build(provider);
        virtualNetworkClient.setRegion(region);
    }
    ...
    public List<String> listShapes(String domainName) {
        List<String> shapesList = new ArrayList<>();
        ListShapesRequest listShapesRequest = ListShapesRequest.builder().availabilityDomaindomainName).compartmentId(compartentId).build();
        ListShapesResponse listShapesResponse = computeClient.listShapes(listShapesRequest);
        List<Shape> shapes = listShapesResponse.getItems();
        if (shapes.isEmpty()) {
            throw new IllegalStateException("No available shape was found.");
        }
        for(Shape shape : shapes) {
            shapesList.add(shape.getShape());
        }
        return shapesList;
    }

}

I have tried : #596 ,but this thread just haved.

 ComputeClient.builder().clientConfigurator(builder -> {
                builder.property(JerseyClientProperties.USE_APACHE_CONNECTOR, false);
            }).region(region).build(provider); 

ComputeClient.builder()..clientConfigurator(builder -> {
                    builder.property(JerseyClientProperties.APACHE_IDLE_CONNECTION_MONITOR_THREAD_ENABLED, false);
                    })...
@balckduck
Copy link
Author

computeClient.listShapes(listShapesRequest);--->

package com.oracle.bmc.http.internal;
....
public <R> R listenForResult(CompletionStage<R> stage) throws Throwable {
        Waiter<R> waiter = new Waiter();
        waiter.listenForResult(stage);
        return waiter.waitAndWork();
    }

this code creates jersey-client-async-executor-xxx , but does not kill it after returning the result.Please fix this bug or Tell me how to avoid

@richachugh11
Copy link

Hi , @balckduck , I wanted to check if you're still experiencing the issue with the jersey-client-async-executor threads not being destroyed after calling listShapes. If so, have you found any workarounds, or would you like me to follow up with the SDK team on this?

@balckduck
Copy link
Author

listShapes
@richachugh11 Hi,I haven't found a solution, I hope the SDK team needs to follow up it

@richachugh11 richachugh11 added the SDK Issue pertains to the SDK itself and not specific to any service label Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
SDK Issue pertains to the SDK itself and not specific to any service
Projects
None yet
Development

No branches or pull requests

2 participants