~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/fsp/fsp0fsp.c

Merge Stewart - Update innobase plugin to be based on innodb 1.1.4 from MySQL 5.5.8 

Show diffs side-by-side

added added

removed removed

Lines of Context:
3097
3097
 
3098
3098
        ut_ad(!mutex_own(&kernel_mutex));
3099
3099
 
 
3100
        /* The convoluted mutex acquire is to overcome latching order
 
3101
        issues: The problem is that the fil_mutex is at a lower level
 
3102
        than the tablespace latch and the buffer pool mutex. We have to
 
3103
        first prevent any operations on the file system by acquiring the
 
3104
        dictionary mutex. Then acquire the tablespace latch to obey the
 
3105
        latching order and then release the dictionary mutex. That way we
 
3106
        ensure that the tablespace instance can't be freed while we are
 
3107
        examining its contents (see fil_space_free()).
 
3108
 
 
3109
        However, there is one further complication, we release the fil_mutex
 
3110
        when we need to invalidate the the pages in the buffer pool and we
 
3111
        reacquire the fil_mutex when deleting and freeing the tablespace
 
3112
        instance in fil0fil.c. Here we need to account for that situation
 
3113
        too. */
 
3114
 
 
3115
        mutex_enter(&dict_sys->mutex);
 
3116
 
 
3117
        /* At this stage there is no guarantee that the tablespace even
 
3118
        exists in the cache. */
 
3119
 
 
3120
        if (fil_tablespace_deleted_or_being_deleted_in_mem(space, -1)) {
 
3121
 
 
3122
                mutex_exit(&dict_sys->mutex);
 
3123
 
 
3124
                return(ULLINT_UNDEFINED);
 
3125
        }
 
3126
 
3100
3127
        mtr_start(&mtr);
3101
3128
 
3102
3129
        latch = fil_space_get_latch(space, &flags);
 
3130
 
 
3131
        /* This should ensure that the tablespace instance can't be freed
 
3132
        by another thread. However, the tablespace pages can still be freed
 
3133
        from the buffer pool. We need to check for that again. */
 
3134
 
3103
3135
        zip_size = dict_table_flags_to_zip_size(flags);
3104
3136
 
3105
3137
        mtr_x_lock(latch, &mtr);
3106
3138
 
 
3139
        mutex_exit(&dict_sys->mutex);
 
3140
 
 
3141
        /* At this point it is possible for the tablespace to be deleted and
 
3142
        its pages removed from the buffer pool. We need to check for that
 
3143
        situation. However, the tablespace instance can't be deleted because
 
3144
        our latching above should ensure that. */
 
3145
 
 
3146
        if (fil_tablespace_is_being_deleted(space)) {
 
3147
 
 
3148
                mtr_commit(&mtr);
 
3149
 
 
3150
                return(ULLINT_UNDEFINED);
 
3151
        }
 
3152
 
 
3153
        /* From here on even if the user has dropped the tablespace, the
 
3154
        pages _must_ still exist in the buffer pool and the tablespace
 
3155
        instance _must_ be in the file system hash table. */
 
3156
 
3107
3157
        space_header = fsp_get_space_header(space, zip_size, &mtr);
3108
3158
 
3109
3159
        size = mtr_read_ulint(space_header + FSP_SIZE, MLOG_4BYTES, &mtr);