Skip to content

Commit

Permalink
[CBRD-23810] Improvement of DML and transaction processing for result…
Browse files Browse the repository at this point in the history
…-cache (CUBRID#2525)

* [CBRD-23810] Improvement of DML and transaction processing for result-cache

* typo

* added assert
  • Loading branch information
beyondykk9 authored and hgryoo committed Dec 17, 2020
1 parent 4a483cb commit b7306a6
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 10 deletions.
6 changes: 6 additions & 0 deletions src/query/list_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -6778,3 +6778,9 @@ qfile_get_list_cache_number_of_entries (int ht_no)

return (qfile_List_cache.list_hts[ht_no]->nentries);
}

bool
qfile_has_no_cache_entries ()
{
return (qfile_List_cache.n_entries == 0);
}
2 changes: 2 additions & 0 deletions src/query/list_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,5 +224,7 @@ extern int qfile_overwrite_tuple (THREAD_ENTRY * thread_p, PAGE_PTR first_page,
QFILE_TUPLE_RECORD * tplrec, QFILE_LIST_ID * list_idp);
extern void qfile_update_qlist_count (THREAD_ENTRY * thread_p, const QFILE_LIST_ID * list_p, int inc);
extern int qfile_get_list_cache_number_of_entries (int ht_no);
extern bool qfile_has_no_cache_entries ();


#endif /* _LIST_FILE_H_ */
30 changes: 23 additions & 7 deletions src/query/query_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -1524,10 +1524,24 @@ xqmgr_execute_query (THREAD_ENTRY * thread_p, const XASL_ID * xasl_id_p, QUERY_I
}

/* update the cache entry for the result associated with the used parameter values (DB_VALUE array) if there
* is, or make new one */
list_cache_entry_p =
qfile_update_list_cache_entry (thread_p, &xasl_cache_entry_p->list_ht_no, &params, list_id_p,
xasl_cache_entry_p);
* is, or make new one
* in case list_ht_no is less than 0,
* the cache is not found and should be newly added (surely list_cache_entry_p is null)
* in case list_ht_no is not less than 0 and list_cache_entry_p is null
* the cache entry is found but the entry is used by other transaction
*/
if (list_cache_entry_p && xasl_cache_entry_p->list_ht_no < 0)
{
assert (false);
}

if (list_cache_entry_p || xasl_cache_entry_p->list_ht_no < 0)
{
list_cache_entry_p =
qfile_update_list_cache_entry (thread_p, &xasl_cache_entry_p->list_ht_no, &params, list_id_p,
xasl_cache_entry_p);
}

if (list_cache_entry_p == NULL)
{
char *s;
Expand Down Expand Up @@ -2033,7 +2047,6 @@ qmgr_clear_relative_cache_entries (THREAD_ENTRY * thread_p, QMGR_TRAN_ENTRY * tr
"qm_clear_trans_wakeup: qexec_clear_list_cache_by_class failed for class { %d %d %d }\n",
class_oid_p->pageid, class_oid_p->slotid, class_oid_p->volid);
}
qmgr_add_modified_class (thread_p, class_oid_p);
}
}
}
Expand Down Expand Up @@ -2080,9 +2093,12 @@ qmgr_clear_trans_wakeup (THREAD_ENTRY * thread_p, int tran_index, bool is_tran_d
tran_entry_p = &qmgr_Query_table.tran_entries_p[tran_index];

/* if the transaction is aborting, clear relative cache entries */
if (tran_entry_p->modified_classes_p)
if (tran_entry_p->modified_classes_p && !QFILE_IS_LIST_CACHE_DISABLED)
{
qmgr_clear_relative_cache_entries (thread_p, tran_entry_p);
if (!qfile_has_no_cache_entries ())
{
qmgr_clear_relative_cache_entries (thread_p, tran_entry_p);
}
qmgr_free_oid_block (thread_p, tran_entry_p->modified_classes_p);
tran_entry_p->modified_classes_p = NULL;
}
Expand Down
7 changes: 4 additions & 3 deletions src/query/xasl_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "thread_lockfree_hash_map.hpp"
#include "thread_manager.hpp"
#include "xasl_unpack_info.hpp"
#include "list_file.h"

#include <algorithm>
#include <assert.h>
Expand Down Expand Up @@ -1780,10 +1781,10 @@ xcache_invalidate_entries (THREAD_ENTRY * thread_p, bool (*invalidate_check) (XA
/* Check invalidation conditions. */
if (invalidate_check == NULL || invalidate_check (xcache_entry, arg))
{
if (xcache_entry->list_ht_no >= 0)
if (xcache_entry->list_ht_no >= 0 && !QFILE_IS_LIST_CACHE_DISABLED && !qfile_has_no_cache_entries ())
{
qfile_clear_list_cache (thread_p, xcache_entry->list_ht_no, true);
if (qfile_get_list_cache_number_of_entries (xcache_entry->list_ht_no) == 0)
qfile_clear_list_cache (thread_p, xcache_entry->list_ht_no, true);
if (qfile_get_list_cache_number_of_entries (xcache_entry->list_ht_no) == 0)
{
xcache_entry->list_ht_no = -1;
}
Expand Down

0 comments on commit b7306a6

Please sign in to comment.