Issue 7627 - When it exists configured matching rule for an indexed a… - #7628
Conversation
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The conditional and the accompanying comment/log message seem inconsistent: the code executes when
!slapi_matchingrule_is_ordering(...) && slapi_matchingrule_can_use_compare_fn(...), but the log says the matching rule is not compatible with the attribute syntax; revisit the condition and log text to ensure they accurately reflect when the configured matching rule is considered compatible/usable. - You always select
official_rules[0]as the fallback ordering matching rule when multiple rules may be present; if multiple matching rules can be configured, consider clarifying or constraining this choice (e.g., explicitly selecting the ordering rule) so the behavior is deterministic and intentional.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The conditional and the accompanying comment/log message seem inconsistent: the code executes when `!slapi_matchingrule_is_ordering(...) && slapi_matchingrule_can_use_compare_fn(...)`, but the log says the matching rule is not compatible with the attribute syntax; revisit the condition and log text to ensure they accurately reflect when the configured matching rule is considered compatible/usable.
- You always select `official_rules[0]` as the fallback ordering matching rule when multiple rules may be present; if multiple matching rules can be configured, consider clarifying or constraining this choice (e.g., explicitly selecting the ordering rule) so the behavior is deterministic and intentional.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
Congratulations! One of the builds has completed. 🍾 You can install the built RPMs by following these steps:
Please note that the RPMs should be used only in a testing environment. |
e3eb979 to
2b5837b
Compare
50e7aee to
f77a185
Compare
| return (mrl->mr_entry->mr_name && | ||
| PL_strcasestr(mrl->mr_entry->mr_name, "ordering")); | ||
| } | ||
| } |
There was a problem hiding this comment.
I think we're missing a return 0; after the loop. If the name/OID isn't registered we fall off the end and the caller gets an undefined value. The old inline loop was protected by is_compat, but this one is called directly, so a typo in nsMatchingRule (or a collation language tag like fr) would reach it. Since it's exported in slapi-plugin.h, maybe a NULL guard on the argument as well?
| } | ||
|
|
||
| if (!do_continue && | ||
| slapi_matchingrule_is_ordering_only(attrValue->bv_val) && |
There was a problem hiding this comment.
I believe this also catches collation rules. They're registered as caseIgnoreOrderingMatch-<lang>, so the "ordering" test passes, plugin_mr_find() returns NULL (the collation plugin has no plg_mr_names), and do_continue = 1 skips the RULE path. If I'm reading it right, nsMatchingRule: 2.16.840.1.113730.3.3.2.11.1 on cn/sn/uid would stop creating the index after upgrade. What do you think about only taking this branch when plugin_mr_find() returns a plugin with plg_mr_compare, and leaving do_continue at 0 otherwise so the RULE path still runs?
There was a problem hiding this comment.
Good catch. collation rule can not be used for comparison. It it is a valid index rule. The patch prevents to use it as an index. I need to rework the patch.
I agree the problem here is that do_continue is set to 1. Now the collation plugin is not a valid comparison and the patch should prevent to use it via mr_ordering_plugin.
| * if there are multiple ordering matching rules for the same attribute, | ||
| * use the last one that is found. | ||
| */ | ||
| mr_ordering_plugin = plugin_mr_find(attrValue->bv_val); |
There was a problem hiding this comment.
Small one: mr_ordering_plugin is overwritten on every value, including with NULL when the lookup fails. With [integerOrderingMatch, <collation OID>] on one index we'd end up with neither a comparator nor a RULE index. Maybe assign only on success?
There was a problem hiding this comment.
I think the an attribute should have only one comparison (ordering) nsMatchingRule. If multiple ordering are set, it looks to me an invalid config and taking the last value is acceptable.
| a->ai_key_cmp_fn = NULL; | ||
| } | ||
| } | ||
| if (mr_ordering_plugin && (a->ai_sattr.a_mr_ord_plugin == NULL)) { |
There was a problem hiding this comment.
Two thoughts here.
This block doesn't check need_compare_fn, so with a compatible plus an incompatible ordering rule on the same index the incompatible one wins (uidNumber with integerOrderingMatch and caseIgnoreOrderingMatch would get a string comparator). Skipping the block when we already have a comparator would probably be enough.
Also, this is the upgrade case from my earlier comment and IMO it deserves a WARNING with a reindex hint rather than INFO. An existing lexicographic index gets opened with int_compare and equality lookups miss keys until db2index.
One more thing I noticed: for string syntax the keys aren't integer-normalized, so =007 and =7 compare equal and merge into one key, and (uid=7) would return the 007 entry because indexed equality skips the filter test. Would it make sense to keep the can_use_compare_fn gate and limit this to what parentid needs?
But I don't have a strong opinion here and maybe it's something we do intentionally.
There was a problem hiding this comment.
Right with multiple nsMatchingRule values we can have need_compare_fn and mr_ordering_plugin both set. I need to rework the patch for multiple ordering nsMatchingRule.
The upgrade I was thinking of heathcheck being responsible to report incoherent index ordering versus ordering config.
A string syntax attribute should not normalize '007' into '7'. So if the search filter is '(uid=007)' the equality index should not return the key '=7'. How did you get this behavior ?
| if disk_ordering == IndexOrdering.LEXICOGRAPHIC: | ||
| log.info(" %s - config: %s, disk: %s", | ||
| index_name, "integer", disk_ordering.value) | ||
| log.warning(" %s - MISMATCH: config has integerOrderingMatch but disk is lexicographic (suggest redindex)", index_name) |
There was a problem hiding this comment.
| log.warning(" %s - MISMATCH: config has integerOrderingMatch but disk is lexicographic (suggest redindex)", index_name) | |
| log.warning(" %s - MISMATCH: config has integerOrderingMatch but disk is lexicographic (suggest reindex)", index_name) |
| index_name, "integer", disk_ordering.value) | ||
| log.info(" %s - could not determine disk ordering, skipping", index_name) | ||
| continue | ||
| if disk_ordering == IndexOrdering.LEXICOGRAPHIC: |
There was a problem hiding this comment.
Should we also set all_ok = False here when reporting the MISMATCH?
| config_has_int_order = _has_integer_ordering_match(dse_ldif, backend, index_name) | ||
| if config_has_int_order: | ||
| # Check disk ordering | ||
| disk_ordering = _check_disk_ordering(db_dir, backend, index_name, dbscan_path, is_mdb, log) |
There was a problem hiding this comment.
_check_disk_ordering() only looks at the first 100 dbscan lines. For attributes with a sub index those are all */+ keys, so it returns UNKNOWN and we silently skip cn/uid on real deployments, IIUC.
Not new code, but now that it runs on user indexes it probably needs to count = keys instead of raw lines...
indexed attribute it should be used if the schema does not define one
Bug description:
An indexed attribute can define a specific Ordering matching rule using nsMatchingRule.
If the ordering matching rule is compatible with the syntax of the attribute
then the index uses the one defined in nsMatchingRule.
If the ordering matching rule is not compatible with the syntax of the attribute
then the index ignores nsMatchingRule setting and falls back to the default
matching rule that is lexicographic order.
A problem occurs if a old attribute syntax, incompatible with nsMatchingRule,
is propated throught the replication of the schema
Fix description:
At startup, in the case the attribute syntax does not define an ordering matching rule
if nsMatchingRule contains an ordering MR compatible with the syntax of the attribute
then it uses this matching rule instead of the default MR.
if nsMatchingRule contains an ordering MR not compatible with the syntax of the attribute
and it exists plugin supporting this implementing this MR then it uses it.
extend the index-check command to check ordering mismatch
(config vs disk) for all indexes/backends
fixes: 389ds#7627
Reviewed by: Simon Pichugin (Many Thanks !!!)
indexed attribute it should be used if the schema does not define one
Bug description:
An indexed attribute can define a specific Ordering matching rule using nsMatchingRule.
If the ordering matching rule is compatible with the syntax of the attribute
then the index uses the one defined in nsMatchingRule.
If the ordering matching rule is not compatible with the syntax of the attribute
then the index ignores nsMatchingRule setting and falls back to the default
matching rule that is lexicographic order.
A problem occurs if a old attribute syntax, incompatible with nsMatchingRule,
is propated throught the replication of the schema
Fix description:
At startup, in the case the attribute syntax does not define an ordering matching rule
if nsMatchingRule contains an ordering MR compatible with the syntax of the attribute
then it uses this matching rule instead of the default MR.
if nsMatchingRule contains an ordering MR not compatible with the syntax of the attribute
and it exists plugin supporting this implementing this MR then it uses it.
extend the index-check command to check ordering mismatch
(config vs disk) for all indexes/backends
fixes: #7627
Reviewed by: Simon Pichugin (Many Thanks !!!)
indexed attribute it should be used if the schema does not define one
Bug description:
An indexed attribute can define a specific Ordering matching rule using nsMatchingRule.
If the ordering matching rule is compatible with the syntax of the attribute
then the index uses the one defined in nsMatchingRule.
If the ordering matching rule is not compatible with the syntax of the attribute
then the index ignores nsMatchingRule setting and falls back to the default
matching rule that is lexicographic order.
A problem occurs if a old attribute syntax, incompatible with nsMatchingRule,
is propated throught the replication of the schema
Fix description:
At startup, in the case the attribute syntax does not define an ordering matching rule
if nsMatchingRule contains an ordering MR compatible with the syntax of the attribute
then it uses this matching rule instead of the default MR.
if nsMatchingRule contains an ordering MR not compatible with the syntax of the attribute
and it exists plugin supporting this implementing this MR then it uses it.
extend the index-check command to check ordering mismatch
(config vs disk) for all indexes/backends
fixes: #7627
Reviewed by: Simon Pichugin (Many Thanks !!!)
indexed attribute it should be used if the schema does not define one
Bug description:
An indexed attribute can define a specific Ordering matching rule using nsMatchingRule.
If the ordering matching rule is compatible with the syntax of the attribute
then the index uses the one defined in nsMatchingRule.
If the ordering matching rule is not compatible with the syntax of the attribute
then the index ignores nsMatchingRule setting and falls back to the default
matching rule that is lexicographic order.
A problem occurs if a old attribute syntax, incompatible with nsMatchingRule,
is propated throught the replication of the schema
Fix description:
At startup, in the case the attribute syntax does not define an ordering matching rule
if nsMatchingRule contains an ordering MR compatible with the syntax of the attribute
then it uses this matching rule instead of the default MR.
if nsMatchingRule contains an ordering MR not compatible with the syntax of the attribute
and it exists plugin supporting this implementing this MR then it uses it.
extend the index-check command to check ordering mismatch
(config vs disk) for all indexes/backends
fixes: #7627
Reviewed by: Simon Pichugin (Many Thanks !!!)
indexed attribute it should be used if the schema does not define one
Bug description:
An indexed attribute can define a specific Ordering matching rule using nsMatchingRule.
If the ordering matching rule is compatible with the syntax of the attribute
then the index uses the one defined in nsMatchingRule.
If the ordering matching rule is not compatible with the syntax of the attribute
then the index ignores nsMatchingRule setting and falls back to the default
matching rule that is lexicographic order.
A problem occurs if a old attribute syntax, incompatible with nsMatchingRule,
is propated throught the replication of the schema
Fix description:
At startup, in the case the attribute syntax does not define an ordering matching rule
if nsMatchingRule contains an ordering MR compatible with the syntax of the attribute
then it uses this matching rule instead of the default MR.
if nsMatchingRule contains an ordering MR not compatible with the syntax of the attribute
and it exists plugin supporting this implementing this MR then it uses it.
extend the index-check command to check ordering mismatch
(config vs disk) for all indexes/backends
fixes: #7627
Reviewed by: Simon Pichugin (Many Thanks !!!)
indexed attribute it should be used if the schema does not define one
Bug description:
An indexed attribute can define a specific Ordering matching rule using nsMatchingRule.
If the ordering matching rule is compatible with the syntax of the attribute
then the index uses the one defined in nsMatchingRule.
If the ordering matching rule is not compatible with the syntax of the attribute
then the index ignores nsMatchingRule setting and falls back to the default
matching rule that is lexicographic order.
A problem occurs if a old attribute syntax, incompatible with nsMatchingRule,
is propated throught the replication of the schema
Fix description:
At startup, in the case the attribute syntax does not define an ordering matching rule
if nsMatchingRule contains an ordering MR compatible with the syntax of the attribute
then it uses this matching rule instead of the default MR.
if nsMatchingRule contains an ordering MR not compatible with the syntax of the attribute
and it exists plugin supporting this implementing this MR then it uses it.
extend the index-check command to check ordering mismatch
(config vs disk) for all indexes/backends
fixes: #7627
Reviewed by: Simon Pichugin (Many Thanks !!!)
indexed attribute it should be used if the schema does not define one
Bug description:
An indexed attribute can define a specific Ordering matching rule using nsMatchingRule.
If the ordering matching rule is compatible with the syntax of the attribute
then the index uses the one defined in nsMatchingRule.
If the ordering matching rule is not compatible with the syntax of the attribute
then the index ignores nsMatchingRule setting and falls back to the default
matching rule that is lexicographic order.
A problem occurs if a old attribute syntax, incompatible with nsMatchingRule,
is propated throught the replication of the schema
Fix description:
At startup, in the case the attribute syntax does not define an ordering matching rule
if nsMatchingRule contains an ordering MR compatible with the syntax of the attribute
then it uses this matching rule instead of the default MR.
if nsMatchingRule contains an ordering MR not compatible with the syntax of the attribute
and it exists plugin supporting this implementing this MR then it uses it.
extend the index-check command to check ordering mismatch
(config vs disk) for all indexes/backends
fixes: #7627
Reviewed by: Simon Pichugin (Many Thanks !!!)
indexed attribute it should be used if the schema does not define one
Bug description:
An indexed attribute can define a specific Ordering matching rule using nsMatchingRule.
If the ordering matching rule is compatible with the syntax of the attribute
then the index uses the one defined in nsMatchingRule.
If the ordering matching rule is not compatible with the syntax of the attribute
then the index ignores nsMatchingRule setting and falls back to the default
matching rule that is lexicographic order.
A problem occurs if a old attribute syntax, incompatible with nsMatchingRule,
is propated throught the replication of the schema
Fix description:
At startup, in the case the attribute syntax does not define an ordering matching rule
if nsMatchingRule contains an ordering MR compatible with the syntax of the attribute
then it uses this matching rule instead of the default MR.
if nsMatchingRule contains an ordering MR not compatible with the syntax of the attribute
and it exists plugin supporting this implementing this MR then it uses it.
extend the index-check command to check ordering mismatch
(config vs disk) for all indexes/backends
fixes: #7627
Reviewed by: Simon Pichugin (Many Thanks !!!)
…ttribute it should be used if the schema does not define one
Bug description:
An attribute is defined in the schema. The matching rule is optional in the schema
so the definition falls back to the default matching rule that is lexicographic order.
Fix description:
At startup when binding the attribute their schema definitions
if no matching rule is define and it existed a configured matching rule
the default matching rule should be the configured one
fixes: #7627
fixes: #7518
Reviewed by:
Summary by Sourcery
Honor configured ordering matching rules when schema definitions lack compatible rules and improve detection and coverage of index ordering behavior.
Bug Fixes:
Enhancements:
Tests: