Skip to content

Reset datasource metadata when failed to update it in postIndex and postDelete to force refresh it from the primary index shard.#761

Merged
heemin32 merged 3 commits intoopensearch-project:mainfrom
bzhangam:main
Jun 17, 2025
Merged

Reset datasource metadata when failed to update it in postIndex and postDelete to force refresh it from the primary index shard.#761
heemin32 merged 3 commits intoopensearch-project:mainfrom
bzhangam:main

Conversation

@bzhangam
Copy link
Copy Markdown
Contributor

@bzhangam bzhangam commented Jun 17, 2025

Description

Reset datasource metadata when failed to update it in postIndex and postDelete to force refresh it from the primary index shard. This can help on the case when the update in the primary shard succeeds but the update in the replica shard fails and causing the outdated datasource metadata in the Cache.

Also add more logs to Ip2GeoCachedDao to monitor its behavior.

Related Issues

N/A

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • API changes companion pull request created.
  • Commits are signed per the DCO using --signoff.
  • Public documentation issue/PR created.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@heemin32
Copy link
Copy Markdown
Collaborator

Please add a change log.

@bzhangam bzhangam changed the title Add more logs to Ip2GeoCachedDao to monitor its behavior. Reset datasource metadata when failed to update it in postIndex and postDelete to force refresh it from the primary index shard. Jun 17, 2025

private void clearMetadata() {
log.info("Resetting all datasource metadata to force a refresh from the primary index shard.");
metadata = null;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might need to handle it more gracefully. Current metadata reading shouldn't be breaking due to this code.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider initializing an empty Map instead? Will it cause NPE when getMetadata() is called elsewhere?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modified the getMetadata() to handle the edge case that we can set the metadata as null before getMetadata() returns the non-null metadata. Create a local variable to ensure the returned metadata is non-null.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment to getMetadata() method explaning why we return local variable instead of metadat.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok


private void clearMetadata() {
log.info("Resetting all datasource metadata to force a refresh from the primary index shard.");
metadata = null;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider initializing an empty Map instead? Will it cause NPE when getMetadata() is called elsewhere?

@bzhangam bzhangam force-pushed the main branch 4 times, most recently from c1b11f5 to 5a02aba Compare June 17, 2025 23:03
…ostDelete to force refresh it from the primary index shard.

Signed-off-by: Bo Zhang <bzhangam@amazon.com>
@heemin32 heemin32 merged commit f57507c into opensearch-project:main Jun 17, 2025
16 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Jun 17, 2025
…ostDelete to force refresh it from the primary index shard. (#761)

* Add release notes for 3.1.0

Signed-off-by: Bo Zhang <bzhangam@amazon.com>

* Reset datasource metadata when failed to update it in postIndex and postDelete to force refresh it from the primary index shard.

Signed-off-by: Bo Zhang <bzhangam@amazon.com>

---------

Signed-off-by: Bo Zhang <bzhangam@amazon.com>
(cherry picked from commit f57507c)
heemin32 pushed a commit that referenced this pull request Jun 17, 2025
…ostDelete to force refresh it from the primary index shard. (#761) (#762)

* Add release notes for 3.1.0



* Reset datasource metadata when failed to update it in postIndex and postDelete to force refresh it from the primary index shard.



---------


(cherry picked from commit f57507c)

Signed-off-by: Bo Zhang <bzhangam@amazon.com>
Co-authored-by: Bo Zhang <bzhangam@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants