Friday, February 11, 2011

This happens when you don't have a condition variable

Did Windows NT not have condition variables? This might be an artifact of that. It shows what happens when you don't have a condition variable.

stop_ibuf_merges:

        mutex_enter(&fil_system->mutex);

        space = fil_space_get_by_id(id);

        if (space != NULL) {
                space->stop_ibuf_merges = TRUE;

                if (space->n_pending_ibuf_merges == 0) {
                        mutex_exit(&fil_system->mutex);
                        count = 0;
                        goto try_again;
                } else {
                        if (count > 5000) {
                                ut_print_timestamp(stderr);
                                fputs("  InnoDB: trying to delete tablespace ", stderr);
                                ut_print_filename(stderr, space->name);
                        }

                        mutex_exit(&fil_system->mutex);

                        os_thread_sleep(20000);
                        count++;

                        goto stop_ibuf_merges;
                }

2 comments:

  1. Windows has condition variables now. 5 years ago, prior to Vista there was no builtin conditions. Instead Windows had events , which is another abstraction to handle interthread communication.

    One can combine events and critical sections to emulate a condition variable. It is present in MySQL sources in mysys/wincond.c (in 5.5, it is called "legacy" implementation, and left here for XP compatibility). The legacy implementation seems to borrow from this paper http://www.cs.wustl.edu/~schmidt/win32-cv-1.html

    Or, one can also emulate Windows event with a condition variable and mutex(like innodb events).

    ReplyDelete
  2. where is "try_again"?

    ReplyDelete

 
Creative Commons License
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.