Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
db_redis: allow deletion of all rows
- Loading branch information
1 parent
a8cc28b
commit bf2ecd4
Showing
1 changed file
with
7 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bf2ecd4
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.
Hello @rdboisvert and @henningw
We bumped into this commit on our deployments because it was causing some issues. In particular it makes the Redis SETs that we use a pseudo-indexes being left over in the Redis DB after a delete operation. The reason is that even for deletes that can be done directly (no/empty "manual keys") the contents of the entry still need to be fetched because the contents are part of the key names used for pseudo-index SETs.
The patch we came up with is exactly the reversal of this commit, so obviously I need to ask about the intentions behind it, since I'm sure you had a good reason to do it :)
bf2ecd4
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.
@rfuchs - apparently the patch was supposed to delete all entries, without a need to match on filters, according to PR #2140. Like the sql
delete from table
withoutwhere
clause.Now I understand that the sets keeping indexes are left. Does it happen for every type of
delete
, even when it has filters (i.e.,where
conditions)? Or only in the case ofdelete all
?bf2ecd4
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.
@miconda it happens on every delete. Our "table definitions" use Redis sets to simulate non-unique database indexes. For example if we have a key
entry:foobar
that is a hash and includes a key "test = blah" (so,HMSET entry:foobar test blah
) and we use the "test" key as a non-unique index, then we'd have a setindex:test:blah
that includesentry:foobar
as member (SADD index:test:blah entry:foobar
). So when deletingentry:foobar
we need to delete that from theindex:test:blah
set (SREM ...
). This requires fetching the contents of theentry:foobar
hash when deleting it. So with this commit, whenentry:foobar
is deleted directly by name, there will be no "manual keys" and so the HMGET is skipped and so the SREM fails.bf2ecd4
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.
If @rdboisvert or @henningw don't have other comments, it can be reverted, or maybe a modparam should added to enable/disable the behaviour of this patch, with default setting to be disabled, as it seems to be the one to have it working.
As you said, it would be good to know what was the reason for this patch, what cases it was supposed to fix. I merged it based on the fact that we have to support the
delete all
operation and seemed to have that purpose.bf2ecd4
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.
I did a review and merged it, if it causes a regression I will revert it. But @rdboisvert can problably best comment on the reasoning for this change, wait a bit for him to reply.
bf2ecd4
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.
We would like to have a delete row function as described in in section 9.2.9 of the Kamailio SIP Server v3.2.0 Development Guide. If I implemented the feature incorrectly then we would appreciate someone fixing this.
Thanks!
bf2ecd4
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.
@rdboisvert it should already do this. Which part was not working for you?
bf2ecd4
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.
From the original issue "Former code always assumed filters would be involved so this change skips the filter matching if no filter is applied."
bf2ecd4
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.
Yes, but did it actually break the delete operation, or was it just a performance optimisation? In either case I can probably come up with an alternative patch that doesn't break the set indexes.
bf2ecd4
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.
@rfuchs I think this sounds more like a bug in the patch, not taking in account your mode of operation. If you can create a patch that fix to the original problem that does not break your operation, this would be great.
bf2ecd4
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.
Sorry for a lack of clarity in my response. What I tried to patch is the bug that it did not delete all rows, or as expressed clearly by @miconda and @henningw, a unfiltered delete of all rows.
bf2ecd4
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.
@rdboisvert I would propose cbc4d1e to fix this. It should allow for full table deletion while also fixing our use case. Could you confirm that this also works for you?
bf2ecd4
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.
Looking at the code I'm not sure I see how it can work but I will build a test environment and let you know. It will probably take me a week to get this together.
bf2ecd4
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.
@rfuchs I was able to test this today and it now works as expected. Thanks for the correction.