-
Notifications
You must be signed in to change notification settings - Fork 21
Sync dependencies #889
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
Sync dependencies #889
Conversation
0a91368
to
8fdf0a2
Compare
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.
So now I have two places things that I suggest to rename in the schema:
affected_children
->total_children
, see Sync dependencies #889 (comment)redundancy_group
->redundancygroup
in all table and column names, see Sync dependencies #889 (comment)
Both affect web, so that should be coordinated. @nilmerg Are you fine with both of these changes? And if so, shall we just update this PR and Icinga/icinga2#10290 and ping you once done?
@@ -1334,6 +1342,61 @@ CREATE TABLE sla_history_downtime ( | |||
INDEX idx_sla_history_downtime_env_downtime_end (environment_id, downtime_end) COMMENT 'Filter for sla history retention' | |||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC; | |||
|
|||
CREATE TABLE redundancy_group ( |
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'd rename this table to redundancygroup
(and redundancygroup_state
respectively) for two reasons:
- Consistency with other already existing group tables:
icingadb/schema/mysql/schema.sql
Line 229 in a77498d
CREATE TABLE hostgroup ( icingadb/schema/mysql/schema.sql
Line 395 in a77498d
CREATE TABLE servicegroup ( icingadb/schema/mysql/schema.sql
Line 1027 in a77498d
CREATE TABLE usergroup ( - Makes the following special-casing for the table name unnecessary 1:
icingadb/pkg/icingadb/v1/dependency.go
Lines 16 to 19 in 8fdf0a2
// TableName implements [database.TableNamer]. func (r *Redundancygroup) TableName() string { return "redundancy_group" }
Footnotes
-
I presume that's currently necessary due to the inconsistency between Redis (
icinga:redundancygroup
, i.e. no separator inredundancygroup
) and SQL (redundancy_group
, i.e. with a separator), otherwise the Go type could also be namedRedundancyGroup
. ↩
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.
- otherwise the Go type could also be named
RedundancyGroup
. ↩
No, it cannot! The Redis keys are generated dynamically based on the Go type name and that would result in icinga:redundancy:group
which does not exist in Icinga 2.
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.
"Otherwise" as in "if it actually was icinga:redundancy:group
and redundancy_group
"
I initially asked Johannes about this and both agreed to keep it as it is, as the effort for renaming on the web side is not worth it compared to a one-line solution on the Go side, i.e. implementing the |
I'm totally fine with |
Why is it a typo? |
I would consider it a typo if it was was named "hostgruop" or something like that. In that case, naming new things like this for consistency would be truely insane. However, nothing is misspelled here, it's just a question of convention how things are mapped to SQL identifiers.
Neither was I, so I don't know the exact motivation for the current names, but the general pattern seems to be that tables are named like the corresponding Icinga 2 object types converted to lowercase with sub-tables (like group members) being named with some So for me, that looks perfectly fine as well, that is, considered in isolation,
I mean that might be nice, but do you really expect that we'd go through the pain of renaming many existing tables any time soon just for cosmetic reasons? And were would you stop? "checkcommand" and "customvar" aren't English words either. If you insist on the naming for this individual table, I predict that there will be inconsistencies in both the table names ( In case the PHP class names are that important to you and they are indeed directly tied to the table names, I'd consider relaxing the latter and adding a mechanism similar to that (I really didn't expect that to be such a controversial suggestion...) |
8fdf0a2
to
dd191ef
Compare
Indeed. That's where things went wrong. Icinga 2's class is also camel case. For some reason, someone decided against transforming this to snake case.
There is such a mechanism, but that wasn't implemented for the purpose of having a different naming syntax for class names. I'd have to verify whether this mechanism reliably works this way, where as what you have does already reliably work.
I'm actually somewhat annoyed that this even comes up, half a year after I put up the schema suggestion. |
I don't see that there's anything inherently wrong with that choice.
That's simply something I didn't notice when looking at the schema diff as there's no inconsistency within the diff but only with other parts of the same file. So I actually only noticed the inconsistency when seeing that I expected the suggested change to be trivial and I still believe it would be a bad idea to introduce that inconsistency, but it really doesn't feel like that discussion is worth my time. So if you believe this is actually a good idea, I won't stop you, just be prepared for some "told you so" in the future. |
I'll gladly take that risk :) |
2736a9a
to
277bb7b
Compare
277bb7b
to
d5c8af4
Compare
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.
Needs a rebase due to newly introduced merge conflicts. Apart from that, the first three inline comments are probably the most important ones.
tests/object_sync_test.go
Outdated
// TODO: Icinga 2 does send runtime delete event for those two tables, but Icinga DB does not handle them well yet. | ||
// This is because the runtime sync pipeline is set to process upsert/delete events concurrently, which can sometimes | ||
// lead to race conditions where the two events are processed in the wrong order. |
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.
Wait, do you actually still send them?
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.
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.
So what exactly is the effect of the race condition mentioned in this comment? Like if it's too broken to be tested, why should it be fine for production?
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 have already talked about this in person, and I have even created a draft PR on your request #894, so there is no point in repeating all of it here again.
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, we had a discussion about that and I don't want to repeat the full discussion here, just write down the relevant parts why we're doing it that way now. I remember that we agreed that it doesn't make sense to solve that fundamental runtime update limitation in this PR, but did we really say that we want to send the updates nonetheless and ignore the problem? If so, I need a refresher on the reasons (hence my surprise in the initial comment).
From the PR you linked:
It seems that when the
allowParallel
parameter is set to true, theRuntimeUpdates#Sync()
method does not honor the exact order ofdelete
andupsert
events from Redis, resulting in some rare and difficult to manually trigger race conditions where a subsequent runtimedelete
event from Icinga 2 might actually surpass the previously sentupsert
event.
What exactly does "difficult to manually trigger" mean? If the tests can trigger it, why can't it happen to a user? I mean you don't need to trigger it manually for it to be a problem, if some user's automation script could trigger it, it wouldn't be good either.
So what makes it safe enough to ignore the problem here, when for regular state updates, it's worked around by not sending runtime deletes?
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.
but did we really say that we want to send the updates nonetheless and ignore the problem?
Well, not exactly, but I definitely remember you saying to not send a runtime delete event for the regular tables, as you saw that I had already added that code in the Icinga 2 PR, so I only removed that part of the code, but not for the dependency states.
So what makes it safe enough to ignore the problem here, when for regular state updates, it's worked around by not sending runtime deletes?
Safe? I don't think it can be described as safe or not safe, if you delete some hosts or services at runtime, you will have dead state entries in the database until the next reload, that's all, nothing more. By the way, the discussion about sending or not sending delete events is not the right place here, as this PR only receives, but never sends 😅.
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.
Safe? I don't think it can be described as safe or not safe, if you delete some hosts or services at runtime, you will have dead state entries in the database until the next reload, that's all, nothing more.
Well it's not perfect but from my understanding, not sending runtime state deletions is the safer option in the sense that all that can happen is that there are a few obsolete state rows in the database, which won't cause any user-facing problems (there's just a row in the database that will never be used). In contrast, if you send deletions, that problem can happen the other way around as well, so that would be state rows missing in the database which will be visible to the user in Icinga Web.
By the way, the discussion about sending or not sending delete events is not the right place here, as this PR only receives, but never sends 😅.
The fun of multi-project changes. The problem is in this project, the workaround in the other.
44cc118
to
67a1d0c
Compare
66159c7
to
2e806bf
Compare
d6f756f
to
24ca91e
Compare
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.
Fine for me now. Can't be merged immediately for two reasons:
- This is not supposed to become part of the imminent release (https://github.com/Icinga/icingadb/milestone/9).
- Requires coordination with Sync dependencies to Redis icinga2#10290 (see Sync dependencies to Redis icinga2#10290 (comment)), in particular, both releases of Icinga 2 and Icinga DB will be necessary due to the incompatibility in Redis.
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.
Given yesterday's release, the schema upgrade files have to be renamed. Also found a minor problem with the issue with the PostgreSQL schema upgrade (actually forgot to do my standard "does the migration match the full schema" check before :o)
24ca91e
to
2356ffb
Compare
Requires