Checking of the indexes that are on the deletion#86
Conversation
There is a possibility that an index that is on a deletion can be selected by the optimizer and we get "index unexpectedly deleted" error. This is caused by the fact that the index still holds in the index tree and will be deleted on commit. To reproduce this error: 1. Drop the index in the first transaction. Not to do commit. 2. Set the breakpoint at phase 4 in delete_index (dfw.cpp) 3. Make the commit of the first transaction. The debugger will stop at the breakpoint. 4. In the second transaction execute the query with the index. 5. Continue running the server from the breakpoint. The optimizer first executes the BTR_all, and then the index is locked, but it's already deleted.
|
I see the following lines added by your commit: The problem with such approach is that it often has problems on classic server. Did you check on classic? |
|
I also failed to see how it could work on CS. |
|
Fixed locking of index on deletion stage via lock manager. Works on super/classic server. |
hvlad
left a comment
There was a problem hiding this comment.
I don't recommend to apply this patch
|
|
||
| Database* dbb = tdbb->getDatabase(); | ||
|
|
||
| Lock* lock = FB_NEW_RPT(*relation->rel_pool, 0) Lock(tdbb, sizeof(SLONG), LCK_idx_deletion); |
There was a problem hiding this comment.
Where is "lock" stored\deleted ? Do we have memory leak there ?
| lock->lck_type, lock->getKeyPtr(), lock->lck_length, | ||
| LCK_EX, lock->lck_ast, lock->lck_object, lock->lck_data, LCK_WAIT, | ||
| lock->lck_owner_handle); | ||
|
|
There was a problem hiding this comment.
Why direct call of LM, not LCK_lock() here ?
| if (!skip) | ||
| count++; | ||
| } | ||
| } |
There was a problem hiding this comment.
Additional call of LM in BTR_all looks like bad idea - it is not needed in 99% of cases and add performance overhead.
Also, i don't understand trick with storing request offset (lck_id) at lock data and double reading of it later in all places.
Also, here we have another leak of "Lock" instance.
Seems, you better should ask in fb-devel how to work with LM properly...
|
Why introduce new kind of lock ? Why not use LCK_idx_exists ? Usage of lock data is wrong and not needed, sorry. PS If you need help understanding how locking in general and metadata locking supposed to work - feel free to ask in fb-devel or contact me directly. |
|
This attempt is better but still not working :)
Probably i missed something, good luck |
|
Thank you for reply! I need to "digest" this information. |
There is a possibility that an index that is on a deletion can be selected by the optimizer and we get "index unexpectedly deleted" error. This is caused by the fact that the index still holds in the index tree and will be deleted on commit.
To reproduce this error:
The optimizer first executes the BTR_all, and then the index is locked, but it's already deleted.