vault icon indicating copy to clipboard operation
vault copied to clipboard

MySQL backend HA lock discuss

Open fatindeed opened this issue 3 years ago • 0 comments

I'm not sure where to post this discussion, so I posted it here.

Now, mysql backend have 2 classes related to HA lock, MySQLHALock and MySQLLock. They both establish mysql connections.

https://github.com/hashicorp/vault/blob/81225745735ddb0ed36f5ea0ff9020672d2e2339/physical/mysql/mysql.go#L540-L555 In MySQLHALock, it will run query every 5 seconds to check if leadership changed.

https://github.com/hashicorp/vault/blob/81225745735ddb0ed36f5ea0ff9020672d2e2339/physical/mysql/mysql.go#L698 But in MySQLLock, no query at all. Only try to get the lock, and update the vault_lock table after got lock successfully. That means, once the node got the leadership, the connection established by MySQLLock won't run any query unitl idle connection timeout. But on the other side, the connection established by MySQLHALock will query every 5 seconds.

Can we use one connection for both MySQLHALock and MySQLLock? So the leadership won't lost due to idle connection timeout.

fatindeed avatar Sep 13 '22 06:09 fatindeed