34
34
Sets the global variable log_fsp_current_free_limit. Also makes a checkpoint,
35
35
so that we know that the limit has been written to a log checkpoint field
39
39
log_fsp_current_free_limit_set_and_checkpoint(
40
40
/*==========================================*/
41
41
ulint limit); /* in: limit to set */
42
42
/***********************************************************************
43
43
Calculates where in log files we find a specified lsn. */
46
46
log_calc_where_lsn_is(
47
47
/*==================*/
48
48
/* out: log file number */
49
ib_longlong* log_file_offset, /* out: offset in that file
49
ib_int64_t* log_file_offset, /* out: offset in that file
50
50
(including the header) */
51
dulint first_header_lsn, /* in: first log file start
51
ib_uint64_t first_header_lsn, /* in: first log file start
53
dulint lsn, /* in: lsn whose position to
53
ib_uint64_t lsn, /* in: lsn whose position to
55
55
ulint n_log_files, /* in: total number of log
57
ib_longlong log_file_size); /* in: log file size
57
ib_int64_t log_file_size); /* in: log file size
58
58
(including the header) */
59
59
/****************************************************************
60
60
Writes to the log the string given. The log must be released with
64
64
log_reserve_and_write_fast(
65
65
/*=======================*/
66
/* out: end lsn of the log record, ut_dulint_zero if
68
byte* str, /* in: string */
69
ulint len, /* in: string length */
70
dulint* start_lsn,/* out: start lsn of the log record */
71
ibool* success);/* out: TRUE if success */
66
/* out: end lsn of the log record,
67
zero if did not succeed */
68
byte* str, /* in: string */
69
ulint len, /* in: string length */
70
ib_uint64_t* start_lsn,/* out: start lsn of the log record */
71
ibool* success);/* out: TRUE if success */
72
72
/***************************************************************************
73
73
Releases the log mutex. */
104
104
ulint str_len); /* in: string length */
105
105
/****************************************************************
106
106
Closes the log. */
112
112
/****************************************************************
113
113
Gets the current lsn. */
116
116
log_get_lsn(void);
117
117
/*=============*/
118
118
/* out: current lsn */
119
119
/**********************************************************
120
120
Initializes the log. */
125
125
/**********************************************************************
126
126
Inits a log group to the log system. */
151
151
that the log has been written to the log file up to the last log entry written
152
152
by the transaction. If there is a flush running, it waits and checks if the
153
153
flush flushed enough. If not, starts a new flush. */
158
dulint lsn, /* in: log sequence number up to which the log should
159
be written, ut_dulint_max if not specified */
160
ulint wait, /* in: LOG_NO_WAIT, LOG_WAIT_ONE_GROUP,
161
or LOG_WAIT_ALL_GROUPS */
162
ibool flush_to_disk);
163
/* in: TRUE if we want the written log also to be
158
ib_uint64_t lsn, /* in: log sequence number up to which
159
the log should be written,
160
IB_ULONGLONG_MAX if not specified */
161
ulint wait, /* in: LOG_NO_WAIT, LOG_WAIT_ONE_GROUP,
162
or LOG_WAIT_ALL_GROUPS */
163
ibool flush_to_disk);
164
/* in: TRUE if we want the written log
165
also to be flushed to disk */
165
166
/********************************************************************
166
167
Does a syncronous flush of the log buffer to disk. */
169
170
log_buffer_flush_to_disk(void);
170
171
/*==========================*/
172
173
Advances the smallest lsn for which there are unflushed dirty blocks in the
173
174
buffer pool and also may make a new checkpoint. NOTE: this function may only
174
175
be called if the calling thread owns no synchronization objects! */
177
178
log_preflush_pool_modified_pages(
178
179
/*=============================*/
179
/* out: FALSE if there was a flush batch of
180
the same type running, which means that we
181
could not start this flush batch */
182
dulint new_oldest, /* in: try to advance oldest_modified_lsn
183
at least to this lsn */
184
ibool sync); /* in: TRUE if synchronous operation is
180
/* out: FALSE if there was a
181
flush batch of the same type
182
running, which means that we
183
could not start this flush
185
ib_uint64_t new_oldest, /* in: try to advance
186
oldest_modified_lsn at least
188
ibool sync); /* in: TRUE if synchronous
189
operation is desired */
186
190
/**********************************************************
187
191
Makes a checkpoint. Note that this function does not flush dirty
188
192
blocks from the buffer pool: it only checks what is lsn of the oldest
189
193
modification in the pool, and writes information about the lsn in
190
194
log files. Use log_make_checkpoint_at to flush also the pool. */
204
208
made to log files */
205
209
/********************************************************************
206
210
Makes a checkpoint at a given lsn or later. */
209
213
log_make_checkpoint_at(
210
214
/*===================*/
211
dulint lsn, /* in: make a checkpoint at this or a later
212
lsn, if ut_dulint_max, makes a checkpoint at
214
ibool write_always); /* in: the function normally checks if the
215
the new checkpoint would have a greater
216
lsn than the previous one: if not, then no
217
physical write is done; by setting this
218
parameter TRUE, a physical write will always be
215
ib_uint64_t lsn, /* in: make a checkpoint at this or a
216
later lsn, if IB_ULONGLONG_MAX, makes
217
a checkpoint at the latest lsn */
218
ibool write_always); /* in: the function normally checks if
219
the the new checkpoint would have a
220
greater lsn than the previous one: if
221
not, then no physical write is done;
222
by setting this parameter TRUE, a
223
physical write will always be made to
220
225
/********************************************************************
221
226
Makes a checkpoint at the latest lsn and writes it to first page of each
222
227
data file in the database, so that we know that the file spaces contain
223
228
all modifications up to that lsn. This can only be called at database
224
229
shutdown. This function also writes all log in log files to the log archive. */
227
232
logs_empty_and_mark_files_at_shutdown(void);
228
233
/*=======================================*/
229
234
/**********************************************************
230
235
Reads a checkpoint info from a log group header to log_sys->checkpoint_buf. */
233
238
log_group_read_checkpoint_info(
234
239
/*===========================*/
246
251
ulint* offset);/* out: archived file offset */
247
252
/**********************************************************
248
253
Writes checkpoint info to groups. */
251
256
log_groups_write_checkpoint_info(void);
252
257
/*==================================*/
253
258
/**********************************************************
254
259
Writes info to a buffer of a log group when log files are created in
255
260
backup restoration. */
258
263
log_reset_first_header_and_checkpoint(
259
264
/*==================================*/
260
byte* hdr_buf,/* in: buffer which will be written to the start
261
of the first log file */
262
dulint start); /* in: lsn of the start of the first log file;
263
we pretend that there is a checkpoint at
264
start + LOG_BLOCK_HDR_SIZE */
265
byte* hdr_buf,/* in: buffer which will be written to the
266
start of the first log file */
267
ib_uint64_t start); /* in: lsn of the start of the first log file;
268
we pretend that there is a checkpoint at
269
start + LOG_BLOCK_HDR_SIZE */
265
270
/************************************************************************
266
271
Starts an archiving operation. */
279
284
log file numbers start from a number one higher, so that the archiving will
280
285
not write again to the archived log files which exist when this function
284
289
log_archive_stop(void);
285
290
/*==================*/
286
291
/* out: DB_SUCCESS or DB_ERROR */
287
292
/********************************************************************
288
293
Starts again archiving which has been stopped. */
291
296
log_archive_start(void);
292
297
/*===================*/
293
298
/* out: DB_SUCCESS or DB_ERROR */
294
299
/********************************************************************
295
300
Stop archiving the log so that a gap may occur in the archived log files. */
298
303
log_archive_noarchivelog(void);
299
304
/*==========================*/
300
305
/* out: DB_SUCCESS or DB_ERROR */
301
306
/********************************************************************
302
307
Start archiving the log so that a gap may occur in the archived log files. */
305
310
log_archive_archivelog(void);
306
311
/*========================*/
307
312
/* out: DB_SUCCESS or DB_ERROR */
308
313
/**********************************************************
309
314
Generates an archived log file name. */
312
317
log_archived_file_name_gen(
313
318
/*=======================*/
319
324
Flushes the log buffer or makes a new checkpoint if necessary. NOTE: this
320
325
function may only be called if the calling thread owns no synchronization
324
329
log_check_margins(void);
325
330
/*===================*/
326
331
/**********************************************************
327
332
Reads a specified log segment to a buffer. */
330
335
log_group_read_log_seg(
331
336
/*===================*/
332
337
ulint type, /* in: LOG_ARCHIVE or LOG_RECOVER */
333
338
byte* buf, /* in: buffer where to read */
334
339
log_group_t* group, /* in: log group */
335
dulint start_lsn, /* in: read area start */
336
dulint end_lsn); /* in: read area end */
340
ib_uint64_t start_lsn, /* in: read area start */
341
ib_uint64_t end_lsn); /* in: read area end */
337
342
/**********************************************************
338
343
Writes a buffer to a log file group. */
341
346
log_group_write_buf(
342
347
/*================*/
344
349
byte* buf, /* in: buffer */
345
350
ulint len, /* in: buffer len; must be divisible
346
351
by OS_FILE_LOG_BLOCK_SIZE */
347
dulint start_lsn, /* in: start lsn of the buffer; must
352
ib_uint64_t start_lsn, /* in: start lsn of the buffer; must
349
354
OS_FILE_LOG_BLOCK_SIZE */
350
355
ulint new_data_offset);/* in: start offset of new data in
355
360
Sets the field values in group to correspond to a given lsn. For this function
356
361
to work, the values must already be correctly initialized to correspond to
357
362
some lsn, for instance, a checkpoint lsn. */
360
365
log_group_set_fields(
361
366
/*=================*/
362
367
log_group_t* group, /* in: group */
363
dulint lsn); /* in: lsn for which the values should be
368
ib_uint64_t lsn); /* in: lsn for which the values should be
365
370
/**********************************************************
366
371
Calculates the data capacity of a log group, when the log file headers are not
370
375
log_group_get_capacity(
371
376
/*===================*/
413
418
log_block_calc_checksum(
414
419
/*====================*/
416
byte* block); /* in: log block */
421
const byte* block); /* in: log block */
417
422
/****************************************************************
418
423
Gets a log block checksum field value. */
421
426
log_block_get_checksum(
422
427
/*===================*/
424
byte* log_block); /* in: log block */
429
const byte* log_block); /* in: log block */
425
430
/****************************************************************
426
431
Sets a log block checksum field value. */
464
byte* log_block, /* in: pointer to the log buffer */
465
dulint lsn); /* in: lsn within the log block */
469
byte* log_block, /* in: pointer to the log buffer */
470
ib_uint64_t lsn); /* in: lsn within the log block */
466
471
/****************************************************************
467
472
Initializes a log block in the log buffer in the old, < 3.23.52 format, where
468
473
there was no checksum yet. */
471
476
log_block_init_in_old_format(
472
477
/*=========================*/
473
byte* log_block, /* in: pointer to the log buffer */
474
dulint lsn); /* in: lsn within the log block */
478
byte* log_block, /* in: pointer to the log buffer */
479
ib_uint64_t lsn); /* in: lsn within the log block */
475
480
/****************************************************************
476
481
Converts a lsn to a log block number. */
479
484
log_block_convert_lsn_to_no(
480
485
/*========================*/
481
/* out: log block number, it is > 0 and <= 1G */
482
dulint lsn); /* in: lsn of a byte within the block */
486
/* out: log block number,
487
it is > 0 and <= 1G */
488
ib_uint64_t lsn); /* in: lsn of a byte within the block */
483
489
/**********************************************************
484
490
Prints info of the log. */
489
495
FILE* file); /* in: file where to print */
490
496
/**********************************************************
491
497
Peeks the current lsn. */
496
/* out: TRUE if success, FALSE if could not get the
498
dulint* lsn); /* out: if returns TRUE, current lsn is here */
502
/* out: TRUE if success, FALSE if
503
could not get the log system mutex */
504
ib_uint64_t* lsn); /* out: if returns TRUE, current lsn is here */
499
505
/**************************************************************************
500
506
Refreshes the statistics used to print per-second averages. */
503
509
log_refresh_stats(void);
504
510
/*===================*/
512
518
#define LOG_RECOVER 98887331
514
520
/* The counting of lsn's starts from this value: this must be non-zero */
515
#define LOG_START_LSN ut_dulint_create(0, 16 * OS_FILE_LOG_BLOCK_SIZE)
521
#define LOG_START_LSN ((ib_uint64_t) (16 * OS_FILE_LOG_BLOCK_SIZE))
517
523
#define LOG_BUFFER_SIZE (srv_log_buffer_size * UNIV_PAGE_SIZE)
518
524
#define LOG_ARCHIVE_BUF_SIZE (srv_log_buffer_size * UNIV_PAGE_SIZE / 4)
671
677
value to ..._file_no */
672
678
ulint next_archived_offset; /* like the preceding field */
673
679
/*-----------------------------*/
674
dulint scanned_lsn; /* used only in recovery: recovery scan
680
ib_uint64_t scanned_lsn; /* used only in recovery: recovery scan
675
681
succeeded up to this lsn in this log
677
683
byte* checkpoint_buf; /* checkpoint header is written from
684
690
byte pad[64]; /* padding to prevent other memory
685
691
update hotspots from residing on the
686
692
same memory cache line */
687
dulint lsn; /* log sequence number */
693
ib_uint64_t lsn; /* log sequence number */
688
694
ulint buf_free; /* first free offset within the log
690
696
mutex_t mutex; /* mutex protecting the log */
696
702
ulint old_buf_free; /* value of buf free when log was
697
703
last time opened; only in the debug
699
dulint old_lsn; /* value of lsn when log was last time
705
ib_uint64_t old_lsn; /* value of lsn when log was last time
700
706
opened; only in the debug version */
701
707
ibool check_flush_or_checkpoint;
702
708
/* this is set to TRUE when there may
719
725
later; this is advanced when a flush
720
726
operation is completed to all the log
722
dulint written_to_some_lsn;
728
ib_uint64_t written_to_some_lsn;
723
729
/* first log sequence number not yet
724
730
written to any log group; for this to
725
731
be advanced, it is enough that the
726
732
write i/o has been completed for any
728
dulint written_to_all_lsn;
734
ib_uint64_t written_to_all_lsn;
729
735
/* first log sequence number not yet
730
736
written to some log group; for this to
731
737
be advanced, it is enough that the
732
738
write i/o has been completed for all
734
dulint write_lsn; /* end lsn for the current running
740
ib_uint64_t write_lsn; /* end lsn for the current running
736
742
ulint write_end_offset;/* the data in buffer has been written
737
743
up to this offset when the current
738
744
write ends: this field will then
739
745
be copied to buf_next_to_write */
740
dulint current_flush_lsn;/* end lsn for the current running
746
ib_uint64_t current_flush_lsn;/* end lsn for the current running
741
747
write + flush operation */
742
dulint flushed_to_disk_lsn;
748
ib_uint64_t flushed_to_disk_lsn;
743
749
/* how far we have written the log
744
750
AND flushed to disk */
745
751
ulint n_pending_writes;/* number of currently pending flushes
802
808
/* this is the maximum allowed value
803
809
for lsn - last_checkpoint_lsn when a
804
810
new query step is started */
805
dulint next_checkpoint_no;
811
ib_uint64_t next_checkpoint_no;
806
812
/* next checkpoint number */
807
dulint last_checkpoint_lsn;
813
ib_uint64_t last_checkpoint_lsn;
808
814
/* latest checkpoint lsn */
809
dulint next_checkpoint_lsn;
815
ib_uint64_t next_checkpoint_lsn;
810
816
/* next checkpoint lsn */
811
817
ulint n_pending_checkpoint_writes;
812
818
/* number of currently pending
818
824
byte* checkpoint_buf; /* checkpoint header is read to this
826
#ifdef UNIV_LOG_ARCHIVE
820
827
/* Fields involved in archiving */
821
828
ulint archiving_state;/* LOG_ARCH_ON, LOG_ARCH_STOPPING
822
829
LOG_ARCH_STOPPED, LOG_ARCH_OFF */
823
dulint archived_lsn; /* archiving has advanced to this
830
ib_uint64_t archived_lsn; /* archiving has advanced to this
825
832
ulint max_archived_lsn_age_async;
826
833
/* recommended maximum age of
829
836
ulint max_archived_lsn_age;
830
837
/* maximum allowed age for
832
dulint next_archived_lsn;/* during an archive write,
839
ib_uint64_t next_archived_lsn;/* during an archive write,
833
840
until the write is completed, we
834
841
store the next value for
835
842
archived_lsn here: the write