Skip to content

Conversation

gribnoysup
Copy link
Collaborator

Based on the recent Slack discussion, we're adjusting the logic here a bit:

  • "In progress" indexes are now removed not based on finishing the "create index" op, but on a matching index appearing in regular or rolling indexes lists
  • To work around a corner case where rolling index might never show up when listed (see the notes in the code), we are setting up a timeout that will just remove the in progress rolling index from the list if enough time has passed and fetching the indexes haven't removed it before

…p in real indexes list; cleanup rolling on a timeout
@gribnoysup gribnoysup force-pushed the adjust-in-progress-logic branch from 3c4b6cd to 7496180 Compare October 9, 2024 07:22
indexId: inProgressIndexId,
});
}, POLLING_INTERVAL * 3);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

how long does it normally take for the rolling index to be created? 15s doesn't sound like much

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's a bit hard to wrap the head around (tried to do it here but not sure if I did a good job to be honest), but we don't need to wait for the index to be created before this timeout check kicks in, we are only waiting for the rolling index build to start showing up in the list returned from the backend which corresponds to the index starting to be created on any of the nodes in the cluster, which happens way faster. As soon as it starts showing up in the list returned from the rolling indexes service, it will be removed from the in progress list and this action firing will be a no-op basically

Copy link
Collaborator

Choose a reason for hiding this comment

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

ah I see, thanks!

Copy link
Collaborator

@paula-stacho paula-stacho left a comment

Choose a reason for hiding this comment

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

Looks good! Are tests planned as a follow up?


// See action description for details
if (isRollingIndexBuild) {
setTimeout(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Wondering if it is worth fussing over the timeout and clearing it. Probably not. Super rare to be adding rolling indexes and then there's only one and if the in-progress index disappeared in the meantime then it will just do nothing.

Copy link
Collaborator Author

@gribnoysup gribnoysup Oct 9, 2024

Choose a reason for hiding this comment

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

That was my reasoning for not doing it, but I probably should put this in a comment, it's a rarely used feature and this action is harmless when it fires, so adding more code to store the reference seemed like an overkill

Copy link
Contributor

@lerouxb lerouxb left a comment

Choose a reason for hiding this comment

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

Tests would be nice, but it is probably fine as is too.

@gribnoysup
Copy link
Collaborator Author

@lerouxb @paula-stacho thanks for holding me accountable, will definitely add some tests 😄

@gribnoysup
Copy link
Collaborator Author

Added tests, also drive-by refactored a bit the polling mechanism so that it can be cleaned up when plugin unmounts (writing a functional test for this started to make the tests "hang" until timeout resolves, so was easy to catch the missing cleanup issue)

@gribnoysup gribnoysup merged commit 803a423 into main Oct 10, 2024
28 checks passed
@gribnoysup gribnoysup deleted the adjust-in-progress-logic branch October 10, 2024 11:15
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

Successfully merging this pull request may close these issues.

3 participants