notifications icon indicating copy to clipboard operation
notifications copied to clipboard

Refresh system index immediately when create/update/delete notification configs

Open gaobinlong opened this issue 2 years ago • 2 comments

Is your feature request related to a problem?

When create, update and delete notification configs, currently we do not refresh the system index .opensearch-notification-config in this plugin, so the operations cannot be seen immediately util the automatic refresh happens within the index(the default value of refresh_interval is 1s, which means the operations can be seen after 1s at most).

However, we can refresh the index when doing those operations to make the result visible immediately, one benefit is that users may use the notifications API to create/update/delete configs so they need to see the realtime result, another benefit is that in the integration test methods, we do not need to use Thread.sleep() or waitFor to wait some time to get the result after creating/updating/deleting the notification configs.

Too many refresh may cause problems, but in our case, creating/updating/deleting operations don't happen frequently, so it's not a problem that we refresh the system index for every operation.

What solution would you like? Add refresh=true parameter when calling the index/update/delete API against the system index .opensearch-notification-config.

Here is the index operation code which needs to be changed: https://github.com/opensearch-project/notifications/blob/0a7a5f99e71248cce9d5c15b0b99f9f270261d21/notifications/notifications/src/main/kotlin/org/opensearch/notifications/index/NotificationConfigIndex.kt#L185 , adding .setRefreshPolicy(RefreshPolicy.IMMEDIATE) maybe enough.

gaobinlong avatar Oct 13 '23 02:10 gaobinlong

After changing this, we'd better modify our unit test to remove refreshAllIndices and Thread.sleep

zhichao-aws avatar Oct 13 '23 03:10 zhichao-aws

I'll work on this

nishantb1 avatar Oct 13 '23 04:10 nishantb1