Describe the issue: We’re experiencing an intermittent problem with the Refresh functionality in OpenSearch Dashboards’ Discover tab.
Steps to Reproduce:
Start a job to insert data into a data index
Navigate to the Discover tab and select the index
Initially, no results are displayed
Click Refresh - data loads correctly on first attempt
Subsequent Refresh clicks fail to fetch updated data
Current Behavior:
After the initial successful refresh, the refresh button stops triggering data fetch requests to retrieve the latest information. This occurs consistently, with only rare instances where subsequent refreshes work as expected.
Additional Context:
We’ve searched for documentation on this issue but found no relevant results
Our OpenSearch Dashboards implementation is largely unmodified - we’ve only made minor platform-specific adjustments that don’t affect core functionality
The issue appears to be intermittent rather than consistent
Request:
Could you please provide guidance on troubleshooting this refresh functionality issue?
@LuisBeltran I’ve tested 2.19.3 OpenSearch Dashboards with security security-auditlog- index.
I’ve initiated multiple failed logins, and every time when I hit Refersh button in the Discovery, data are refreshed successfully in the view.
My OpenSearch Dashboards connects only to one single OpenSearch in the 2 node cluster.
How many OpenSearch nodes are configured in your opensearch_dashboards.yml?
Do you see any errors in OpenSearch logs?
Actually, there is something important I must mention. So I was doing the upgrade from 2.11 to 2.18 and I ended up removing the management overview plugin as we didn’t want that section of the UI (where you can inject AWS data sources), the problem is that in order to remove that plugin I remember I had to delete some of the data source management plugin references as well. Perhaps do you think this could be impacting this refresh functionality?
I’d greatly appreciate if you could explain the following plugins: datasource, datesourcemanagement, managementoverview.
Those are the three plugins I modified, and I did so thinking the datasources were mostly referring to the possible external sources loaded in the management overview section, but we came to find out that one of the buttons in the Discover tab to refresh the selectors (indexes) was seemingly linked to the data source plugin.
This issue seems to be intermittent from our end. There are times where the button works normally, I will keep investigating but if you know a way of debugging this let me know please.
Our changes do not seem to matter. We barely touched the Discover plugin; we just made some CSS adjustments. In fact, I reverted those CSS changes and the button still doesn’t work. The major changes we really did was the disablement of those plugins as we did not want to deal with external data sources.
Having said that, I found a workaround, which is basically to click on the Search bar from the same query bar and click the refresh button again and it starts working normally. I debugged a bit more to see if maybe the button was getting out of focus when clicking, or maybe there was some event propagation that was causing the button not to fetch anything and even tried seeing the event listeners linked to the button in case for some reason it changed but I see no issues at all, so the issue seems a bit obscure.
By the way we do not have the OpenSearch security plugin, in case that matters.
I found the root cause of the refresh button issue. The refresh button has an event listener function called defaultOnQuerySubmit located in src/plugins/data/public/ui/search_bar/create_search_bar.tsx.
After debugging, I discovered that the isUpdate variable stays true if your query or time filter don’t change between clicks. When isUpdate is true, it doesn’t call the onQuerySubmit function, which is what actually fetches the new results (you can see this function in src/plugins/discover/application/view_components/canvas/index.tsx).
This logic seems weird because the refresh button shouldn’t depend solely on whether the query or time changes - it should fetch the current results at that point in time. In our product, we continuously process and fill the index with records in batches, so we use the refresh button to see which records and how many are available at any given moment.
I might have a wrong understanding of the code, or maybe OpenSearch Dashboards wasn’t designed for our use case. Is this the intended behavior? Was it designed this way for performance reasons rather than real-time data scenarios? Has this behavior changed in newer versions? We don’t mind changing the code ourselves if needed, but I’d like clarification on how to move forward.
I found the exact issue. The problem is with the isEqual method from lodash that does deep comparison between the query objects.
I debugged why the isUpdate variable was becoming true even when the queries and date ranges looked the same. By testing each condition individually, I found it was the query object comparison failing.
Turns out the payload.query object has a dataset property set to undefined, while currentQuery doesn’t have this property at all. So, you get:
This makes isEqual() return false, so isUpdate becomes true and it doesn’t refetch.
The weird part is the inconsistent behavior. The first refresh click works and fetches data even though isUpdate is true. Subsequent clicks don’t work because isUpdate stays true. But after clicking the search bar, it works again because now payload.query doesn’t have the dataset property anymore:
I’m confused about why the first click works despite isUpdate being true, since the code suggests it should only refetch when isUpdate is false. Maybe there’s another mechanism I’m missing.
The dataset property seems to get added and removed inconsistently. Not sure if this is intended behavior or if there’s a bug in how the dataset functionality works. Can you clarify if this is expected?