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#1634932: Assertion failure in thread x in file fts0que.cc #1297

Merged
merged 2 commits into from
Feb 10, 2017

Conversation

robgolebiowski
Copy link
Contributor

No test case for this bug as it is very time and resource consuming.

@laurynas-biveinis
Copy link
Contributor

Same comment re. Launchpad bug handling as in the other PRs

@laurynas-biveinis laurynas-biveinis self-assigned this Jan 20, 2017
@laurynas-biveinis
Copy link
Contributor

The commit message should be slightly more descriptive ("foo and bar allocated but did not free baz in the case of error")

@laurynas-biveinis
Copy link
Contributor

Can you tell why the testcase is time and resource consuming? Is it possible to reduce it?

@@ -953,6 +953,18 @@ fts_query_free_doc_ids(
query->total_size -= SIZEOF_RBT_CREATE;
}


/*******************************************************************//**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New InnoDB code should use the new InnoDB function header comment style (see e.g. fts_ast_string_create, innobase_mysql_tmpfile, fil_rename_tablespace_check for examples)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

static
void
fts_query_free_intersection(
fts_query_t* query) /*!< in: query instance */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either here, either in the function body the indentation is wrong (should be tabs everywhere)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -1311,6 +1323,7 @@ fts_query_intersect(
/* error is passed by 'query->error' */
if (query->error != DB_SUCCESS) {
ut_ad(query->error == DB_FTS_EXCEED_RESULT_CACHE_LIMIT);
fts_query_free_intersection(query);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation (should be tabs)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -1557,6 +1572,10 @@ fts_merge_doc_ids(
query, ranking->doc_id, ranking->rank);

if (query->error != DB_SUCCESS) {
if (query->oper == FTS_EXIST && query->intersection != NULL)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The query->oper == FTS_EXIST check looks redundant: the function asserts query->intersection == NULL at the start and only sets it to something if that check passes

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can replace with an ut_ad(query->oper == FTS_EXIST) if the branch is taken

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@robgolebiowski
Copy link
Contributor Author

@@ -0,0 +1,50 @@
--echo #
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use upstream bug number for upstream bugs (ie. bug83648.test). After the Percona Server merge the next step is to send the bugfix to Oracle (get your Percona OCA sorted out meanwhile)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


-- source include/have_innodb.inc

# Must have debug code to use SET SESSION debug
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant comment

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

delimiter ;//

call populate_t1;
SET autocommit=1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

COMMIT ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed, from documentation: "If autocommit is 0 and you change it to 1, MySQL performs an automatic COMMIT of any open transaction"

call populate_t1;
SET autocommit=1;

let @saved_session_debug= @@session.debug;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to save and restore session variables - MTR will disconnect the session at the end of the testcase. Only global variables have to be saved and restored

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DONE.

SET autocommit=1;

let @saved_session_debug= @@session.debug;
SET SESSION debug="d,fts_instrument_result_cache_limit";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But here you want to enable some debug setting and later disable it, so for that here use "+d,fts_...", and below "-d,fts_..."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, removed.

# Must have debug code to use SET SESSION debug
--source include/have_debug.inc

create table `t1` (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consistent case for SQL keywords, suggesting uppercase

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -765,7 +765,8 @@ JOIN::optimize()
if (!(select_options & SELECT_DESCRIBE) &&
!select_lex->materialized_table_count)
{
init_ftfuncs(thd, select_lex, order);
if (init_ftfuncs(thd, select_lex, order))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the other callers of init_ftfuncs do not check its return code - are they affected by this bug?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They were. This was fixed in 5.7 by bug fix:21140111. I have ported this bug into 5.6. The bug fix is not completely correct - needed to move check for errors from init_ftfuncs bit higher in sql_delete.cc, otherwise error from init_ftfuncs caused assertion problem.

The problem here is missing error check in Item_func_match::init_search()
after the handler call ft_init_ext_with_hints(), and missing error
propagation in the call stack.

The fix also includes a new inlined query block property function
has_ft_funcs() that is used to avoid an unnecessary and costly
function call to optimize full-text searches.

(cherry picked from commit e78f3cb)
@robgolebiowski
Copy link
Contributor Author

Copy link
Contributor

@laurynas-biveinis laurynas-biveinis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Er, no, please check Jenkins results - the debug build crashes constantly

@robgolebiowski
Copy link
Contributor Author

Jenkins run => http://jenkins.percona.com/job/percona-server-5.6-param/1641/ There are some tests failing, but I have run them locally and all pass fine.

@@ -0,0 +1,55 @@
--echo #
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this test be put into innod_fts test suite rather than innodb?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

`text_content` MEDIUMTEXT, PRIMARY KEY (`FTS_DOC_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE UNIQUE INDEX FTS_DOC_ID_INDEX ON t1(FTS_DOC_ID);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is additional index really needed? FTS_DOC_ID is already the primary key.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is taken from here: https://dev.mysql.com/doc/refman/5.6/en/optimizing-innodb-bulk-data-loading.html . To speed up the inserts.

DELETE FROM t1
WHERE MATCH text_content AGAINST ('+some_text_1234' IN BOOLEAN MODE);

SET GLOBAL innodb_ft_result_cache_limit=default;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Store @@global.innodb_ft_result_cache_limit at the beginning of the test and restore it here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -1339,7 +1352,9 @@ fts_query_intersect(

ut_a(!query->multi_exist || (query->multi_exist
&& rbt_size(query->doc_ids) <= n_doc_ids));
}
} else if (query->intersection != NULL) {
fts_query_free_intersection(query);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatting

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

}
} else if (query->intersection != NULL) {
fts_query_free_intersection(query);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatting

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

--source include/have_innodb.inc
--source include/have_debug.inc

SET @saved_innodb_ft_result_cache_limit= @@innodb_ft_result_cache_limit;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to save GLOBAL variable here, e.g.

SET @saved_innodb_ft_result_cache_limit= @@global.innodb_ft_result_cache_limit;

@@ -953,6 +953,18 @@ fts_query_free_doc_ids(
query->total_size -= SIZEOF_RBT_CREATE;
}

/**
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

InnoDB code (everything in storage/innobase*) requires InnoDB-style code formatting:

  1. Tab characters must be used for indentation
  2. Blocks must be indented by 1 tab
  3. 1 tab = 8 spaces (set this in your editor)

SQL code (for instance sql/* and include/*) requires MySQL-style code formatting:

  1. Using spaces only for indentation.
  2. Blocks must be indented by 2 spaces.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

The bug was caused by three problems:
1) query->intersection was not freed in case of error caused by
exceeding innodb_ft_result_cache_limit.
2) errors from init_ftfuncs were not propagated - this was fixed
in 5.7 by bug fix 21140111. This was ported into 5.6
3) bug fix 21140111 was causing assertion failure when
innodb_ft_result_cache was exceeded in DELETE command. This was
also fixed.
@robgolebiowski robgolebiowski merged commit 23243c0 into percona:5.6 Feb 10, 2017
@robgolebiowski robgolebiowski deleted the 5.6-ps-bug1634932 branch February 10, 2017 14:36
inikep pushed a commit to inikep/percona-server that referenced this pull request Dec 20, 2023
Summary:
Add ddst_dict_init handler api support for rocksdb dd

Currently rocksdb ddst_dict_init() doesn't add any rocksdb specific tables and tablespace during ddse initialize.

Pull Request resolved: facebook/mysql-5.6#1297

Test Plan: CI

Differential Revision: D46700996

fbshipit-source-id: fbb80035b54cc068c845e63fe6903c8488fce1d3
inikep pushed a commit to inikep/percona-server that referenced this pull request Dec 20, 2023
Summary:
Add ddst_dict_init handler api support for rocksdb dd

Currently rocksdb ddst_dict_init() doesn't add any rocksdb specific tables and tablespace during ddse initialize.

Pull Request resolved: facebook/mysql-5.6#1297

Test Plan: CI

Differential Revision: D46700996

fbshipit-source-id: fbb80035b54cc068c845e63fe6903c8488fce1d3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants