Commit graph

1972 commits

Author SHA1 Message Date
Julian Brost
b82a4c3285 Make overdue sync HA-aware
Syncing the overdue flag to the host_state and service_state tables was
not HA-aware and assumed to have a consistent copy of all serivces/hosts
with overdue set stored in Redis. However, if a second Icinga DB
instance was active, this set might have become outdated.

This commit fixes this by making the overdue sync HA-aware, i.e. pausing
it if the current instance is inactive. Additionally, it fetches the set
of overdue services from MySQL and syncs it back to Redis when becoming
active.
2021-02-17 12:21:52 +01:00
Noah Hilverling
3df4b95de7
Merge pull request #232 from Icinga/bugfix/multiple-ha-takeovers
HA: Prevent multiple instances from taking over at the same time
2021-02-17 12:17:18 +01:00
Julian Brost
9d23bbec2e HA: only read new hearbeats from Redis
Selecting any heartbeat from the last 15 seconds from Redis makes little
sense, just wait for new ones. If Icinga 2 just stopped, there is no
point in becoming active for just a few seconds, otherwise the next
heartbeat will arrive in a second anyways.
2021-02-17 11:01:41 +01:00
Julian Brost
4374eec849 HA: use separate MySQL connection
A dedicated MySQL connection for HA heartbeats to help get them done
reliably even if the normal connection pool is under heavy use.
2021-02-17 11:01:39 +01:00
Julian Brost
29f82647c0 HA: use separate Redis connection
A dedidcated Redis connections helps to receive heartbeats from Icinga 2
even if there is a high load on the normal Redis connection pool.
2021-02-17 11:00:13 +01:00
Julian Brost
fc1c9c8134 Improve log messages related to HA takeover/handover 2021-02-17 11:00:13 +01:00
Julian Brost
2957f32c77 HA: prefer new Icinga 2 heartbeat over forced update 2021-02-17 11:00:13 +01:00
Julian Brost
3f6a6534c1 Detect and warn about slow HA heartbeat SQL transactions 2021-02-17 11:00:13 +01:00
Julian Brost
335ff91fb7 Remove previous rows from icingadb_instance table
To prevent this table from growing indefinitely, this now removes timed
out rows for the same environment_id and endpoint_id.
2021-02-17 11:00:13 +01:00
Julian Brost
f3d21d5a95 Add test for HA RegisterStateChangeListener 2021-02-17 11:00:13 +01:00
Julian Brost
c6f8360052 Rewrite HA logic to use SQL serializable transactions
The old logic didn't properly handle multiple nodes trying to become
active at the same time.
2021-02-17 11:00:13 +01:00
Julian Brost
b09e18825a Add test demonstrating that multiple instances may take over at the same time
Example output:

time="2020-12-21T09:22:29+01:00" level=info msg="Taking over." UUID=bbc39673-7281-5064-a71e-91c25dbc6643 context=HA-Testing
time="2020-12-21T09:22:29+01:00" level=info msg="Taking over." UUID=dddedcc5-507e-56d6-adb4-9c6451f6aeb7 context=HA-Testing
time="2020-12-21T09:22:29+01:00" level=info msg="Changing HA state to active"
time="2020-12-21T09:22:29+01:00" level=info msg="Changing HA state to active"
    ha_test.go:291:
        	Error Trace:	ha_test.go:291
        	Error:      	Not equal:
        	            	expected: 1
        	            	actual  : 2
        	Test:       	TestHA_ConcurrentCheckResponsibility
        	Messages:   	exactly 1 instance must be active after checkResponsibility() but 2 are active
--- FAIL: TestHA_ConcurrentCheckResponsibility (0.02s)
2021-02-17 11:00:13 +01:00
Julian Brost
acc10490e9 Provide generic HA state change notifications
The HA code generated special notifications for the configsync package.
This commit instead provides a generic notification channel in the HA
package and moves all the special handling to the configsync package
which now generates its special notifications based on the generic ones.
2021-02-17 11:00:13 +01:00
Julian Brost
05cc307112 Don't retry individual SQL transaction commands
If anything in a transaction fails, the transaction should be retried as
a whole, just retrying some individual command makes no sense and breaks
transaction semantics. For example, if a COMMIT fails in MySQL, it
automatically rolls back the transaction and if you issue another
COMMIT, you just commit an empty transaction.

Remove the test case for commit as is basically tested that it showed
the broken behavior described above.
2021-02-17 11:00:13 +01:00
Noah Hilverling
9570975494
Merge pull request #245 from Icinga/feature/add-mysql-unix-domain-socket-228
Add support mysql unix domain socket
2021-02-17 10:47:54 +01:00
Noah Hilverling
6f94d461c6
Merge pull request #251 from Icinga/feature/hscan-instead-of-hkeys
Config Sync: Iterate over config using cursor (replace HKEYS with HSCAN)
2021-02-16 16:57:08 +01:00
Noah Hilverling
5391f6991f
Merge pull request #255 from Icinga/bugfix/error-1064-209
ChunkRows(): ensure to never get an empty chunk
2021-02-16 16:13:56 +01:00
Alexander Aleksandrovič Klimov
2927fd735d
Merge pull request #256 from Icinga/feature/chunk-rows-int-arithmetic
ChunkRows: replace float with int arithmetic
2021-02-09 19:03:45 +01:00
Julian Brost
b94e8233e4 ChunkRows: replace float with int arithmetic 2021-02-09 18:27:13 +01:00
Alexander A. Klimov
50010c6024 ChunkRows(): ensure to never get an empty chunk
refs #209
2021-02-09 18:06:51 +01:00
Julian Brost
fc70dae931 configsync: fetch checksums using HSCAN if available, otherwise reuse config
The previous commit replaced HKEYS with HSCAN, which in addition the the
keys, also returns the values from Redis. With this commit, instead of
the config values the checksum is fetched, or if no checksum is
available, the value is reused.
2021-02-04 16:13:46 +01:00
Alexander Aleksandrovič Klimov
62f6c80928
Schema: correct comments in flapping_history, acknowledgement_history
... describing the id column.
2021-02-02 18:03:50 +01:00
Julian Brost
9eaed64e76 configsync: use HSCAN instead of HKEYS
Redis documentation states that it is preferable to use *SCAN instead of
*KEYS (https://redis.io/commands/keys):

  Warning: consider KEYS as a command that should only be used in
  production environments with extreme care. It may ruin performance
  when it is executed against large databases. This command is intended
  for debugging and special operations, such as changing your keyspace
  layout.  Don't use KEYS in your regular application code. If you're
  looking for a way to find keys in a subset of your keyspace, consider
  using SCAN or sets.

While the documentation is for the KEYS command and not HKEYS, the same
warning should apply here to as the hashes we are iterating over can get
quite large. Therefore use the HSCAN command that exists as an
alternative.
2021-02-02 16:59:35 +01:00
Yonas Habteab
aa7a15e75d Add support mysql unix domain socket 2021-01-26 11:35:11 +01:00
Noah Hilverling
6dd577ea89
Merge pull request #246 from Icinga/dependabot/go_modules/github.com/google/uuid-1.2.0
Bump github.com/google/uuid from 1.1.5 to 1.2.0
2021-01-25 16:05:17 +01:00
dependabot[bot]
00ccd10f9e
Bump github.com/google/uuid from 1.1.5 to 1.2.0
Bumps [github.com/google/uuid](https://github.com/google/uuid) from 1.1.5 to 1.2.0.
- [Release notes](https://github.com/google/uuid/releases)
- [Commits](https://github.com/google/uuid/compare/v1.1.5...v1.2.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-01-25 10:02:22 +00:00
Noah Hilverling
88deca05b7
Merge pull request #244 from Icinga/dependabot/go_modules/github.com/google/uuid-1.1.5
Bump github.com/google/uuid from 1.1.4 to 1.1.5
2021-01-18 13:18:47 +01:00
dependabot[bot]
dee409a7f7
Bump github.com/google/uuid from 1.1.4 to 1.1.5
Bumps [github.com/google/uuid](https://github.com/google/uuid) from 1.1.4 to 1.1.5.
- [Release notes](https://github.com/google/uuid/releases)
- [Commits](https://github.com/google/uuid/compare/v1.1.4...v1.1.5)

Signed-off-by: dependabot[bot] <support@github.com>
2021-01-18 10:02:38 +00:00
Noah Hilverling
adf3508588
Merge pull request #242 from Icinga/dependabot/go_modules/github.com/google/uuid-1.1.4
Bump github.com/google/uuid from 1.1.3 to 1.1.4
2021-01-12 07:54:38 +01:00
dependabot[bot]
595fc46f61
Bump github.com/google/uuid from 1.1.3 to 1.1.4
Bumps [github.com/google/uuid](https://github.com/google/uuid) from 1.1.3 to 1.1.4.
- [Release notes](https://github.com/google/uuid/releases)
- [Commits](https://github.com/google/uuid/compare/v1.1.3...v1.1.4)

Signed-off-by: dependabot[bot] <support@github.com>
2021-01-11 10:02:31 +00:00
Noah Hilverling
fd97bbe74d
Merge pull request #238 from Icinga/dependabot/go_modules/github.com/prometheus/client_golang-1.9.0
Bump github.com/prometheus/client_golang from 1.8.0 to 1.9.0
2021-01-08 09:40:00 +01:00
Noah Hilverling
fa2cc79bea
Merge pull request #240 from Icinga/dependabot/go_modules/github.com/google/uuid-1.1.3
Bump github.com/google/uuid from 1.1.2 to 1.1.3
2021-01-08 09:38:52 +01:00
dependabot[bot]
d0c34b5d9a
Bump github.com/google/uuid from 1.1.2 to 1.1.3
Bumps [github.com/google/uuid](https://github.com/google/uuid) from 1.1.2 to 1.1.3.
- [Release notes](https://github.com/google/uuid/releases)
- [Commits](https://github.com/google/uuid/compare/v1.1.2...v1.1.3)

Signed-off-by: dependabot[bot] <support@github.com>
2021-01-04 10:02:30 +00:00
dependabot[bot]
da4d0965f7
Bump github.com/prometheus/client_golang from 1.8.0 to 1.9.0
Bumps [github.com/prometheus/client_golang](https://github.com/prometheus/client_golang) from 1.8.0 to 1.9.0.
- [Release notes](https://github.com/prometheus/client_golang/releases)
- [Changelog](https://github.com/prometheus/client_golang/blob/master/CHANGELOG.md)
- [Commits](https://github.com/prometheus/client_golang/compare/v1.8.0...v1.9.0)

Signed-off-by: dependabot[bot] <support@github.com>
2020-12-21 10:02:34 +00:00
Noah Hilverling
75c6bdebea
Merge pull request #205 from Icinga/feature/password-authentication
Add Redis password authentication
2020-12-10 16:57:44 +01:00
Noah Hilverling
f555bfdd4d
Merge pull request #219 from Icinga/add-missing-object-name-indices
mysql/schema: Add name indices to host,service,user,usergroup tables
2020-12-10 16:52:23 +01:00
Noah Hilverling
fcace92903
Merge pull request #227 from Icinga/bugfix/bytes-nil
Actually insert NULL into NULLable columns
2020-12-10 16:49:59 +01:00
Noah Hilverling
ba4c7e0e05
Merge pull request #230 from Icinga/bugfix/error-message-in-tests
Fix error message for MySQL in tests which previously said that Redis is not working
2020-12-10 16:47:55 +01:00
Julian Brost
2edd75de39 Fix error message for MySQL in tests which previously said that Redis is not working 2020-11-17 13:24:31 +01:00
Eric Lippmann
54085f18ac Initial commit 2020-11-05 13:22:59 +01:00
Alexander A. Klimov
0abfebb66b Actually insert NULL into NULLable columns 2020-10-27 16:49:19 +01:00
Alexander Aleksandrovič Klimov
cdd98c4f10
Merge pull request #226 from Icinga/feature/mariadb104
Keep testing w/ MariaDB v10.4
2020-10-27 11:42:15 +01:00
Alexander Aleksandrovič Klimov
0da141486a
Merge pull request #225 from Icinga/feature/redis6
Test also w/ Redis v6+
2020-10-27 11:40:20 +01:00
Alexander Aleksandrovič Klimov
aa446de8dc
Keep testing w/ MariaDB v10.4
... after v10.5 was released.
2020-10-27 11:37:42 +01:00
Alexander Aleksandrovič Klimov
ed2b517fe4
Test also w/ Redis v6+ 2020-10-27 11:27:02 +01:00
Alexander Aleksandrovič Klimov
7fe21a5f16
Merge pull request #224 from Icinga/feature/go114
Keep testing w/ Go v1.14
2020-10-27 11:24:48 +01:00
Alexander Aleksandrovič Klimov
1ff02283d7
Keep testing w/ Go v1.14
... after v1.15 was released.
2020-10-27 11:19:48 +01:00
Noah Hilverling
9e1275ca11
Merge pull request #213 from Icinga/dependabot/go_modules/github.com/sirupsen/logrus-1.7.0
Bump github.com/sirupsen/logrus from 1.6.0 to 1.7.0
2020-10-20 13:07:12 +02:00
Noah Hilverling
8c799e829e
Merge pull request #217 from Icinga/dependabot/go_modules/github.com/go-ini/ini-1.62.0
Bump github.com/go-ini/ini from 1.61.0 to 1.62.0
2020-10-20 13:06:06 +02:00
dependabot[bot]
980d62518c
Bump github.com/go-ini/ini from 1.61.0 to 1.62.0
Bumps [github.com/go-ini/ini](https://github.com/go-ini/ini) from 1.61.0 to 1.62.0.
- [Release notes](https://github.com/go-ini/ini/releases)
- [Commits](https://github.com/go-ini/ini/compare/v1.61.0...v1.62.0)

Signed-off-by: dependabot[bot] <support@github.com>
2020-10-20 11:01:00 +00:00