-
Notifications
You must be signed in to change notification settings - Fork 13
UPDATE for table with VARCHAR pk gives "Can't find record" error #99
Comments
The reason for this is as follows:
|
Possible solutions: S1. Let the rowid be PK in KeyTupleFormat. KeyTupleFormat is fixed-length.
S2. Keep the rowid being mem-comparable form.
|
This doesn't work in all cases. In this case, secondary index only gives mem-comparable form of PK columns. We can't restore the original values, and so we can return them in KeyTupleFormat |
This looks feasible. mem-comparable images of keys are traversed by skip_variable_length skips data in "varchar encoding". Varchar encoding means 9-byte groups, where the 9th byte varies between 0xFF (no padding bytes) to 0xF7 (all 8 bytes were padding bytes). That is, if the next 9-byte group is padding it has all zeros, it is zero-padding, otherwise it is not. |
…s PK values Summary: Do set handler::key_used_on_scan in ha_rocksdb::open. This informs the SQL layer that MyRocks uses primary key when doing a full table scan. When the SQL layer knows this, it will buffer updates that change the value of the primary key. Note: after this patch, rocksdb.rocksdb test fails with this error: Can't find record in 't8'. This is Issue #99. Test Plan: Run MTR Reviewers: hermanlee4, maykov, jtolmer, yoshinorim Reviewed By: yoshinorim Differential Revision: https://reviews.facebook.net/D45519
… error Summary: MyRocks uses mem-comparable form of Primary Key as rowid. SQL layer assumes that rowids have fixed size. However, "Efficient Varchar encoding" feature in MyRocks makes mem-comparable forms to have varying lengths. This causes rowids to be "garbage-padded", and possible "Record not found" errors whenever SQL layer calls ha_rocksdb::rnd_pos(). Fixed by making ::position() to pad rowid with zeros, and making ::rnd_pos() remove the zeros before doing the PK lookup. Test Plan: Ran MTR Reviewers: maykov, jtolmer, jkedgar, yoshinorim, hermanlee4 Reviewed By: hermanlee4 Differential Revision: https://reviews.facebook.net/D45639
Testcase:
This gives an error:
The text was updated successfully, but these errors were encountered: