[MDEV-21391] why not process ha_index_or_rnd_end 's return value Created: 2019-12-25  Updated: 2023-04-27

Status: Confirmed
Project: MariaDB Server
Component/s: Data Manipulation - Update
Affects Version/s: 10.4.8
Fix Version/s: 10.4

Type: Bug Priority: Minor
Reporter: chu huaxing Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: beginner-friendly


 Description   

#0 mdb::CMdb::rnd_end (this=0x7faaa801e490) at /data01/chuhx_mdb4/mariadb-10.4.8/storage/mdb/src/mdb/mdb.cc:735
#1 0x00007fab4dae3795 in ha_mdb::rnd_end (this=0x7faaa801bdf8) at /data01/chuhx_mdb4/mariadb-10.4.8/storage/mdb/src/handler/ha_mdb.cc:843
#2 0x00007fabdb7ce630 in handler::ha_rnd_end (this=0x7faaa801bdf8) at /data01/chuhx_mdb4/mariadb-10.4.8/sql/handler.h:3230
#3 0x00007fabdb88d996 in handler::ha_index_or_rnd_end (this=0x7faaa801bdf8) at /data01/chuhx_mdb4/mariadb-10.4.8/sql/handler.h:3237
#4 0x00007fabdc24dde0 in end_read_record (info=0x7faad47877c0) at /data01/chuhx_mdb4/mariadb-10.4.8/sql/records.cc:330
#5 0x00007fabdbb1d1cb in mysql_update (thd=0x7faaa8000b20, table_list=0x7faaa8011890, fields=..., values=..., conds=0x0, order_num=0, order=0x0, limit=0,
ignore=false, found_return=0x7faad4787d20, updated_return=0x7faad4787de0) at /data01/chuhx_mdb4/mariadb-10.4.8/sql/sql_update.cc:1220
#6 0x00007fabdb91f2a8 in mysql_execute_command (thd=0x7faaa8000b20) at /data01/chuhx_mdb4/mariadb-10.4.8/sql/sql_parse.cc:4387
#7 0x00007fabdb93482c in mysql_parse (thd=0x7faaa8000b20, rawbuf=0x7faaa8011788 "update test_sharding set x=x+1 limit 2", length=38, parser_state=0x7faad4788450,
is_com_multi=false, is_next_command=false) at /data01/chuhx_mdb4/mariadb-10.4.8/sql/sql_parse.cc:8018

(gdb)
end_read_record (info=0x7faad47877c0) at /data01/chuhx_mdb4/mariadb-10.4.8/sql/records.cc:331
331 info->table=0;
(gdb) l
326 {
327 if (info->table->is_created())
328 (void) info->table->file->extra(HA_EXTRA_NO_CACHE);
329 if (info->read_record_func != rr_quick) // otherwise quick_range does it
330 (void) info->table->file->ha_index_or_rnd_end();
331 info->table=0;
332 }
333 }

*we designed our own engine, and rnd_end() may return error , but at records.cc:330 , it is void, so update will success even error! *
why it is void?



 Comments   
Comment by Sergei Golubchik [ 2019-12-25 ]

What could the server do if your rnd_end() fails? The update loop is, basically,

  • open table
    • read row
    • update row
    • repeat
  • rnd_end

so if you fail at rnd_end() what does it mean? The table was already updated. The server cab try to rollback the transaction, if your engine is transactional. Otherwise it's too late to fail.

Comment by chu huaxing [ 2020-01-10 ]

But the return value type it defines is int (int ha_rnd_end(); /int ha_index_or_rnd_end();).
our engine is transactional,and it may update row in other node. for fast , we batch update , and may send in rnd_end( when sql with limit).

Comment by Sergei Golubchik [ 2020-01-21 ]

Are you saying that if the engine fails in rnd_end(), the server has to abort the transaction?

This sounds reasonable.

Comment by chu huaxing [ 2020-02-03 ]

yes, i mean that,when rnd_end() fail, the server should know, and to abort the transaction.

Generated at Thu Feb 08 09:06:47 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.