# Performance issue with wsrep: in pre-commit stage

**URL:** <https://forums.percona.com/t/performance-issue-with-wsrep-in-pre-commit-stage/5191>\
**Category:** Percona XtraDB Cluster 5.x\
**Created:** [November 6, 2016, 1:30pm UTC](https://forums.percona.com/t/performance-issue-with-wsrep-in-pre-commit-stage/5191 "2016-11-06T13:30:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![maver1ck](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@maver1ck](https://forums.percona.com/u/maver1ck)\
**Post date:** [November 6, 2016, 1:30pm UTC](https://forums.percona.com/t/performance-issue-with-wsrep-in-pre-commit-stage/5191/1 "2016-11-06T13:30:42Z")

</div>

Hi,  
I have following problem with PXC.

1. I have following configuration  
2 x DB + Arbitrator  
PXC version 5.7.14

2. I’m writing data to database on 50 concurrent threads.  
Writes are batched and every 10k rows there is a commit.

3. The problem is that commit is super slow. It can take up to 60 second.  
And during commit thread is in “wsrep: in pre-commit stage” state.

4. my.cnf

[client]  
port = 3306  
socket = /var/run/mysqld/mysqld.sock

[mysqld]  
log\_error = /var/log/mysql/error.log  
server-id=1  
log-bin  
expire\_logs\_days=2  
binlog\_format=ROW

default\_storage\_engine=InnoDB  
innodb\_autoinc\_lock\_mode=2

wsrep\_provider=/usr/lib/libgalera\_smm.so  
wsrep\_cluster\_address=gcomm://list\_of\_nodes  
wsrep\_node\_address=address  
wsrep\_sst\_method=xtrabackup-v2  
wsrep\_cluster\_name=bi-percona  
wsrep\_sst\_auth=“login:password”  
wsrep\_slave\_threads=15  
wsrep\_provider\_options=“gcache.size=128G;gcs.fc\_limit=128;gsc.fc\_master\_slave=YES;repl.commit\_order=0”

skip-external-locking  
sql\_mode=“STRICT\_TRANS\_TABLES,ERROR\_FOR\_DIVISION\_BY\_ZERO,NO\_AUTO\_CREATE\_USER,NO\_ENGINE\_SUBSTITUTION”  
pxc\_strict\_mode = PERMISSIVE

bind-address = 0.0.0.0  
ssl = on

max\_allowed\_packet = 1G  
group\_concat\_max\_len = 1073741824  
key\_buffer\_size = 8589934592  
max\_heap\_table\_size = 10737418240  
max\_connect\_errors = 1000000  
thread\_stack = 192K  
thread\_cache\_size = 8

query\_cache\_type = 0

max\_connections = 2000  
thread\_cache\_size = 100  
open\_files\_limit = 10440

query\_cache\_size = 0

net\_read\_timeout = 360  
net\_write\_timeout = 360  
default-storage-engine = InnoDB  
innodb\_flush\_method = O\_DIRECT  
innodb\_log\_files\_in\_group = 4  
innodb\_log\_file\_size = 1G  
innodb\_flush\_log\_at\_trx\_commit = 0  
innodb\_file\_per\_table = 1  
innodb\_buffer\_pool\_size = 128G  
innodb\_buffer\_pool\_instances = 64  
character-set-client-handshake = FALSE  
character-set-server = utf8mb4  
collation-server = utf8mb4\_unicode\_ci  
range\_optimizer\_max\_mem\_size = 100M

What can I do to optimize writes ?  
I already enabled wsrep\_slave\_threads. I was experimenting with wsrep\_provider\_options. What else can I do?

Regards,  
Maciek

---

<div class="post-metadata">

**Author:** ![krunalbauskar](https://avatars.discourse-cdn.com/v4/letter/k/439d5e/32.png) [@krunalbauskar](https://forums.percona.com/u/krunalbauskar)\
**Post date:** [November 8, 2016, 4:05am UTC](https://forums.percona.com/t/performance-issue-with-wsrep-in-pre-commit-stage/5191/2 "2016-11-08T04:05:16Z")

</div>

Hi maver1ck,

a. From the problem statement described above you are using long or big transactions (10K rows per commit).

b. Galera/PXC doesn’t work well with large trx and fix for it will be upcoming in galera-4.x

c. Easiest solution is break your commit in smaller set. Say 500 or less that works well for your environment

* * *

Said that some theory

when you commit in PXC Galera:

a. write-set needed for pxc replication is formed. For really large trx if write-set doesn’t fit in memory it will be written to disk in form of file.  
b. this write-set is then replicated on group channel that needs round-trip to other nodes. (heavy operation)  
c. this is followed by local certification.  
d. Finally the real mysql-commit is done

(action a, b and c are termed as pre-commit)

So even though you are writing rows as part of trx there is no cost incurred immediately during your DML operation.  
Real replication is done only on commit so commit is taking good amount of time.

---

<div class="post-metadata">

**Author:** ![krunalbauskar](https://avatars.discourse-cdn.com/v4/letter/k/439d5e/32.png) [@krunalbauskar](https://forums.percona.com/u/krunalbauskar)\
**Post date:** [April 24, 2017, 11:25am UTC](https://forums.percona.com/t/performance-issue-with-wsrep-in-pre-commit-stage/5191/3 "2017-04-24T11:25:11Z")

</div>

check the performance optimized pxc-5.7

[url][https://www.percona.com/blog/2017/04/19/performance-improvements-percona-xtradb-cluster-5-7-17/[/url]](https://www.percona.com/blog/2017/04/19/performance-improvements-percona-xtradb-cluster-5-7-17/%5B/url%5D)
