- Notifications
You must be signed in to change notification settings - Fork 25.7k
ESQL: Fix function registry concurrency issues on constructor #123492
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
ESQL: Fix function registry concurrency issues on constructor #123492
Conversation
| Hi @ivancea, I've created a changelog YAML for you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason for this class to not be "static", and the instance getter to not always return the corresponding registry (snapshot or non-snapshot)?
Could be a fairly simple improvement, avoiding recreating those maps again and again
| ); | ||
| } | ||
| | ||
| protected void buildDataTypesForStringLiteralConversion(FunctionDefinition[]... groupFunctions) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was just moved, as it's now protected, with the "register()" functions
| public class Delay extends UnaryScalarFunction { | ||
| public static final NamedWriteableRegistry.Entry ENTRY = new NamedWriteableRegistry.Entry(Expression.class, "Delay", Delay::new); | ||
| | ||
| @FunctionInfo(returnType = { "boolean" }, description = "Sleeps for a duration for every row. For debug purposes only.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is needed within the buildDataTypesForStringLiteralConversion() -> description() chain.
It won't be used for anything, as this function has no documentation, but I'd rather have it here than changing the registry code for this case
| Pinging @elastic/es-analytical-engine (Team:Analytics) |
| private final Map<String, FunctionDefinition> defs = new LinkedHashMap<>(); | ||
| private final Map<String, String> aliases = new HashMap<>(); | ||
| private final Map<Class<? extends Function>, String> names = new HashMap<>(); | ||
| private final Map<Class<? extends Function>, List<DataType>> dataTypesForStringLiteralConversions = new LinkedHashMap<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
fang-xing-esql left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you @ivancea ! Just to be extra cautious, perhaps add test-releases label, as a call to snapshotRegistry is added.
…c#123492) Fixes elastic#123430 There were 2 problems here: - We were filling a static field (used to auto-cast string literals) within a constructor, which is also called in multiple places - The field was only filled with non-snapshot functions, so snapshot function auto-casting wasn't possible Fixed both bugs by making the field non-static instead, and a fix to use the snapshot registry (if available) in the string casting rule.
…c#123492) Fixes elastic#123430 There were 2 problems here: - We were filling a static field (used to auto-cast string literals) within a constructor, which is also called in multiple places - The field was only filled with non-snapshot functions, so snapshot function auto-casting wasn't possible Fixed both bugs by making the field non-static instead, and a fix to use the snapshot registry (if available) in the string casting rule.
… (#123584) Fixes #123430 There were 2 problems here: - We were filling a static field (used to auto-cast string literals) within a constructor, which is also called in multiple places - The field was only filled with non-snapshot functions, so snapshot function auto-casting wasn't possible Fixed both bugs by making the field non-static instead, and a fix to use the snapshot registry (if available) in the string casting rule.
… (#123583) Fixes #123430 There were 2 problems here: - We were filling a static field (used to auto-cast string literals) within a constructor, which is also called in multiple places - The field was only filled with non-snapshot functions, so snapshot function auto-casting wasn't possible Fixed both bugs by making the field non-static instead, and a fix to use the snapshot registry (if available) in the string casting rule.
Fixes #123430
There were 2 problems here:
Fixed both bugs by making the field non-static instead, and a fix to use the snapshot registry (if available) in the string casting rule.