Commit 704b39a1 authored by unknown's avatar unknown

- moving pagecache.h from include/ to storage/maria as it is Maria-

specific
- adding TRN::first_undo_lsn, needed to know when a log can be deleted;
this variable must be set under log's mutex and that leads to setting
TRN::rec_lsn, TRN::undo_lsn and TRN::first_undo_lsn in a
inwrite_rec_hook; adding implementation of one hook for REDOs and one
for UNDOs. Thus translog_write_record() always uses TRN and so does
not need a short_id argument, can find it from TRN.
- Monty's patch for the last Valgrind error in the tree.
- Log handler's unit tests fail but Sanja says it's known


include/Makefile.am:
  pagecache.h moved and renamed
include/maria.h:
  pagecache.h moved and renamed
sql/handler.h:
  pagecache.h moved and renamed
storage/maria/Makefile.am:
  pagecache.h moved and renamed
storage/maria/ha_maria.cc:
  adding an assertion which sounds logical
storage/maria/ma_blockrec.c:
  trn->rec_lsn and trn->undo_lsn are now set via hooks inside the log
  record's writing; this allows to also set trn->first_undo_lsn
  needed to compute the log's low-water mark.
  The PAGERANGE_STORE_SIZE -> PAGE_STORE_SIZE is Monty's fix to a
  Valgrind error.
storage/maria/ma_loghandler.c:
  "tcb" renamed to "trn". Log handler now knows what is a transaction,
  and finds short_id from trn. trn's rec_lsn, undo_lsn, first_undo_lsn
  are now set by some inwrite_rec_hookS (one for REDOs, one for UNDOs).
  The HAVE_purify blocks are Monty's fix to a Valgrind error.
storage/maria/ma_loghandler.h:
  Log handler functions use TRN, that needs a forward declaration
storage/maria/ma_pagecache.c:
  pagecache.h was moved and renamed
storage/maria/ma_pagecache.h:
  pagecache.h was moved and renamed
storage/maria/ma_pagecaches.c:
  pagecache.h was moved and renamed
storage/maria/trnman.c:
  initializing some members of TRN.
storage/maria/trnman.h:
  TRN::first_undo_lsn needed for log's low-water mark calculation
  (which will serve to know which logs can be deleted)
storage/maria/unittest/ma_test_loghandler-t.c:
  translog_write_record() now needs a valid TRN
storage/maria/unittest/ma_test_loghandler_multigroup-t.c:
  translog_write_record() now needs a valid TRN
storage/maria/unittest/ma_test_loghandler_multithread-t.c:
  translog_write_record() now needs a valid TRN
storage/maria/unittest/ma_test_loghandler_pagecache-t.c:
  translog_write_record() now needs a valid TRN
storage/maria/unittest/test_file.h:
  pagecache.h was moved and renamed
parent fdfb5148
...@@ -37,7 +37,7 @@ noinst_HEADERS = config-win.h config-netware.h lf.h my_bit.h \ ...@@ -37,7 +37,7 @@ noinst_HEADERS = config-win.h config-netware.h lf.h my_bit.h \
mysql_version.h.in my_handler.h my_time.h decimal.h \ mysql_version.h.in my_handler.h my_time.h decimal.h \
my_vle.h my_user.h my_atomic.h atomic/nolock.h \ my_vle.h my_user.h my_atomic.h atomic/nolock.h \
atomic/rwlock.h atomic/x86-gcc.h atomic/x86-msvc.h \ atomic/rwlock.h atomic/x86-gcc.h atomic/x86-msvc.h \
my_libwrap.h pagecache.h wqueue.h my_libwrap.h wqueue.h
# Remove built files and the symlinked directories # Remove built files and the symlinked directories
CLEANFILES = $(BUILT_SOURCES) readline openssl CLEANFILES = $(BUILT_SOURCES) readline openssl
......
...@@ -27,9 +27,7 @@ extern "C" { ...@@ -27,9 +27,7 @@ extern "C" {
#ifndef _m_ctype_h #ifndef _m_ctype_h
#include <m_ctype.h> #include <m_ctype.h>
#endif #endif
#ifndef _pagecache_h #include "../storage/maria/ma_pagecache.h"
#include "pagecache.h"
#endif
#include "my_handler.h" #include "my_handler.h"
#include "ft_global.h" #include "ft_global.h"
#include <myisamchk.h> #include <myisamchk.h>
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include <my_handler.h> #include <my_handler.h>
#include <ft_global.h> #include <ft_global.h>
#include <keycache.h> #include <keycache.h>
#include <pagecache.h> #include "../storage/maria/ma_pagecache.h"
#ifndef NO_HASH #ifndef NO_HASH
#define NO_HASH /* Not yet implemented */ #define NO_HASH /* Not yet implemented */
......
...@@ -54,7 +54,7 @@ noinst_HEADERS = maria_def.h ma_rt_index.h ma_rt_key.h ma_rt_mbr.h \ ...@@ -54,7 +54,7 @@ noinst_HEADERS = maria_def.h ma_rt_index.h ma_rt_key.h ma_rt_mbr.h \
ma_sp_defs.h ma_fulltext.h ma_ftdefs.h ma_ft_test1.h \ ma_sp_defs.h ma_fulltext.h ma_ftdefs.h ma_ft_test1.h \
ma_ft_eval.h trnman.h lockman.h tablockman.h \ ma_ft_eval.h trnman.h lockman.h tablockman.h \
ma_control_file.h ha_maria.h ma_blockrec.h \ ma_control_file.h ha_maria.h ma_blockrec.h \
ma_loghandler.h ma_loghandler_lsn.h ma_loghandler.h ma_loghandler_lsn.h ma_pagecache.h
ma_test1_DEPENDENCIES= $(LIBRARIES) ma_test1_DEPENDENCIES= $(LIBRARIES)
ma_test1_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmaria.a \ ma_test1_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmaria.a \
$(top_builddir)/storage/myisam/libmyisam.a \ $(top_builddir)/storage/myisam/libmyisam.a \
......
...@@ -1919,8 +1919,15 @@ int ha_maria::start_stmt(THD *thd, thr_lock_type lock_type) ...@@ -1919,8 +1919,15 @@ int ha_maria::start_stmt(THD *thd, thr_lock_type lock_type)
if (file->s->base.transactional) if (file->s->base.transactional)
{ {
DBUG_ASSERT(trn); // this may be called only after external_lock() DBUG_ASSERT(trn); // this may be called only after external_lock()
DBUG_ASSERT(trnman_has_locked_tables(trn));
DBUG_ASSERT(lock_type != F_UNLCK); DBUG_ASSERT(lock_type != F_UNLCK);
/* As external_lock() was already called, don't increment locked_tables */ /*
As external_lock() was already called, don't increment locked_tables.
Note that we call the function below possibly several times when
statement starts (once per table). This is ok as long as that function
does cheap operations. Otherwise, we will need to do it only on first
call to start_stmt().
*/
trnman_new_statement(trn); trnman_new_statement(trn);
} }
return 0; return 0;
......
...@@ -1141,12 +1141,9 @@ static my_bool write_tail(MARIA_HA *info, ...@@ -1141,12 +1141,9 @@ static my_bool write_tail(MARIA_HA *info,
log_array[TRANSLOG_INTERNAL_PARTS + 0].length= sizeof(log_data); log_array[TRANSLOG_INTERNAL_PARTS + 0].length= sizeof(log_data);
log_array[TRANSLOG_INTERNAL_PARTS + 1].str= (char*) row_pos.data; log_array[TRANSLOG_INTERNAL_PARTS + 1].str= (char*) row_pos.data;
log_array[TRANSLOG_INTERNAL_PARTS + 1].length= length; log_array[TRANSLOG_INTERNAL_PARTS + 1].length= length;
if (translog_write_record(!info->trn->rec_lsn ? &info->trn->rec_lsn : &lsn, if (translog_write_record(&lsn, LOGREC_REDO_INSERT_ROW_TAIL,
LOGREC_REDO_INSERT_ROW_TAIL, info->trn, share, sizeof(log_data) + length,
info->trn->short_id, NULL, share, TRANSLOG_INTERNAL_PARTS + 2, log_array))
sizeof(log_data) + length,
TRANSLOG_INTERNAL_PARTS + 2,
log_array))
DBUG_RETURN(1); DBUG_RETURN(1);
} }
...@@ -1398,10 +1395,8 @@ static my_bool free_full_pages(MARIA_HA *info, MARIA_ROW *row) ...@@ -1398,10 +1395,8 @@ static my_bool free_full_pages(MARIA_HA *info, MARIA_ROW *row)
log_array[TRANSLOG_INTERNAL_PARTS + 0].length= sizeof(log_data); log_array[TRANSLOG_INTERNAL_PARTS + 0].length= sizeof(log_data);
log_array[TRANSLOG_INTERNAL_PARTS + 1].str= row->extents; log_array[TRANSLOG_INTERNAL_PARTS + 1].str= row->extents;
log_array[TRANSLOG_INTERNAL_PARTS + 1].length= extents_length; log_array[TRANSLOG_INTERNAL_PARTS + 1].length= extents_length;
if (translog_write_record(!info->trn->rec_lsn ? &info->trn->rec_lsn : &lsn, if (translog_write_record(&lsn, LOGREC_REDO_PURGE_BLOCKS, info->trn,
LOGREC_REDO_PURGE_BLOCKS, info->s, sizeof(log_data) + extents_length,
info->trn->short_id, NULL, info->s,
sizeof(log_data) + extents_length,
TRANSLOG_INTERNAL_PARTS + 2, log_array)) TRANSLOG_INTERNAL_PARTS + 2, log_array))
DBUG_RETURN(1); DBUG_RETURN(1);
...@@ -1416,9 +1411,6 @@ static my_bool free_full_pages(MARIA_HA *info, MARIA_ROW *row) ...@@ -1416,9 +1411,6 @@ static my_bool free_full_pages(MARIA_HA *info, MARIA_ROW *row)
NOTES NOTES
This is very similar to free_full_pages() This is very similar to free_full_pages()
We don't have to update trn->rec_lsn here as before calling this function
we have already generated REDO's for deleting the HEAD block.
RETURN RETURN
0 ok 0 ok
1 error 1 error
...@@ -1449,8 +1441,7 @@ static my_bool free_full_page_range(MARIA_HA *info, ulonglong page, uint count) ...@@ -1449,8 +1441,7 @@ static my_bool free_full_page_range(MARIA_HA *info, ulonglong page, uint count)
log_array[TRANSLOG_INTERNAL_PARTS + 0].length= sizeof(log_data); log_array[TRANSLOG_INTERNAL_PARTS + 0].length= sizeof(log_data);
if (translog_write_record(&lsn, LOGREC_REDO_PURGE_BLOCKS, if (translog_write_record(&lsn, LOGREC_REDO_PURGE_BLOCKS,
info->trn->short_id, NULL, info->s, info->trn, info->s, sizeof(log_data),
sizeof(log_data),
TRANSLOG_INTERNAL_PARTS + 1, log_array)) TRANSLOG_INTERNAL_PARTS + 1, log_array))
res= 1; res= 1;
...@@ -1957,10 +1948,8 @@ static my_bool write_block_record(MARIA_HA *info, ...@@ -1957,10 +1948,8 @@ static my_bool write_block_record(MARIA_HA *info,
log_array[TRANSLOG_INTERNAL_PARTS + 0].length= sizeof(log_data); log_array[TRANSLOG_INTERNAL_PARTS + 0].length= sizeof(log_data);
log_array[TRANSLOG_INTERNAL_PARTS + 1].str= (char*) row_pos->data; log_array[TRANSLOG_INTERNAL_PARTS + 1].str= (char*) row_pos->data;
log_array[TRANSLOG_INTERNAL_PARTS + 1].length= data_length; log_array[TRANSLOG_INTERNAL_PARTS + 1].length= data_length;
if (translog_write_record(!info->trn->rec_lsn ? &info->trn->rec_lsn : &lsn, if (translog_write_record(&lsn, LOGREC_REDO_INSERT_ROW_HEAD, info->trn,
LOGREC_REDO_INSERT_ROW_HEAD, share, sizeof(log_data) + data_length,
info->trn->short_id, NULL, share,
sizeof(log_data) + data_length,
TRANSLOG_INTERNAL_PARTS + 2, log_array)) TRANSLOG_INTERNAL_PARTS + 2, log_array))
goto disk_err; goto disk_err;
} }
...@@ -2077,9 +2066,8 @@ static my_bool write_block_record(MARIA_HA *info, ...@@ -2077,9 +2066,8 @@ static my_bool write_block_record(MARIA_HA *info,
/* trn->rec_lsn is already set earlier in this function */ /* trn->rec_lsn is already set earlier in this function */
error= translog_write_record(&lsn, LOGREC_REDO_INSERT_ROW_BLOBS, error= translog_write_record(&lsn, LOGREC_REDO_INSERT_ROW_BLOBS,
info->trn->short_id, NULL, share, info->trn, share, log_entry_length,
log_entry_length, (uint) (log_array_pos - (uint) (log_array_pos - log_array),
log_array),
log_array); log_array);
if (log_array != tmp_log_array) if (log_array != tmp_log_array)
my_free((gptr) log_array, MYF(0)); my_free((gptr) log_array, MYF(0));
...@@ -2109,11 +2097,9 @@ static my_bool write_block_record(MARIA_HA *info, ...@@ -2109,11 +2097,9 @@ static my_bool write_block_record(MARIA_HA *info,
if (!old_record) if (!old_record)
{ {
/* Write UNDO log record for the INSERT */ /* Write UNDO log record for the INSERT */
if (translog_write_record(&info->trn->undo_lsn, LOGREC_UNDO_ROW_INSERT, if (translog_write_record(&lsn, LOGREC_UNDO_ROW_INSERT,
info->trn->short_id, NULL, share, info->trn, share, sizeof(log_data),
sizeof(log_data), TRANSLOG_INTERNAL_PARTS + 1, log_array))
TRANSLOG_INTERNAL_PARTS + 1,
log_array))
goto disk_err; goto disk_err;
} }
else else
...@@ -2125,9 +2111,8 @@ static my_bool write_block_record(MARIA_HA *info, ...@@ -2125,9 +2111,8 @@ static my_bool write_block_record(MARIA_HA *info,
info->log_row_parts + info->log_row_parts +
TRANSLOG_INTERNAL_PARTS + 1, TRANSLOG_INTERNAL_PARTS + 1,
&row_parts_count); &row_parts_count);
if (translog_write_record(&info->trn->undo_lsn, LOGREC_UNDO_ROW_UPDATE, if (translog_write_record(&lsn, LOGREC_UNDO_ROW_UPDATE, info->trn,
info->trn->short_id, NULL, share, share, sizeof(log_data) + row_length,
sizeof(log_data) + row_length,
TRANSLOG_INTERNAL_PARTS + 1 + row_parts_count, TRANSLOG_INTERNAL_PARTS + 1 + row_parts_count,
log_array)) log_array))
goto disk_err; goto disk_err;
...@@ -2293,6 +2278,7 @@ my_bool _ma_write_abort_block_record(MARIA_HA *info) ...@@ -2293,6 +2278,7 @@ my_bool _ma_write_abort_block_record(MARIA_HA *info)
if (info->s->base.transactional) if (info->s->base.transactional)
{ {
LSN lsn;
LEX_STRING log_array[TRANSLOG_INTERNAL_PARTS + 1]; LEX_STRING log_array[TRANSLOG_INTERNAL_PARTS + 1];
uchar log_data[LSN_STORE_SIZE]; uchar log_data[LSN_STORE_SIZE];
...@@ -2302,15 +2288,16 @@ my_bool _ma_write_abort_block_record(MARIA_HA *info) ...@@ -2302,15 +2288,16 @@ my_bool _ma_write_abort_block_record(MARIA_HA *info)
really undo a failed insert. Note that this UNDO will cause recover really undo a failed insert. Note that this UNDO will cause recover
to ignore the LOGREC_UNDO_ROW_INSERT that is the previous entry to ignore the LOGREC_UNDO_ROW_INSERT that is the previous entry
in the UNDO chain. in the UNDO chain.
We will soon change that: we will here execute the UNDO records
generated while we were trying to write the row; this will log some CLRs
which will replace this LOGREC_UNDO_PURGE. RECOVERY TODO BUG.
*/ */
lsn_store(log_data, info->trn->undo_lsn); lsn_store(log_data, info->trn->undo_lsn);
log_array[TRANSLOG_INTERNAL_PARTS + 0].str= (char*) log_data; log_array[TRANSLOG_INTERNAL_PARTS + 0].str= (char*) log_data;
log_array[TRANSLOG_INTERNAL_PARTS + 0].length= sizeof(log_data); log_array[TRANSLOG_INTERNAL_PARTS + 0].length= sizeof(log_data);
if (translog_write_record(&info->trn->undo_lsn, LOGREC_UNDO_ROW_PURGE, if (translog_write_record(&lsn, LOGREC_UNDO_ROW_PURGE,
info->trn->short_id, NULL, info->s, info->trn, info->s, sizeof(log_data),
sizeof(log_data), TRANSLOG_INTERNAL_PARTS + 1, log_array))
TRANSLOG_INTERNAL_PARTS + 1,
log_array))
res= 1; res= 1;
} }
_ma_unpin_all_pages(info, info->trn->undo_lsn); _ma_unpin_all_pages(info, info->trn->undo_lsn);
...@@ -2534,12 +2521,10 @@ static my_bool delete_head_or_tail(MARIA_HA *info, ...@@ -2534,12 +2521,10 @@ static my_bool delete_head_or_tail(MARIA_HA *info,
log_array[TRANSLOG_INTERNAL_PARTS + 0].str= (char*) log_data; log_array[TRANSLOG_INTERNAL_PARTS + 0].str= (char*) log_data;
log_array[TRANSLOG_INTERNAL_PARTS + 0].length= sizeof(log_data); log_array[TRANSLOG_INTERNAL_PARTS + 0].length= sizeof(log_data);
if (translog_write_record(!info->trn->rec_lsn ? &info->trn->rec_lsn : &lsn, if (translog_write_record(&lsn, (head ? LOGREC_REDO_PURGE_ROW_HEAD :
(head ? LOGREC_REDO_PURGE_ROW_HEAD : LOGREC_REDO_PURGE_ROW_TAIL),
LOGREC_REDO_PURGE_ROW_TAIL), info->trn, share, sizeof(log_data),
info->trn->short_id, NULL, share, TRANSLOG_INTERNAL_PARTS + 1, log_array))
sizeof(log_data), TRANSLOG_INTERNAL_PARTS + 1,
log_array))
DBUG_RETURN(1); DBUG_RETURN(1);
if (pagecache_write(share->pagecache, if (pagecache_write(share->pagecache,
&info->dfile, page, 0, &info->dfile, page, 0,
...@@ -2564,14 +2549,12 @@ static my_bool delete_head_or_tail(MARIA_HA *info, ...@@ -2564,14 +2549,12 @@ static my_bool delete_head_or_tail(MARIA_HA *info,
pagerange_store(log_data + FILEID_STORE_SIZE, 1); pagerange_store(log_data + FILEID_STORE_SIZE, 1);
page_store(log_data+ FILEID_STORE_SIZE + PAGERANGE_STORE_SIZE, page); page_store(log_data+ FILEID_STORE_SIZE + PAGERANGE_STORE_SIZE, page);
pagerange_store(log_data + FILEID_STORE_SIZE + PAGERANGE_STORE_SIZE + pagerange_store(log_data + FILEID_STORE_SIZE + PAGERANGE_STORE_SIZE +
PAGERANGE_STORE_SIZE, 1); PAGE_STORE_SIZE, 1);
log_array[TRANSLOG_INTERNAL_PARTS + 0].str= (char*) log_data; log_array[TRANSLOG_INTERNAL_PARTS + 0].str= (char*) log_data;
log_array[TRANSLOG_INTERNAL_PARTS + 0].length= sizeof(log_data); log_array[TRANSLOG_INTERNAL_PARTS + 0].length= sizeof(log_data);
if (translog_write_record(!info->trn->rec_lsn ? &info->trn->rec_lsn : &lsn, if (translog_write_record(&lsn, LOGREC_REDO_PURGE_BLOCKS,
LOGREC_REDO_PURGE_BLOCKS, info->trn, share, sizeof(log_data),
info->trn->short_id, NULL, share, TRANSLOG_INTERNAL_PARTS + 1, log_array))
sizeof(log_data), TRANSLOG_INTERNAL_PARTS + 1,
log_array))
DBUG_RETURN(1); DBUG_RETURN(1);
DBUG_ASSERT(empty_space >= info->s->bitmap.sizes[0]); DBUG_ASSERT(empty_space >= info->s->bitmap.sizes[0]);
} }
...@@ -2640,6 +2623,7 @@ my_bool _ma_delete_block_record(MARIA_HA *info, const byte *record) ...@@ -2640,6 +2623,7 @@ my_bool _ma_delete_block_record(MARIA_HA *info, const byte *record)
if (info->s->base.transactional) if (info->s->base.transactional)
{ {
LSN lsn;
uchar log_data[LSN_STORE_SIZE + FILEID_STORE_SIZE + PAGE_STORE_SIZE + uchar log_data[LSN_STORE_SIZE + FILEID_STORE_SIZE + PAGE_STORE_SIZE +
DIR_COUNT_SIZE]; DIR_COUNT_SIZE];
size_t row_length; size_t row_length;
...@@ -2658,9 +2642,8 @@ my_bool _ma_delete_block_record(MARIA_HA *info, const byte *record) ...@@ -2658,9 +2642,8 @@ my_bool _ma_delete_block_record(MARIA_HA *info, const byte *record)
TRANSLOG_INTERNAL_PARTS + 1, TRANSLOG_INTERNAL_PARTS + 1,
&row_parts_count); &row_parts_count);
if (translog_write_record(&info->trn->undo_lsn, LOGREC_UNDO_ROW_DELETE, if (translog_write_record(&lsn, LOGREC_UNDO_ROW_DELETE, info->trn,
info->trn->short_id, NULL, info->s, info->s, sizeof(log_data) + row_length,
sizeof(log_data) + row_length,
TRANSLOG_INTERNAL_PARTS + 1 + row_parts_count, TRANSLOG_INTERNAL_PARTS + 1 + row_parts_count,
info->log_row_parts)) info->log_row_parts))
goto err; goto err;
......
This diff is collapsed.
...@@ -180,6 +180,7 @@ struct st_translog_reader_data ...@@ -180,6 +180,7 @@ struct st_translog_reader_data
my_bool eor; /* end of the record */ my_bool eor; /* end of the record */
}; };
struct st_transaction;
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
...@@ -191,8 +192,8 @@ extern my_bool translog_init(const char *directory, uint32 log_file_max_size, ...@@ -191,8 +192,8 @@ extern my_bool translog_init(const char *directory, uint32 log_file_max_size,
extern my_bool translog_write_record(LSN *lsn, extern my_bool translog_write_record(LSN *lsn,
enum translog_record_type type, enum translog_record_type type,
SHORT_TRANSACTION_ID short_trid, struct st_transaction *trn,
void *tcb, struct st_maria_share *share, struct st_maria_share *share,
translog_size_t rec_len, translog_size_t rec_len,
uint part_no, uint part_no,
LEX_STRING *parts_data); LEX_STRING *parts_data);
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
#include "maria_def.h" #include "maria_def.h"
#include <m_string.h> #include <m_string.h>
#include <pagecache.h> #include "ma_pagecache.h"
#include <my_bit.h> #include <my_bit.h>
#include <errno.h> #include <errno.h>
#include <stdarg.h> #include <stdarg.h>
......
...@@ -16,11 +16,11 @@ ...@@ -16,11 +16,11 @@
/* Page cache variable structures */ /* Page cache variable structures */
#ifndef _pagecache_h #ifndef _ma_pagecache_h
#define _pagecache_h #define _ma_pagecache_h
C_MODE_START C_MODE_START
#include "../storage/maria/ma_loghandler_lsn.h" #include "ma_loghandler_lsn.h"
#include <m_string.h> #include <m_string.h>
/* Type of the page */ /* Type of the page */
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
*/ */
#include "maria_def.h" #include "maria_def.h"
#include <pagecache.h> #include "ma_pagecache.h"
#include <hash.h> #include <hash.h>
#include <m_string.h> #include <m_string.h>
#include "../../mysys/my_safehash.h" #include "../../mysys/my_safehash.h"
......
...@@ -298,7 +298,7 @@ TRN *trnman_new_trn(pthread_mutex_t *mutex, pthread_cond_t *cond, ...@@ -298,7 +298,7 @@ TRN *trnman_new_trn(pthread_mutex_t *mutex, pthread_cond_t *cond,
trn->min_read_from= trn->trid; trn->min_read_from= trn->trid;
trn->commit_trid= 0; trn->commit_trid= 0;
trn->undo_lsn= 0; trn->rec_lsn= trn->undo_lsn= trn->first_undo_lsn= 0;
trn->locks.mutex= mutex; trn->locks.mutex= mutex;
trn->locks.cond= cond; trn->locks.cond= cond;
......
...@@ -45,7 +45,7 @@ struct st_transaction ...@@ -45,7 +45,7 @@ struct st_transaction
LF_PINS *pins; LF_PINS *pins;
TrID trid, min_read_from, commit_trid; TrID trid, min_read_from, commit_trid;
TRN *next, *prev; TRN *next, *prev;
LSN rec_lsn, undo_lsn; LSN rec_lsn, undo_lsn, first_undo_lsn;
uint locked_tables; uint locked_tables;
/* Note! if locks.loid is 0, trn is NOT initialized */ /* Note! if locks.loid is 0, trn is NOT initialized */
}; };
......
...@@ -2,12 +2,14 @@ ...@@ -2,12 +2,14 @@
#include <stdio.h> #include <stdio.h>
#include <errno.h> #include <errno.h>
#include <tap.h> #include <tap.h>
#include "../trnman.h"
extern my_bool maria_log_remove(); extern my_bool maria_log_remove();
#ifndef DBUG_OFF #ifndef DBUG_OFF
static const char *default_dbug_option; static const char *default_dbug_option;
#endif #endif
static TRN *trn= &dummy_transaction_object;
#define PCACHE_SIZE (1024*1024*10) #define PCACHE_SIZE (1024*1024*10)
...@@ -166,9 +168,10 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -166,9 +168,10 @@ int main(int argc __attribute__((unused)), char *argv[])
int4store(long_tr_id, 0); int4store(long_tr_id, 0);
parts[TRANSLOG_INTERNAL_PARTS + 0].str= (char*)long_tr_id; parts[TRANSLOG_INTERNAL_PARTS + 0].str= (char*)long_tr_id;
parts[TRANSLOG_INTERNAL_PARTS + 0].length= 6; parts[TRANSLOG_INTERNAL_PARTS + 0].length= 6;
trn->short_id= 0;
if (translog_write_record(&lsn, if (translog_write_record(&lsn,
LOGREC_LONG_TRANSACTION_ID, LOGREC_LONG_TRANSACTION_ID,
0, NULL, NULL, trn, NULL,
6, TRANSLOG_INTERNAL_PARTS + 1, parts)) 6, TRANSLOG_INTERNAL_PARTS + 1, parts))
{ {
fprintf(stderr, "Can't write record #%lu\n", (ulong) 0); fprintf(stderr, "Can't write record #%lu\n", (ulong) 0);
...@@ -181,6 +184,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -181,6 +184,7 @@ int main(int argc __attribute__((unused)), char *argv[])
for (i= 1; i < ITERATIONS; i++) for (i= 1; i < ITERATIONS; i++)
{ {
trn->short_id= i % 0xFFFF;
if (i % 2) if (i % 2)
{ {
lsn_store(lsn_buff, lsn_base); lsn_store(lsn_buff, lsn_base);
...@@ -189,7 +193,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -189,7 +193,7 @@ int main(int argc __attribute__((unused)), char *argv[])
/* check auto-count feature */ /* check auto-count feature */
parts[TRANSLOG_INTERNAL_PARTS + 1].str= NULL; parts[TRANSLOG_INTERNAL_PARTS + 1].str= NULL;
parts[TRANSLOG_INTERNAL_PARTS + 1].length= 0; parts[TRANSLOG_INTERNAL_PARTS + 1].length= 0;
if (translog_write_record(&lsn, LOGREC_CLR_END, (i % 0xFFFF), NULL, if (translog_write_record(&lsn, LOGREC_CLR_END, trn,
NULL, LSN_STORE_SIZE, 0, parts)) NULL, LSN_STORE_SIZE, 0, parts))
{ {
fprintf(stderr, "1 Can't write reference defore record #%lu\n", fprintf(stderr, "1 Can't write reference defore record #%lu\n",
...@@ -209,8 +213,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -209,8 +213,7 @@ int main(int argc __attribute__((unused)), char *argv[])
/* check record length auto-counting */ /* check record length auto-counting */
if (translog_write_record(&lsn, if (translog_write_record(&lsn,
LOGREC_UNDO_KEY_INSERT, LOGREC_UNDO_KEY_INSERT,
(i % 0xFFFF), trn, NULL, 0, TRANSLOG_INTERNAL_PARTS + 2,
NULL, NULL, 0, TRANSLOG_INTERNAL_PARTS + 2,
parts)) parts))
{ {
fprintf(stderr, "1 Can't write var reference defore record #%lu\n", fprintf(stderr, "1 Can't write var reference defore record #%lu\n",
...@@ -229,7 +232,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -229,7 +232,7 @@ int main(int argc __attribute__((unused)), char *argv[])
parts[TRANSLOG_INTERNAL_PARTS + 0].length= 23; parts[TRANSLOG_INTERNAL_PARTS + 0].length= 23;
if (translog_write_record(&lsn, if (translog_write_record(&lsn,
LOGREC_UNDO_ROW_DELETE, LOGREC_UNDO_ROW_DELETE,
(i % 0xFFFF), NULL, NULL, trn, NULL,
23, TRANSLOG_INTERNAL_PARTS + 1, parts)) 23, TRANSLOG_INTERNAL_PARTS + 1, parts))
{ {
fprintf(stderr, "0 Can't write reference defore record #%lu\n", fprintf(stderr, "0 Can't write reference defore record #%lu\n",
...@@ -249,8 +252,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -249,8 +252,7 @@ int main(int argc __attribute__((unused)), char *argv[])
parts[TRANSLOG_INTERNAL_PARTS + 1].length= rec_len; parts[TRANSLOG_INTERNAL_PARTS + 1].length= rec_len;
if (translog_write_record(&lsn, if (translog_write_record(&lsn,
LOGREC_UNDO_KEY_DELETE, LOGREC_UNDO_KEY_DELETE,
(i % 0xFFFF), trn, NULL, 14 + rec_len,
NULL, NULL, 14 + rec_len,
TRANSLOG_INTERNAL_PARTS + 2, parts)) TRANSLOG_INTERNAL_PARTS + 2, parts))
{ {
fprintf(stderr, "0 Can't write var reference defore record #%lu\n", fprintf(stderr, "0 Can't write var reference defore record #%lu\n",
...@@ -266,7 +268,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -266,7 +268,7 @@ int main(int argc __attribute__((unused)), char *argv[])
parts[TRANSLOG_INTERNAL_PARTS + 0].length= 6; parts[TRANSLOG_INTERNAL_PARTS + 0].length= 6;
if (translog_write_record(&lsn, if (translog_write_record(&lsn,
LOGREC_LONG_TRANSACTION_ID, LOGREC_LONG_TRANSACTION_ID,
(i % 0xFFFF), NULL, NULL, 6, trn, NULL, 6,
TRANSLOG_INTERNAL_PARTS + 1, TRANSLOG_INTERNAL_PARTS + 1,
parts)) parts))
{ {
...@@ -285,7 +287,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -285,7 +287,7 @@ int main(int argc __attribute__((unused)), char *argv[])
parts[TRANSLOG_INTERNAL_PARTS + 0].length= rec_len; parts[TRANSLOG_INTERNAL_PARTS + 0].length= rec_len;
if (translog_write_record(&lsn, if (translog_write_record(&lsn,
LOGREC_REDO_INSERT_ROW_HEAD, LOGREC_REDO_INSERT_ROW_HEAD,
(i % 0xFFFF), NULL, NULL, rec_len, trn, NULL, rec_len,
TRANSLOG_INTERNAL_PARTS + 1, TRANSLOG_INTERNAL_PARTS + 1,
parts)) parts))
{ {
......
...@@ -2,12 +2,14 @@ ...@@ -2,12 +2,14 @@
#include <stdio.h> #include <stdio.h>
#include <errno.h> #include <errno.h>
#include <tap.h> #include <tap.h>
#include "../trnman.h"
extern my_bool maria_log_remove(); extern my_bool maria_log_remove();
#ifndef DBUG_OFF #ifndef DBUG_OFF
static const char *default_dbug_option; static const char *default_dbug_option;
#endif #endif
static TRN *trn= &dummy_transaction_object;
#define PCACHE_SIZE (1024*1024*10) #define PCACHE_SIZE (1024*1024*10)
...@@ -186,7 +188,8 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -186,7 +188,8 @@ int main(int argc __attribute__((unused)), char *argv[])
int4store(long_tr_id, 0); int4store(long_tr_id, 0);
parts[TRANSLOG_INTERNAL_PARTS + 0].str= (char*)long_tr_id; parts[TRANSLOG_INTERNAL_PARTS + 0].str= (char*)long_tr_id;
parts[TRANSLOG_INTERNAL_PARTS + 0].length= 6; parts[TRANSLOG_INTERNAL_PARTS + 0].length= 6;
if (translog_write_record(&lsn, LOGREC_LONG_TRANSACTION_ID, 0, NULL, NULL, trn->short_id= 0;
if (translog_write_record(&lsn, LOGREC_LONG_TRANSACTION_ID, trn, NULL,
6, TRANSLOG_INTERNAL_PARTS + 1, parts)) 6, TRANSLOG_INTERNAL_PARTS + 1, parts))
{ {
fprintf(stderr, "Can't write record #%lu\n", (ulong) 0); fprintf(stderr, "Can't write record #%lu\n", (ulong) 0);
...@@ -204,9 +207,10 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -204,9 +207,10 @@ int main(int argc __attribute__((unused)), char *argv[])
lsn_store(lsn_buff, lsn_base); lsn_store(lsn_buff, lsn_base);
parts[TRANSLOG_INTERNAL_PARTS + 0].str= (char*)lsn_buff; parts[TRANSLOG_INTERNAL_PARTS + 0].str= (char*)lsn_buff;
parts[TRANSLOG_INTERNAL_PARTS + 0].length= LSN_STORE_SIZE; parts[TRANSLOG_INTERNAL_PARTS + 0].length= LSN_STORE_SIZE;
trn->short_id= i % 0xFFFF;
if (translog_write_record(&lsn, if (translog_write_record(&lsn,
LOGREC_CLR_END, LOGREC_CLR_END,
(i % 0xFFFF), NULL, NULL, trn, NULL,
LSN_STORE_SIZE, LSN_STORE_SIZE,
TRANSLOG_INTERNAL_PARTS + 1, parts)) TRANSLOG_INTERNAL_PARTS + 1, parts))
{ {
...@@ -223,10 +227,10 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -223,10 +227,10 @@ int main(int argc __attribute__((unused)), char *argv[])
parts[TRANSLOG_INTERNAL_PARTS + 0].length= LSN_STORE_SIZE; parts[TRANSLOG_INTERNAL_PARTS + 0].length= LSN_STORE_SIZE;
parts[TRANSLOG_INTERNAL_PARTS + 1].str= (char*)long_buffer; parts[TRANSLOG_INTERNAL_PARTS + 1].str= (char*)long_buffer;
parts[TRANSLOG_INTERNAL_PARTS + 1].length= rec_len; parts[TRANSLOG_INTERNAL_PARTS + 1].length= rec_len;
trn->short_id= i % 0xFFFF;
if (translog_write_record(&lsn, if (translog_write_record(&lsn,
LOGREC_UNDO_KEY_INSERT, LOGREC_UNDO_KEY_INSERT,
(i % 0xFFFF), trn, NULL, LSN_STORE_SIZE + rec_len,
NULL, NULL, LSN_STORE_SIZE + rec_len,
TRANSLOG_INTERNAL_PARTS + 2, TRANSLOG_INTERNAL_PARTS + 2,
parts)) parts))
{ {
...@@ -244,9 +248,10 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -244,9 +248,10 @@ int main(int argc __attribute__((unused)), char *argv[])
lsn_store(lsn_buff + LSN_STORE_SIZE, first_lsn); lsn_store(lsn_buff + LSN_STORE_SIZE, first_lsn);
parts[TRANSLOG_INTERNAL_PARTS + 1].str= (char*)lsn_buff; parts[TRANSLOG_INTERNAL_PARTS + 1].str= (char*)lsn_buff;
parts[TRANSLOG_INTERNAL_PARTS + 1].length= 23; parts[TRANSLOG_INTERNAL_PARTS + 1].length= 23;
trn->short_id= i % 0xFFFF;
if (translog_write_record(&lsn, if (translog_write_record(&lsn,
LOGREC_UNDO_ROW_DELETE, LOGREC_UNDO_ROW_DELETE,
(i % 0xFFFF), NULL, NULL, 23, trn, NULL, 23,
TRANSLOG_INTERNAL_PARTS + 1, TRANSLOG_INTERNAL_PARTS + 1,
parts)) parts))
{ {
...@@ -264,10 +269,10 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -264,10 +269,10 @@ int main(int argc __attribute__((unused)), char *argv[])
parts[TRANSLOG_INTERNAL_PARTS + 0].length= LSN_STORE_SIZE * 2; parts[TRANSLOG_INTERNAL_PARTS + 0].length= LSN_STORE_SIZE * 2;
parts[TRANSLOG_INTERNAL_PARTS + 1].str= (char*)long_buffer; parts[TRANSLOG_INTERNAL_PARTS + 1].str= (char*)long_buffer;
parts[TRANSLOG_INTERNAL_PARTS + 1].length= rec_len; parts[TRANSLOG_INTERNAL_PARTS + 1].length= rec_len;
trn->short_id= i % 0xFFFF;
if (translog_write_record(&lsn, if (translog_write_record(&lsn,
LOGREC_UNDO_KEY_DELETE, LOGREC_UNDO_KEY_DELETE,
(i % 0xFFFF), trn, NULL, LSN_STORE_SIZE * 2 + rec_len,
NULL, NULL, LSN_STORE_SIZE * 2 + rec_len,
TRANSLOG_INTERNAL_PARTS + 2, TRANSLOG_INTERNAL_PARTS + 2,
parts)) parts))
{ {
...@@ -282,9 +287,10 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -282,9 +287,10 @@ int main(int argc __attribute__((unused)), char *argv[])
int4store(long_tr_id, i); int4store(long_tr_id, i);
parts[TRANSLOG_INTERNAL_PARTS + 0].str= (char*)long_tr_id; parts[TRANSLOG_INTERNAL_PARTS + 0].str= (char*)long_tr_id;
parts[TRANSLOG_INTERNAL_PARTS + 0].length= 6; parts[TRANSLOG_INTERNAL_PARTS + 0].length= 6;
trn->short_id= i % 0xFFFF;
if (translog_write_record(&lsn, if (translog_write_record(&lsn,
LOGREC_LONG_TRANSACTION_ID, LOGREC_LONG_TRANSACTION_ID,
(i % 0xFFFF), NULL, NULL, 6, trn, NULL, 6,
TRANSLOG_INTERNAL_PARTS + 1, parts)) TRANSLOG_INTERNAL_PARTS + 1, parts))
{ {
fprintf(stderr, "Can't write record #%lu\n", (ulong) i); fprintf(stderr, "Can't write record #%lu\n", (ulong) i);
...@@ -299,9 +305,10 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -299,9 +305,10 @@ int main(int argc __attribute__((unused)), char *argv[])
rec_len= get_len(); rec_len= get_len();
parts[TRANSLOG_INTERNAL_PARTS + 0].str= (char*)long_buffer; parts[TRANSLOG_INTERNAL_PARTS + 0].str= (char*)long_buffer;
parts[TRANSLOG_INTERNAL_PARTS + 0].length= rec_len; parts[TRANSLOG_INTERNAL_PARTS + 0].length= rec_len;
trn->short_id= i % 0xFFFF;
if (translog_write_record(&lsn, if (translog_write_record(&lsn,
LOGREC_REDO_INSERT_ROW_HEAD, LOGREC_REDO_INSERT_ROW_HEAD,
(i % 0xFFFF), NULL, NULL, rec_len, trn, NULL, rec_len,
TRANSLOG_INTERNAL_PARTS + 1, parts)) TRANSLOG_INTERNAL_PARTS + 1, parts))
{ {
fprintf(stderr, "Can't write variable record #%lu\n", (ulong) i); fprintf(stderr, "Can't write variable record #%lu\n", (ulong) i);
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
#include <stdio.h> #include <stdio.h>
#include <errno.h> #include <errno.h>
#include <tap.h> #include <tap.h>
#include "../trnman.h"
extern my_bool maria_log_remove(); extern my_bool maria_log_remove();
#ifndef DBUG_OFF #ifndef DBUG_OFF
...@@ -117,9 +119,11 @@ static my_bool read_and_check_content(TRANSLOG_HEADER_BUFFER *rec, ...@@ -117,9 +119,11 @@ static my_bool read_and_check_content(TRANSLOG_HEADER_BUFFER *rec,
void writer(int num) void writer(int num)
{ {
LSN lsn; LSN lsn;
TRN trn;
byte long_tr_id[6]; byte long_tr_id[6];
uint i; uint i;
trn.short_id= num;
for (i= 0; i < ITERATIONS; i++) for (i= 0; i < ITERATIONS; i++)
{ {
uint len= get_len(); uint len= get_len();
...@@ -132,7 +136,7 @@ void writer(int num) ...@@ -132,7 +136,7 @@ void writer(int num)
parts[TRANSLOG_INTERNAL_PARTS + 0].length= 6; parts[TRANSLOG_INTERNAL_PARTS + 0].length= 6;
if (translog_write_record(&lsn, if (translog_write_record(&lsn,
LOGREC_LONG_TRANSACTION_ID, LOGREC_LONG_TRANSACTION_ID,
num, NULL, NULL, 6, TRANSLOG_INTERNAL_PARTS + 1, &trn, NULL, 6, TRANSLOG_INTERNAL_PARTS + 1,
parts)) parts))
{ {
fprintf(stderr, "Can't write LOGREC_LONG_TRANSACTION_ID record #%lu " fprintf(stderr, "Can't write LOGREC_LONG_TRANSACTION_ID record #%lu "
...@@ -148,7 +152,7 @@ void writer(int num) ...@@ -148,7 +152,7 @@ void writer(int num)
parts[TRANSLOG_INTERNAL_PARTS + 0].length= len; parts[TRANSLOG_INTERNAL_PARTS + 0].length= len;
if (translog_write_record(&lsn, if (translog_write_record(&lsn,
LOGREC_REDO_INSERT_ROW_HEAD, LOGREC_REDO_INSERT_ROW_HEAD,
num, NULL, NULL, &trn, NULL,
len, TRANSLOG_INTERNAL_PARTS + 1, len, TRANSLOG_INTERNAL_PARTS + 1,
parts)) parts))
{ {
...@@ -296,7 +300,8 @@ int main(int argc __attribute__((unused)), ...@@ -296,7 +300,8 @@ int main(int argc __attribute__((unused)),
parts[TRANSLOG_INTERNAL_PARTS + 0].length= 6; parts[TRANSLOG_INTERNAL_PARTS + 0].length= 6;
if (translog_write_record(&first_lsn, if (translog_write_record(&first_lsn,
LOGREC_LONG_TRANSACTION_ID, LOGREC_LONG_TRANSACTION_ID,
0, NULL, NULL, 6, TRANSLOG_INTERNAL_PARTS + 1, &dummy_transaction_object, NULL, 6,
TRANSLOG_INTERNAL_PARTS + 1,
parts)) parts))
{ {
fprintf(stderr, "Can't write the first record\n"); fprintf(stderr, "Can't write the first record\n");
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#include <stdio.h> #include <stdio.h>
#include <errno.h> #include <errno.h>
#include <tap.h> #include <tap.h>
#include "../trnman.h"
extern my_bool maria_log_remove(); extern my_bool maria_log_remove();
...@@ -90,7 +91,8 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -90,7 +91,8 @@ int main(int argc __attribute__((unused)), char *argv[])
parts[TRANSLOG_INTERNAL_PARTS + 0].length= 6; parts[TRANSLOG_INTERNAL_PARTS + 0].length= 6;
if (translog_write_record(&lsn, if (translog_write_record(&lsn,
LOGREC_LONG_TRANSACTION_ID, LOGREC_LONG_TRANSACTION_ID,
0, NULL, NULL, 6, TRANSLOG_INTERNAL_PARTS + 1, &dummy_transaction_object, NULL, 6,
TRANSLOG_INTERNAL_PARTS + 1,
parts)) parts))
{ {
fprintf(stderr, "Can't write record #%lu\n", (ulong) 0); fprintf(stderr, "Can't write record #%lu\n", (ulong) 0);
......
#include <m_string.h> #include <m_string.h>
#include <pagecache.h> #include "../ma_pagecache.h"
/* /*
File content descriptor File content descriptor
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment