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

[BUG] Memory usage exceed limit and java.lang.IllegalStateException: resource is not enough to run the query, quit. #611

Closed
microtimber opened this issue May 16, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@microtimber
Copy link

microtimber commented May 16, 2022

Describe the bug
Memory used up after many sql requests was executed.

To Reproduce
Steps to reproduce the behavior:

  1. start a new container from the opensearch docker image v1.2.3;
  2. use JMeter to perform a lot of sql requests;
  3. See error in the container console log: "Memory usage:7301801288 exceed limit:7301444403" and "java.lang.IllegalStateException: resource is not enough to run the query, quit."

Expected behavior
Memory should be GCed.

Plugins

analysis-hanlp
opensearch-asynchronous-search
opensearch-job-scheduler
opensearch-performance-analyzer
opensearch-sql
opensearch-alerting
opensearch-cross-cluster-replication
opensearch-knn
opensearch-reports-scheduler
opensearch-anomaly-detection
opensearch-index-management
opensearch-observability opensearch-security

Host/Environment:

  • OS: CentOS 7
  • Version: opensearch docker image v1.2.3

Additional context
MAT analyses the memory dump and shows the leak suspect:

The class org.springframework.beans.factory.support.DefaultListableBeanFactory, loaded by java.net.FactoryURLClassLoader @ 0x605cb7520, occupies 5,631,327,632 (91.39%) bytes. The memory is accumulated in one instance of java.util.concurrent.ConcurrentHashMap$Node[], loaded by , which occupies 5,631,322,800 (91.39%) bytes.

And we find that sql legacy plugin creates an AnnotationConfigApplicationContext instance for every sql request in the class file RestSQLQueryAction:

  private SQLService createSQLService(NodeClient client) {
    return doPrivileged(() -> {
      AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
      context.registerBean(ClusterService.class, () -> clusterService);
      context.registerBean(NodeClient.class, () -> client);
      context.registerBean(Settings.class, () -> pluginSettings);
      context.register(ElasticsearchSQLPluginConfig.class);
      context.register(SQLServiceConfig.class);
      context.refresh();
      return context.getBean(SQLService.class);
    });
  }
@microtimber microtimber added bug Something isn't working untriaged labels May 16, 2022
@dai-chen
Copy link
Collaborator

dai-chen commented Aug 9, 2022

@microtimber Thanks for reporting the issue! Will investigate.
The error message you saw comes from our own circuit breaker as intended. But we may need to double check if any memory leak.

@dai-chen
Copy link
Collaborator

This is already fixed in #822. Thanks!

@dai-chen dai-chen moved this to Done in SQL Engineering Dec 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
No open projects
Status: Done
Development

No branches or pull requests

3 participants