-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
kv Index.Walk function matches the foreign key by prefix only #20096
Comments
This commit breaks other tests, so it is unclear if the `Influx.Walk` function is intended to match by prefix. If so, it would suggest code documentation clarifying `Index.Walk` is a prefix match. Additionally, a new `Index.WalkExact` function that performs an exact match by the `foreignKey` argument. Closes #20096
Hey @stuartcarnie 👋 Sorry, definitely a gap in the documentation here. This index is currently a non-unique many to one secondary index.
And so the index is structured like so:
Such that we can have multiple entries per foreign key. Meaning we could retrieve the many resources for a particular foreign key in a single range / cursor with a prefix lookup. As this was originally designed around creating a URM by User index. The Walk function visits each key / value pair in the Lines 218 to 229 in 15b9531
I have thought about adding support for a secondary index with a uniqueness constraint. In that scenario walk should find one item. Or perhaps a better name might be |
@GeorgeMac thanks for the reply! I do understand the many to one feature. There is a bug or unexpected behaviour, as described in the issue, that because Walk matches the foreign key using a prefix match, it will find any keys with that prefix. So, back to the dbrp example, if a user adds a mapping to a database named jenkins-aws, the indexes foreign key would be It seems it is expected behaviour as a number of other tests fail when I fix that issue. It seems we might need a WalkExact API to match the foreign key exactly. |
ooooooh I seee 😂 now I am with you. Took me long enough. I added a comment to your draft PR, should be fixable in Walk. |
This commit modifies the behaviour of the indexWalk function to ensure it parses the key parts and matches the foreign key exactly. Closes #20096
This commit adds a new index and migration to the DBRP service for retrieving all database and retention policy mappings for a single organization. This change was required to resolve an invalid assumption of the DBRP service, which relied on a prefix match of the byOrgAndDatabase kv.Index when performing search operations by organization ID only. Closes #20096
This commit modifies the behaviour of the indexWalk function to ensure it parses the key parts and matches the foreign key exactly. Closes #20096
This commit adds a new index and migration to the DBRP service for retrieving all database and retention policy mappings for a single organization. This change was required to resolve an invalid assumption of the DBRP service, which relied on a prefix match of the byOrgAndDatabase kv.Index when performing search operations by organization ID only. Closes #20096
This commit modifies the behaviour of the indexWalk function to ensure it parses the key parts and matches the foreign key exactly. Closes #20096
This commit adds a new index and migration to the DBRP service for retrieving all database and retention policy mappings for a single organization. This change was required to resolve an invalid assumption of the DBRP service, which relied on a prefix match of the byOrgAndDatabase kv.Index when performing search operations by organization ID only. Closes #20096
This commit modifies the behaviour of the indexWalk function to ensure it parses the key parts and matches the foreign key exactly. Closes #20096
This commit adds a new index and migration to the DBRP service for retrieving all database and retention policy mappings for a single organization. This change was required to resolve an invalid assumption of the DBRP service, which relied on a prefix match of the byOrgAndDatabase kv.Index when performing search operations by organization ID only. Closes #20096
This commit modifies the behaviour of the indexWalk function to ensure it parses the key parts and matches the foreign key exactly. Closes #20096
This commit adds a new index and migration to the DBRP service for retrieving all database and retention policy mappings for a single organization. This change was required to resolve an invalid assumption of the DBRP service, which relied on a prefix match of the byOrgAndDatabase kv.Index when performing search operations by organization ID only. Closes #20096
What
When the kv store searches the index, it utilises a forward cursor matching by prefix:
influxdb/kv/index.go
Lines 192 to 193 in 15b9531
The cursor will return all keys that have a matching prefix, in the following loop, including those keys which are longer:
influxdb/kv/index.go
Lines 206 to 208 in 15b9531
For example, if the
foreignKey
ishello
and the index contains the keyshello
,hello-world
andhello-there
, the loop will gather them all.In most cases, the index is typically the result of combining 16-byte IDs, so this is not a problem. However, for
dbrp
, it creates an additionalorgID
+database
foreign key:influxdb/dbrp/service.go
Lines 70 to 76 in b274e15
Creation of DBRPs fail:
Create
bucket1
Create a dbrp mapping for
bucket1
with dbjenkins-aws
, rpnever
:Create
bucket2
Attempt to create a dbrp mapping for
bucket2
with dbjenkins
, rpnever
:Fails with the following error:
The text was updated successfully, but these errors were encountered: