Closed yoshinorim closed 8 years ago
@yoshinorim, I've started looking into this. In ha_rocksdb::store_lock() we set two things - we set lock_rows (and lock_for_write) to tell ourselves how to lock later and we set lock.type which appears to tell MySQL information about what we are allowing.
The change that I need to do would appear to be only related to the first part (lock_rows and lock_for_write) and not for the second. Is that correct?
If so, I think what I need to do is if I would be setting lock_rows to false, check the option and the above criteria and if everything fits I would set lock_rows to true (but leave lock_for_write as false). Does that sound right?
@jkedgar Yes, updating lock_rows and lock_for_write depending on config (session) variable would work.
This added a new option (named rocksdb-lock-scanned-rows) that can be used to act more like InnoDB in regards to locking rows that are scanned during an insert/update but are not going to be changed.
InnoDB locks scanned rows. This includes join and subquery like below:
InnoDB holds shared lock on scanned rows in t2. MyRocks does not hold any lock in t2. Locking t2 is not really needed with RBR. But to make transition from InnoDB to MyRocks easier, it might be useful to have an option to lock scanned rows from t2. Since MyRocks currently does not support shared lock, hold exclusive lock instead. Also, when the option is turned on, scanned but not found rows should be locked too (#165 should be skipped).
Here is an example:
InnoDB implements this logic in ha_rocksdb::store_lock(). We may reuse this in MyRocks.