Comment 15 for bug 1438516

Revision history for this message
Pavel Boldin (pboldin) wrote :

OK, so the problem is the code re-inventing the `os_(inc|dec)_counter' calls, that is writing:

                        if (foreign->referenced_table) {
                                mutex_enter(&(dict_sys->mutex));

                                (foreign->referenced_table
                                 ->n_foreign_key_checks_running)++;

                                mutex_exit(&(dict_sys->mutex));
                        }

instead of:

                        if (foreign->referenced_table) {
                                os_inc_counter(dict_sys->mutex,
                                               foreign->referenced_table
                                               ->n_foreign_key_checks_running);
                        }

The difference is the latter providing an atomic update while first is not.

Furthermore, `os_inc_counter' is implemented as an atomic in our version (HAVE_ATOMIC_BUILTINS is defined) and is not using `mutex'es at all.

The proposed fix is to use `os_inc_counter'/`os_dec_counter' pair instead.