@@ -1574,9 +1574,23 @@ row_merge_read_clustered_index(
15741574 continue ;
15751575 }
15761576
1577- if ((buf->index ->type & DICT_FTS)
1578- && (!row || !doc_id)) {
1579- continue ;
1577+ if (buf->index ->type & DICT_FTS) {
1578+ if (!row || !doc_id) {
1579+ continue ;
1580+ }
1581+
1582+ /* Check if error occurs in child thread */
1583+ for (ulint j = 0 ; j < fts_sort_pll_degree; j++) {
1584+ if (psort_info[j].error != DB_SUCCESS) {
1585+ err = psort_info[j].error ;
1586+ trx->error_key_num = i;
1587+ break ;
1588+ }
1589+ }
1590+
1591+ if (err != DB_SUCCESS) {
1592+ break ;
1593+ }
15801594 }
15811595
15821596 /* The buffer must be sufficiently large
@@ -1634,7 +1648,7 @@ row_merge_read_clustered_index(
16341648
16351649 if (!row_merge_write (file->fd , file->offset ++,
16361650 block)) {
1637- err = DB_OUT_OF_FILE_SPACE ;
1651+ err = DB_TEMP_FILE_WRITE_FAILURE ;
16381652 trx->error_key_num = i;
16391653 break ;
16401654 }
@@ -1689,11 +1703,25 @@ row_merge_read_clustered_index(
16891703 ulint trial_count = 0 ;
16901704 const ulint max_trial_count = 10000 ;
16911705
1706+ wait_again:
1707+ /* Check if error occurs in child thread */
1708+ for (ulint j = 0 ; j < fts_sort_pll_degree; j++) {
1709+ if (psort_info[j].error != DB_SUCCESS) {
1710+ err = psort_info[j].error ;
1711+ trx->error_key_num = j;
1712+ break ;
1713+ }
1714+ }
1715+
16921716 /* Tell all children that parent has done scanning */
16931717 for (ulint i = 0 ; i < fts_sort_pll_degree; i++) {
1694- psort_info[i].state = FTS_PARENT_COMPLETE;
1718+ if (err == DB_SUCCESS) {
1719+ psort_info[i].state = FTS_PARENT_COMPLETE;
1720+ } else {
1721+ psort_info[i].state = FTS_PARENT_EXITING;
1722+ }
16951723 }
1696- wait_again:
1724+
16971725 /* Now wait all children to report back to be completed */
16981726 os_event_wait_time_low (fts_parallel_sort_event,
16991727 1000000 , sig_count);
@@ -3389,6 +3417,7 @@ row_merge_build_indexes(
33893417 fts_psort_t * psort_info = NULL ;
33903418 fts_psort_t * merge_info = NULL ;
33913419 ib_int64_t sig_count = 0 ;
3420+ bool fts_psort_initiated = false ;
33923421 DBUG_ENTER (" row_merge_build_indexes" );
33933422
33943423 ut_ad (!srv_read_only_mode);
@@ -3445,6 +3474,10 @@ row_merge_build_indexes(
34453474 row_fts_psort_info_init (
34463475 trx, dup, new_table, opt_doc_id_size,
34473476 &psort_info, &merge_info);
3477+
3478+ /* "We need to ensure that we free the resources
3479+ allocated */
3480+ fts_psort_initiated = true ;
34483481 }
34493482 }
34503483
@@ -3567,6 +3600,7 @@ row_merge_build_indexes(
35673600
35683601 if (indexes[i]->type & DICT_FTS) {
35693602 row_fts_psort_info_destroy (psort_info, merge_info);
3603+ fts_psort_initiated = false ;
35703604 } else if (error != DB_SUCCESS || !online) {
35713605 /* Do not apply any online log. */
35723606 } else if (old_table != new_table) {
@@ -3603,6 +3637,12 @@ row_merge_build_indexes(
36033637 error = DB_TOO_MANY_CONCURRENT_TRXS;
36043638 trx->error_state = error;);
36053639
3640+ if (fts_psort_initiated) {
3641+ /* Clean up FTS psort related resource */
3642+ row_fts_psort_info_destroy (psort_info, merge_info);
3643+ fts_psort_initiated = false ;
3644+ }
3645+
36063646 row_merge_file_destroy_low (tmpfd);
36073647
36083648 for (i = 0 ; i < n_indexes; i++) {
0 commit comments