Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Dec 9, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/query/list_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -6779,3 +6779,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_ */
25 changes: 18 additions & 7 deletions src/query/query_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -1531,10 +1531,19 @@ 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)
{
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 @@ -2040,7 +2049,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 @@ -2087,9 +2095,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