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

Empty category issue #3391

Open
Nuranto opened this issue Sep 19, 2024 · 2 comments
Open

Empty category issue #3391

Nuranto opened this issue Sep 19, 2024 · 2 comments

Comments

@Nuranto
Copy link
Contributor

Nuranto commented Sep 19, 2024

Magento Version : 2.4.7-p2

ElasticSuite Version : 2.11.8.3

Steps to reproduce

  1. Simulate a query exception in src/module-elasticsuite-core/Search/Adapter/Elasticsuite/Adapter.php : add line $searchResponse = []; before return
  2. Load a category page

Expected result

  1. An error page is diplayed (or non-cacheable empty category page)

Actual result

  1. Cacheable empty category

Additional informations

The case where an exception is thrown and $searchResponse gets empty is very very rare in our case. But when it happens, it may be put in cache by Varnish, which causes empty categories displayed to customers for hours...

Also the exception logging method ($this->logger->error($e->getMessage());) is not very handy. A specific logfile and usage of $this->logger->critical($e); would be more powerfull for debugging.

Note : jfyi there's a similar issue on Adobe's adapter : magento/magento2#38284

@romainruaud
Copy link
Collaborator

Hi @Nuranto

I think that, as a first step, we'll add something onto this line : https://github.com/Smile-SA/elasticsuite/blob/2.11.x/src/module-elasticsuite-core/Search/Adapter/Elasticsuite/Adapter.php#L84

Most probably, we'll add to the HTTP context some variable, like "X-Search-Failure". This should allow you to set these pages as not-cacheable with a plugin on the HTTP context later on.

Would this fit ?

Regards

@Nuranto
Copy link
Contributor Author

Nuranto commented Sep 30, 2024

Hi @romainruaud ,

Thank you for your answer,

We already fixed the caching issue by throwing the exception when it happens. We prefer a temporary error on our category page than a long-term empty category. Your solution would work too, but I think a more "out of the box" solution would be better.

And it works, we just got alerted that the issue occured again. Here is the exception that causes the issue :

{
  "error": {
    "root_cause": [
      {
        "type": "query_shard_exception",
        "reason": "failed to create query: empty String",
        "index_uuid": "---",
        "index": "magento2_default_catalog_product_20240929_232103"
      }
    ],
    "type": "search_phase_execution_exception",
    "reason": "all shards failed",
    "phase": "query",
    "grouped": true,
    "failed_shards": [
      {
        "shard": 0,
        "index": "magento2_default_catalog_product_20240929_232103",
        "node": "---",
        "reason": {
          "type": "query_shard_exception",
          "reason": "failed to create query: empty String",
          "index_uuid": "---",
          "index": "magento2_default_catalog_product_20240929_232103",
          "caused_by": {
            "type": "number_format_exception",
            "reason": "empty String"
          }
        }
      }
    ]
  },
  "status": 400
}

After cleaning magento cache (bin/magento c:f), the error disappeared.

I don't know where to search here, any ideas on how to debug ? How a query can be empty, and why purging cache solves that ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants