wesql / wescale

WeScale is a Modern MySQL proxy that supports read-write-split, read-after-write-consistency, load balancing and OnlineDDL.
https://wesql.io
Apache License 2.0
203 stars 8 forks source link

Feature Request: Rewrite Select for Lock-related Functions(engine.Lock) #106

Open earayu opened 1 year ago

earayu commented 1 year ago

Background:

The Select function for lock-related functions generates an engine.Lock type of plan and has a corresponding execution function. However, there is still room for improvement in terms of their correctness and compatibility with MySQL.

Solution:

We need to rewrite engine.Lock primitive and related planner. The VTGate layer need not to evaluate expressions or split the locking functions. Just like engine.Send, VTGate should send the SQL to VTTablet, and add some flags in session. That's all.

earayu commented 1 year ago

For SQL like select get_lock('xyz', 10) from db1.t1

  1. The planner will generate an engine.Lock plan
  2. During execution stage, the tryExecute() of engine.Lock will be called
  3. And inside the tryExecute(), it will generate a SQL like select get_lock('xyz', 10) from dual and will execute it.

So the tryExecute() of engine.Lock is not implemented correctly, we need to fix it.

earayu commented 1 year ago

see also: https://github.com/vitessio/vitess/issues/6367