~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/buf/buf0flu.c

  • Committer: Stewart Smith
  • Author(s): Marko Mäkelä, Stewart Smith
  • Date: 2010-12-17 04:05:47 UTC
  • mto: (2021.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 2022.
  • Revision ID: stewart@flamingspork.com-20101217040547-vxdivnnqnp62xfqi
Merge Revision revid:marko.makela@oracle.com-20101019060415-bj3u6ewk022mk4nr from MySQL InnoDB

Original revid:marko.makela@oracle.com-20101019060415-bj3u6ewk022mk4nr

Original Authors: Marko Mkel <marko.makela@oracle.com>
Original commit message:
Bug #56680 wrong InnoDB results from a case-insensitive covering index

row_search_for_mysql(): When a secondary index record might not be
visible in the current transaction's read view and we consult the
clustered index and optionally some undo log records, return the
relevant columns of the clustered index record to MySQL instead of the
secondary index record.

ibuf_insert_to_index_page_low(): New function, refactored from
ibuf_insert_to_index_page().

ibuf_insert_to_index_page(): When we are inserting a record in place
of a delete-marked record and some fields of the record differ, update
that record just like row_ins_sec_index_entry_by_modify() would do.

btr_cur_update_alloc_zip(): Make the function public.

mysql_row_templ_t: Add clust_rec_field_no.

row_sel_store_mysql_rec(), row_sel_push_cache_row_for_mysql(): Add the
flag rec_clust, for returning data at clust_rec_field_no instead of
rec_field_no. Resurrect the debug assertion that the record not be
marked for deletion. (Bug #55626)

[UNIV_DEBUG || UNIV_IBUF_DEBUG] ibuf_debug, buf_page_get_gen(),
buf_flush_page_try():
Implement innodb_change_buffering_debug=1 for evicting pages from the
buffer pool, so that change buffering will be attempted more
frequently.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1152
1152
        }
1153
1153
}
1154
1154
 
 
1155
# if defined UNIV_DEBUG || defined UNIV_IBUF_DEBUG
 
1156
/********************************************************************//**
 
1157
Writes a flushable page asynchronously from the buffer pool to a file.
 
1158
NOTE: buf_pool_mutex and block->mutex must be held upon entering this
 
1159
function, and they will be released by this function after flushing.
 
1160
This is loosely based on buf_flush_batch() and buf_flush_page().
 
1161
@return TRUE if the page was flushed and the mutexes released */
 
1162
UNIV_INTERN
 
1163
ibool
 
1164
buf_flush_page_try(
 
1165
/*===============*/
 
1166
        buf_pool_t*     buf_pool,       /*!< in/out: buffer pool instance */
 
1167
        buf_block_t*    block)          /*!< in/out: buffer control block */
 
1168
{
 
1169
        ut_ad(buf_pool_mutex_own(buf_pool));
 
1170
        ut_ad(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
 
1171
        ut_ad(mutex_own(&block->mutex));
 
1172
 
 
1173
        if (!buf_flush_ready_for_flush(&block->page, BUF_FLUSH_LRU)) {
 
1174
                return(FALSE);
 
1175
        }
 
1176
 
 
1177
        if (buf_pool->n_flush[BUF_FLUSH_LRU] > 0
 
1178
            || buf_pool->init_flush[BUF_FLUSH_LRU]) {
 
1179
                /* There is already a flush batch of the same type running */
 
1180
                return(FALSE);
 
1181
        }
 
1182
 
 
1183
        buf_pool->init_flush[BUF_FLUSH_LRU] = TRUE;
 
1184
 
 
1185
        buf_page_set_io_fix(&block->page, BUF_IO_WRITE);
 
1186
 
 
1187
        buf_page_set_flush_type(&block->page, BUF_FLUSH_LRU);
 
1188
 
 
1189
        if (buf_pool->n_flush[BUF_FLUSH_LRU]++ == 0) {
 
1190
 
 
1191
                os_event_reset(buf_pool->no_flush[BUF_FLUSH_LRU]);
 
1192
        }
 
1193
 
 
1194
        /* VERY IMPORTANT:
 
1195
        Because any thread may call the LRU flush, even when owning
 
1196
        locks on pages, to avoid deadlocks, we must make sure that the
 
1197
        s-lock is acquired on the page without waiting: this is
 
1198
        accomplished because buf_flush_ready_for_flush() must hold,
 
1199
        and that requires the page not to be bufferfixed. */
 
1200
 
 
1201
        rw_lock_s_lock_gen(&block->lock, BUF_IO_WRITE);
 
1202
 
 
1203
        /* Note that the s-latch is acquired before releasing the
 
1204
        buf_pool mutex: this ensures that the latch is acquired
 
1205
        immediately. */
 
1206
 
 
1207
        mutex_exit(&block->mutex);
 
1208
        buf_pool_mutex_exit(buf_pool);
 
1209
 
 
1210
        /* Even though block is not protected by any mutex at this
 
1211
        point, it is safe to access block, because it is io_fixed and
 
1212
        oldest_modification != 0.  Thus, it cannot be relocated in the
 
1213
        buffer pool or removed from flush_list or LRU_list. */
 
1214
 
 
1215
        buf_flush_write_block_low(&block->page);
 
1216
 
 
1217
        buf_pool_mutex_enter(buf_pool);
 
1218
        buf_pool->init_flush[BUF_FLUSH_LRU] = FALSE;
 
1219
 
 
1220
        if (buf_pool->n_flush[BUF_FLUSH_LRU] == 0) {
 
1221
                /* The running flush batch has ended */
 
1222
                os_event_set(buf_pool->no_flush[BUF_FLUSH_LRU]);
 
1223
        }
 
1224
 
 
1225
        buf_pool_mutex_exit(buf_pool);
 
1226
        buf_flush_buffered_writes();
 
1227
 
 
1228
        return(TRUE);
 
1229
}
 
1230
# endif /* UNIV_DEBUG || UNIV_IBUF_DEBUG */
 
1231
 
1155
1232
/********************************************************************//**
1156
1233
Writes a flushable page asynchronously from the buffer pool to a file.
1157
1234
NOTE: in simulated aio we must call