Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: ERROR 1010 (HY000): Error dropping database #662

Closed
3 tasks done
hustjieke opened this issue Oct 9, 2022 · 4 comments
Closed
3 tasks done

bug: ERROR 1010 (HY000): Error dropping database #662

hustjieke opened this issue Oct 9, 2022 · 4 comments
Assignees
Labels
A-bug Something isn't working C-stonedb-8.0 associated with stonedb 8.0

Comments

@hustjieke
Copy link
Collaborator

Have you read the Contributing Guidelines on issues?

Please confirm if bug report does NOT exists already ?

  • I confirm there is no existing issue for this

Describe the problem

If database has table, can not drop it:

mysql> create database test;
Query OK, 1 row affected (0.01 sec)

mysql> use test
Database changed
mysql> create table t(a int key, b int) engine = tianmu;
Query OK, 0 rows affected (0.06 sec)

mysql> drop database test;
ERROR 1010 (HY000): Error dropping database (can't rmdir './test/', errno: 17 - File exists)

Expected behavior

drop database success.

How To Reproduce

mysql> create database test;
Query OK, 1 row affected (0.01 sec)

mysql> use test
Database changed
mysql> create table t(a int key, b int) engine = tianmu;
Query OK, 0 rows affected (0.06 sec)

mysql> drop database test;
ERROR 1010 (HY000): Error dropping database (can't rmdir './test/', errno: 17 - File exists)

Environment

  1. ubuntu 20.04
  2. stonedb-8.0-dev
  3. commit id: 52a721e

Are you interested in submitting a PR to solve the problem?

  • Yes, I will!
@hustjieke hustjieke added the A-bug Something isn't working label Oct 9, 2022
@hustjieke hustjieke added this to the stonedb_8.0_v1.0.0 milestone Oct 9, 2022
@hustjieke hustjieke self-assigned this Oct 9, 2022
@hustjieke hustjieke added the C-stonedb-8.0 associated with stonedb 8.0 label Oct 9, 2022
@hustjieke hustjieke moved this to In Progress in StoneDB for MySQL 8.0 Oct 9, 2022
@hustjieke
Copy link
Collaborator Author

trace log:

do_command: info: Command on socket (44) = 3 (Query)
do_command: info: packet: '                    '; command: 3
dispatch_command: info: command: 3
gtid_pre_statement_checks: info: gtid_next->type=0 owned_gtid.{sidno,gno}={0,0}
gtid_pre_statement_checks: info: gtid_next_list=(nil) gtid_next->type=0 thd->owned_gtid.gtid.{sidno,gno}={0,0} thd->thread_id=9
TC_LOG::enum_result MYSQL_BIN_LOG::commit: info: query='drop database test'
gtid_reacquire_ownership_if_anonymous: info: gtid_next->type=0 gtid_mode=OFF
THD::is_ddl_gtid_compatible: info: is_binlog_open:1 is_binlog_enabled_for_session:1
THD::is_ddl_gtid_compatible: info: is_create_table:0 is_create_temporary_table:0 is_create_table_select:0 is_create_table_atomic:0 is_drop_table:0 is_drop_temporary_table:0 is_in_transaction:0 is_in_sub_statement:0 is_binlog_format_statement:1
find_unknown_and_remove_deletable_files: info: Examining: t.tianmu

error returned from find_unknown_and_remove_deletable_files .

@hustjieke
Copy link
Collaborator Author

image

@hustjieke
Copy link
Collaborator Author

For drop database call stack :

exts_handlerton(plugin_ref plugin, void * arg) (/github/stonedb/sql/handler.cc:7458)
plugin_foreach_with_mask(THD * thd, plugin_foreach_func ** funcs, int type, uint state_mask, void * arg) (/github/stonedb/sql/sql_plugin.cc:2760)
plugin_foreach_with_mask(THD * thd, plugin_foreach_func * func, int type, uint state_mask, void * arg) (/github/stonedb/sql/sql_plugin.cc:2773)
ha_known_exts() (/github/stonedb/sql/handler.cc:7482)
find_unknown_and_remove_deletable_files(THD * thd, MY_DIR * dirp, const char * path) (/github/stonedb/sql/sql_db.cc:959)
mysql_rm_db(THD * thd, const LEX_CSTRING & db, bool if_exists) (/github/stonedb/sql/sql_db.cc:779)
mysql_execute_command(THD * thd, bool first_level) (/github/stonedb/sql/sql_parse.cc:3771)
dispatch_sql_command(THD * thd, Parser_state * parser_state) (/github/stonedb/sql/sql_parse.cc:5239)
dispatch_command(THD * thd, const COM_DATA * com_data, enum_server_command command) (/github/stonedb/sql/sql_parse.cc:1959)
do_command(THD * thd) (/github/stonedb/sql/sql_parse.cc:1362)
handle_connection(void * arg) (/github/stonedb/sql/conn_handler/connection_handler_per_thread.cc:302)
pfs_spawn_thread(void * arg) (/github/stonedb/storage/perfschema/pfs.cc:2942)
libpthread.so.0!start_thread(void * arg) (/build/glibc-SzIz7B/glibc-2.31/nptl/pthread_create.c:477)
libc.so.6!clone() (/build/glibc-SzIz7B/glibc-2.31/sysdeps/unix/sysv/linux/x86_64/clone.S:95)

When get file extensions from each plugin, we'll get extensions like.ibd, .csv...
But when get from tianmu plugin, ton->file_extensions is 0x0

@hustjieke
Copy link
Collaborator Author

In stonedb 5.7, it use bas_ext to get file extensions

const char **TianmuHandler::bas_ext() const {
  static const char *ha_rcbase_exts[] = {common::TIANMU_EXT, 0};
  return ha_rcbase_exts;
}

but in 8.0, changed to a variable setted in struct handlerton:

const char **file_extensions;
/github/stonedb/sql/handler.cc
  4508,25:   if (!(start_ext = ht->file_extensions)) return 0;
  4533,25:   if (!(start_ext = ht->file_extensions)) return 0;
  5431,14:   if (!hton->file_extensions) return false;
  5436,35:     for (const char **ext = hton->file_extensions; *ext; ext++) {
  7458,47:   if (hton->state == SHOW_OPTION_YES && hton->file_extensions) {
  7462,22:     for (ext = hton->file_extensions; *ext; ext++) {

/github/stonedb/sql/handler.h
  2675,16:   const char **file_extensions;

/github/stonedb/sql/sql_admin.cc
  196,26:   ext = table->file->ht->file_extensions;

/github/stonedb/sql/table.cc
  3373,26:           if (!file->ht->file_extensions ||
  3374,36:               !(datext = file->ht->file_extensions[0]))

/github/stonedb/storage/archive/ha_archive.cc
  240,17:   archive_hton->file_extensions = ha_archive_exts;

/github/stonedb/storage/csv/ha_tina.cc
  184,14:   tina_hton->file_extensions = ha_tina_exts;

/github/stonedb/storage/innobase/handler/ha_innodb.cc
  5155,18:   innobase_hton->file_extensions = ha_innobase_exts;

/github/stonedb/storage/myisam/ha_myisam.cc
  1990,16:   myisam_hton->file_extensions = ha_myisam_exts;

/github/stonedb/storage/myisammrg/ha_myisammrg.cc
  1431,19:   myisammrg_hton->file_extensions = ha_myisammrg_exts;

/github/stonedb/unittest/gunit/temptable/temptable-handler-t.cc
  94,28:     m_temptable_handlerton.file_extensions = nullptr;

hustjieke added a commit to hustjieke/stonedb-8.0.30-upgrade that referenced this issue Oct 11, 2022
…ase error stoneatom#662

[summary]
When drop database, mysqld cannot find tianmu file extension and drop failed.
1. change all `rcbase_hton` to `tianmu_hton`, just like innodb, myisam,
csv ... does.
2. rm function bas_ext(), it used in 5.7, but removed in 8.0 and changed
to a variable instead.
3. Add tianmu file extension to tianmu_hton->file_extensions.
mergify bot pushed a commit that referenced this issue Oct 12, 2022
…ase error #662

[summary]
When drop database, mysqld cannot find tianmu file extension and drop failed.
1. change all `rcbase_hton` to `tianmu_hton`, just like innodb, myisam,
csv ... does.
2. rm function bas_ext(), it used in 5.7, but removed in 8.0 and changed
to a variable instead.
3. Add tianmu file extension to tianmu_hton->file_extensions.
Repository owner moved this from In Progress to Done in StoneDB for MySQL 8.0 Oct 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-bug Something isn't working C-stonedb-8.0 associated with stonedb 8.0
Projects
Development

No branches or pull requests

1 participant