Skip to content
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

Support Percona XtraDB Cluster by not using SERIALIZABLE transactions directly #609

Merged
merged 1 commit into from
Jul 31, 2023

Conversation

Al2Klimov
Copy link
Member

@Al2Klimov Al2Klimov commented Jun 22, 2023

The RDBMS rejects them by default. But it doesn't rejects their equivalent: Append "LOCK IN SHARE MODE" to every SELECT in a REPEATABLE READ transaction. Now we do the latter with MySQL.

fixes #576

Before

root@aklimov-pxc:~# cat idb.yml
database:
  type: mysql
  host: 172.19.0.3
  database: icingadb
  user: icingadb
  password: icingadb
redis:
  host: localhost
  port: 6379
root@aklimov-pxc:~# /home/debian/l63 -c idb.yml
2023-06-22T13:12:07.566Z	INFO	l63	Starting Icinga DB
2023-06-22T13:12:07.566Z	INFO	l63	Connecting to database at '172.19.0.3:0'
2023-06-22T13:12:07.579Z	INFO	l63	Connecting to Redis at 'localhost:6379'
2023-06-22T13:12:07.580Z	INFO	l63	Starting history sync
2023-06-22T13:12:08.282Z	INFO	heartbeat	Received Icinga heartbeat	{"environment": "79c4cbeb3eb06a9bfd91beeb60a8ea842234a96d"}
2023-06-22T13:12:08.295Z	FATAL	l63	Error 1105: Percona-XtraDB-Cluster doesn't recommend using SERIALIZABLE isolation with pxc_strict_mode = ENFORCING
can't start transaction
github.com/icinga/icingadb/pkg/icingadb.(*HA).realize.func1
	/Users/aklimov/NET/WS/icingadb/pkg/icingadb/ha.go:253

After

root@aklimov-pxc:~# /home/debian/l64 -c idb.yml
2023-06-22T13:12:55.411Z	INFO	l64	Starting Icinga DB
2023-06-22T13:12:55.411Z	INFO	l64	Connecting to database at '172.19.0.3:0'
2023-06-22T13:12:55.425Z	INFO	l64	Connecting to Redis at 'localhost:6379'
2023-06-22T13:12:55.426Z	INFO	l64	Starting history sync
2023-06-22T13:12:56.385Z	INFO	heartbeat	Received Icinga heartbeat	{"environment": "79c4cbeb3eb06a9bfd91beeb60a8ea842234a96d"}
2023-06-22T13:12:56.401Z	INFO	l64	Taking over
2023-06-22T13:12:56.402Z	INFO	l64	Starting config sync
2023-06-22T13:12:56.402Z	INFO	l64	Starting overdue sync
2023-06-22T13:12:56.402Z	INFO	l64	Starting initial state sync
2023-06-22T13:12:56.416Z	INFO	config-sync	Inserting 4 items of type host customvar
2023-06-22T13:12:56.419Z	INFO	config-sync	Inserting 1 items of type host
2023-06-22T13:12:56.423Z	INFO	config-sync	Inserting 3 items of type servicegroup
2023-06-22T13:12:56.445Z	INFO	config-sync	Inserting 1 items of type hostgroup member
2023-06-22T13:12:56.453Z	INFO	config-sync	Inserting 3183 items of type checkcommand argument
2023-06-22T13:12:56.453Z	INFO	config-sync	Inserting 12 items of type notification usergroup
2023-06-22T13:12:56.453Z	INFO	config-sync	Inserting 1281 items of type checkcommand customvar
2023-06-22T13:12:56.461Z	INFO	config-sync	Inserting 246 items of type checkcommand
2023-06-22T13:12:56.462Z	INFO	config-sync	Inserting 11 items of type service state
2023-06-22T13:12:56.462Z	INFO	config-sync	Inserting 2 items of type notificationcommand
2023-06-22T13:12:56.462Z	INFO	config-sync	Inserting 1 items of type endpoint
2023-06-22T13:12:56.463Z	INFO	config-sync	Inserting 1 items of type downtime
2023-06-22T13:12:56.467Z	INFO	config-sync	Inserting 520 items of type customvar flat
2023-06-22T13:12:56.473Z	INFO	config-sync	Inserting 27 items of type notificationcommand customvar
2023-06-22T13:12:56.474Z	INFO	config-sync	Inserting 3 items of type timeperiod
2023-06-22T13:12:56.508Z	INFO	config-sync	Inserting 12 items of type timeperiod range
2023-06-22T13:12:56.508Z	INFO	config-sync	Inserting 12 items of type notification
2023-06-22T13:12:56.508Z	INFO	config-sync	Inserting 24 items of type notification recipient
2023-06-22T13:12:56.508Z	INFO	config-sync	Inserting 12 items of type notification customvar
2023-06-22T13:12:56.510Z	INFO	config-sync	Inserting 6 items of type checkcommand envvar
2023-06-22T13:12:56.510Z	INFO	config-sync	Inserting 2 items of type hostgroup
2023-06-22T13:12:56.510Z	INFO	config-sync	Inserting 3 items of type zone
2023-06-22T13:12:56.510Z	INFO	config-sync	Inserting 1 items of type usergroup member
2023-06-22T13:12:56.510Z	INFO	config-sync	Inserting 33 items of type notificationcommand argument
2023-06-22T13:12:56.511Z	INFO	config-sync	Inserting 11 items of type service
2023-06-22T13:12:56.538Z	INFO	config-sync	Inserting 5 items of type servicegroup member
2023-06-22T13:12:56.540Z	INFO	config-sync	Inserting 1 items of type host state
2023-06-22T13:12:56.549Z	INFO	config-sync	Inserting 502 items of type customvar
2023-06-22T13:12:56.557Z	INFO	config-sync	Inserting 1 items of type usergroup
2023-06-22T13:12:56.561Z	INFO	config-sync	Inserting 1 items of type user
2023-06-22T13:12:56.564Z	INFO	config-sync	Inserting 3 items of type service customvar
2023-06-22T13:12:56.592Z	INFO	l64	Starting state runtime updates sync
2023-06-22T13:12:56.594Z	INFO	config-sync	Finished initial state sync in 192.487138ms
2023-06-22T13:12:56.754Z	INFO	l64	Starting config runtime updates sync
2023-06-22T13:12:56.761Z	INFO	l64	Starting history retention
2023-06-22T13:12:56.761Z	INFO	config-sync	Finished config sync in 358.996294ms

… directly

The RDBMS rejects them by default. But it doesn't rejects their equivalent:
Append "LOCK IN SHARE MODE" to every SELECT in a REPEATABLE READ transaction.
Now we do the latter with MySQL.
@cla-bot cla-bot bot added the cla/signed label Jun 22, 2023
@Al2Klimov Al2Klimov changed the title Support Percona XtraDB Cluster by not using SERIALIZABLE transactions… Support Percona XtraDB Cluster by not using SERIALIZABLE transactions directly Jun 22, 2023
@julianbrost julianbrost added this to the 1.2.0 milestone Jul 26, 2023
Copy link
Contributor

@julianbrost julianbrost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But it doesn't rejects their equivalent: Append "LOCK IN SHARE MODE" to every SELECT in a REPEATABLE READ transaction.

Justification for this claim is hidden in #576 (comment).

@julianbrost julianbrost merged commit 62f7ae9 into master Jul 31, 2023
@julianbrost julianbrost deleted the percona-xtradb-cluster branch July 31, 2023 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Percona-XtraDB-Cluster Support
2 participants