summaryrefslogtreecommitdiff
path: root/storage
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2019-09-04 01:59:35 +0300
committerMonty <monty@mariadb.org>2019-09-04 10:09:46 +0300
commit01e455dbb875e077b04eb6ac231714fac8319787 (patch)
tree052625684acaba3e921b13dc8b419e46cc368122 /storage
parentdae1b3b04c839b25233700c7ff7def578c545508 (diff)
downloadmariadb-git-01e455dbb875e077b04eb6ac231714fac8319787.tar.gz
Fix of query cache bug in Aria
MDEV-5817 query cache bug (returning inconsistent/old result set) with aria table parallel inserts, row format = page The problem is that for transactional aria tables (row_type=PAGE and transactional=1), maria_lock_database() didn't flush the state or the query cache. Not flushing the state is correct for transactional tables as this is done by checkpoint, but not flushing the query cache was wrong and could cause concurrent SELECT queries to not be deleted from the cache. Fixed by introducing a flush of the query cache as part of commit, if the table has changed. t for transactional aria tables (row_type=PAGE and transactional=1), maria_lock_table() didn't flush their state or the query cache.
Diffstat (limited to 'storage')
-rw-r--r--storage/maria/ha_maria.cc21
-rw-r--r--storage/maria/maria_def.h1
2 files changed, 20 insertions, 2 deletions
diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc
index 51839aa5ff4..e82c76fd938 100644
--- a/storage/maria/ha_maria.cc
+++ b/storage/maria/ha_maria.cc
@@ -2859,7 +2859,20 @@ static void reset_thd_trn(THD *thd, MARIA_HA *first_table)
THD_TRN= NULL;
for (MARIA_HA *table= first_table; table ;
table= table->trn_next)
+ {
_ma_reset_trn_for_table(table);
+
+ /*
+ If table has changed by this statement, invalidate it from the query
+ cache
+ */
+ if (table->row_changes != table->start_row_changes)
+ {
+ table->start_row_changes= table->row_changes;
+ DBUG_ASSERT(table->s->chst_invalidator != NULL);
+ (*table->s->chst_invalidator)(table->s->data_file_name.str);
+ }
+ }
DBUG_VOID_RETURN;
}
@@ -3325,7 +3338,10 @@ static int maria_commit(handlerton *hton __attribute__ ((unused)),
THD *thd, bool all)
{
TRN *trn= THD_TRN;
+ int res;
+ MARIA_HA *used_instances= (MARIA_HA*) trn->used_instances;
DBUG_ENTER("maria_commit");
+
trnman_reset_locked_tables(trn, 0);
trnman_set_flags(trn, trnman_get_flags(trn) & ~TRN_STATE_INFO_LOGGED);
@@ -3333,8 +3349,9 @@ static int maria_commit(handlerton *hton __attribute__ ((unused)),
if ((thd->variables.option_bits & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) &&
!all)
DBUG_RETURN(0); // end of statement
- reset_thd_trn(thd, (MARIA_HA*) trn->used_instances);
- DBUG_RETURN(ma_commit(trn)); // end of transaction
+ res= ma_commit(trn);
+ reset_thd_trn(thd, used_instances);
+ DBUG_RETURN(res);
}
diff --git a/storage/maria/maria_def.h b/storage/maria/maria_def.h
index a23e00a24a3..cba35aabeb3 100644
--- a/storage/maria/maria_def.h
+++ b/storage/maria/maria_def.h
@@ -640,6 +640,7 @@ struct st_maria_handler
invalidator_by_filename invalidator; /* query cache invalidator */
ulonglong last_auto_increment; /* auto value at start of statement */
ulonglong row_changes; /* Incremented for each change */
+ ulonglong start_row_changes; /* Row changes since start trans */
ulong this_unique; /* uniq filenumber or thread */
ulong last_unique; /* last unique number */
ulong this_loop; /* counter for this open */