66 #if defined(SERVER_MODE) 69 #if defined(ENABLE_SYSTEMTAP) 77 #define PGBUF_MINIMUM_BUFFERS (MAX_NTRANS * 10) 83 #define PGBUF_DEFAULT_FIX_COUNT 7 87 #define PGBUF_NUM_ALLOC_HOLDER 10 89 #if !defined(SERVER_MODE) 91 #define pthread_mutex_init(a, b) 92 #define pthread_mutex_destroy(a) 93 #define pthread_mutex_lock(a) 0 94 #define pthread_mutex_unlock(a) 99 #define PGBUF_TIMEOUT 300 100 #define PGBUF_FIX_COUNT_THRESHOLD 64 103 #if defined(CUBRID_DEBUG) 104 #define SIZEOF_IOPAGE_PAGESIZE_AND_GUARD() (IO_PAGESIZE + sizeof (pgbuf_Guard)) 106 #define SIZEOF_IOPAGE_PAGESIZE_AND_GUARD() (IO_PAGESIZE) 110 #define PGBUF_BCB_SIZEOF (sizeof (PGBUF_BCB)) 111 #define PGBUF_IOPAGE_BUFFER_SIZE \ 112 ((size_t)(offsetof (PGBUF_IOPAGE_BUFFER, iopage) + \ 113 SIZEOF_IOPAGE_PAGESIZE_AND_GUARD())) 115 #define PGBUF_BUFFER_HASH_SIZEOF (sizeof (PGBUF_BUFFER_HASH)) 117 #define PGBUF_BUFFER_LOCK_SIZEOF (sizeof (PGBUF_BUFFER_LOCK)) 119 #define PGBUF_LRU_LIST_SIZEOF (sizeof (PGBUF_LRU_LIST)) 121 #define PGBUF_HOLDER_SIZEOF (sizeof (PGBUF_HOLDER)) 123 #define PGBUF_HOLDER_SET_SIZEOF (sizeof (PGBUF_HOLDER_SET)) 125 #define PGBUF_HOLDER_ANCHOR_SIZEOF (sizeof (PGBUF_HOLDER_ANCHOR)) 128 #define PGBUF_FIND_BCB_PTR(i) \ 129 ((PGBUF_BCB *) ((char *) &(pgbuf_Pool.BCB_table[0]) + (PGBUF_BCB_SIZEOF * (i)))) 131 #define PGBUF_FIND_IOPAGE_PTR(i) \ 132 ((PGBUF_IOPAGE_BUFFER *) ((char *) &(pgbuf_Pool.iopage_table[0]) + (PGBUF_IOPAGE_BUFFER_SIZE * (i)))) 134 #define PGBUF_FIND_BUFFER_GUARD(bufptr) \ 135 (&bufptr->iopage_buffer->iopage.page[DB_PAGESIZE]) 138 #define CAST_PGPTR_TO_BFPTR(bufptr, pgptr) \ 140 (bufptr) = ((PGBUF_BCB *) ((PGBUF_IOPAGE_BUFFER *) \ 141 ((char *) pgptr - offsetof (PGBUF_IOPAGE_BUFFER, iopage.page)))->bcb); \ 142 assert ((bufptr) == (bufptr)->iopage_buffer->bcb); \ 145 #define CAST_PGPTR_TO_IOPGPTR(io_pgptr, pgptr) \ 147 (io_pgptr) = (FILEIO_PAGE *) ((char *) pgptr - offsetof (FILEIO_PAGE, page)); \ 150 #define CAST_IOPGPTR_TO_PGPTR(pgptr, io_pgptr) \ 152 (pgptr) = (PAGE_PTR) ((char *) (io_pgptr)->page); \ 155 #define CAST_BFPTR_TO_PGPTR(pgptr, bufptr) \ 157 assert ((bufptr) == (bufptr)->iopage_buffer->bcb); \ 158 (pgptr) = ((PAGE_PTR) ((char *) (bufptr->iopage_buffer) + offsetof (PGBUF_IOPAGE_BUFFER, iopage.page))); \ 162 #define PGBUF_IS_AUXILIARY_VOLUME(volid) ((volid) < LOG_DBFIRST_VOLID ? true : false) 170 #define PGBUF_LRU_NBITS 16 171 #define PGBUF_LRU_LIST_MAX_COUNT ((int) 1 << PGBUF_LRU_NBITS) 172 #define PGBUF_LRU_INDEX_MASK (PGBUF_LRU_LIST_MAX_COUNT - 1) 204 #define PGBUF_MAKE_ZONE(list_id, zone) ((list_id) | (zone)) 205 #define PGBUF_GET_ZONE(flags) ((PGBUF_ZONE) ((flags) & PGBUF_ZONE_MASK)) 206 #define PGBUF_GET_LRU_INDEX(flags) ((flags) & PGBUF_LRU_INDEX_MASK) 214 #define PGBUF_BCB_DIRTY_FLAG ((int) 0x80000000) 217 #define PGBUF_BCB_FLUSHING_TO_DISK_FLAG ((int) 0x40000000) 224 #define PGBUF_BCB_VICTIM_DIRECT_FLAG ((int) 0x20000000) 225 #define PGBUF_BCB_INVALIDATE_DIRECT_VICTIM_FLAG ((int) 0x10000000) 227 #define PGBUF_BCB_MOVE_TO_LRU_BOTTOM_FLAG ((int) 0x08000000) 229 #define PGBUF_BCB_TO_VACUUM_FLAG ((int) 0x04000000) 231 #define PGBUF_BCB_ASYNC_FLUSH_REQ ((int) 0x02000000) 234 #define PGBUF_BCB_FLAGS_MASK \ 235 (PGBUF_BCB_DIRTY_FLAG \ 236 | PGBUF_BCB_FLUSHING_TO_DISK_FLAG \ 237 | PGBUF_BCB_VICTIM_DIRECT_FLAG \ 238 | PGBUF_BCB_INVALIDATE_DIRECT_VICTIM_FLAG \ 239 | PGBUF_BCB_MOVE_TO_LRU_BOTTOM_FLAG \ 240 | PGBUF_BCB_TO_VACUUM_FLAG \ 241 | PGBUF_BCB_ASYNC_FLUSH_REQ) 248 #define PGBUF_BCB_INVALID_VICTIM_CANDIDATE_MASK \ 249 (PGBUF_BCB_DIRTY_FLAG \ 250 | PGBUF_BCB_FLUSHING_TO_DISK_FLAG \ 251 | PGBUF_BCB_VICTIM_DIRECT_FLAG \ 252 | PGBUF_BCB_INVALIDATE_DIRECT_VICTIM_FLAG) 255 #define PGBUF_BCB_INIT_FLAGS PGBUF_INVALID_ZONE 258 #define PGBUF_BCB_COUNT_FIX_SHIFT_BITS 16 259 #define PGBUF_BCB_AVOID_DEALLOC_MASK ((int) 0x0000FFFF) 266 #define PGBUF_TRAN_THRESHOLD_ACTIVITY (pgbuf_Pool.num_buffers / 4) 267 #define PGBUF_TRAN_MAX_ACTIVITY (10 * PGBUF_TRAN_THRESHOLD_ACTIVITY) 269 #define PGBUF_AOUT_NOT_FOUND -2 271 #if defined (SERVER_MODE) 273 #define PGBUF_THREAD_SHOULD_IGNORE_UNFIX(th) VACUUM_IS_THREAD_VACUUM_WORKER (th) 275 #define PGBUF_THREAD_SHOULD_IGNORE_UNFIX(th) false 278 #define HASH_SIZE_BITS 20 279 #define PGBUF_HASH_SIZE (1 << HASH_SIZE_BITS) 281 #define PGBUF_HASH_VALUE(vpid) pgbuf_hash_func_mirror(vpid) 286 #define PGBUF_FLUSH_VICTIM_BOOST_MULT 10 288 #define PGBUF_NEIGHBOR_FLUSH_NONDIRTY \ 289 (prm_get_bool_value (PRM_ID_PB_NEIGHBOR_FLUSH_NONDIRTY)) 291 #define PGBUF_MAX_NEIGHBOR_PAGES 32 292 #define PGBUF_NEIGHBOR_PAGES \ 293 (prm_get_integer_value (PRM_ID_PB_NEIGHBOR_FLUSH_PAGES)) 295 #define PGBUF_NEIGHBOR_POS(idx) (PGBUF_NEIGHBOR_PAGES - 1 + (idx)) 298 #define PGBUF_MAX_PAGE_WATCHERS 64 300 #define PGBUF_MAX_PAGE_FIXED_BY_TRAN 64 303 #define PGBUF_CHKPT_MAX_FLUSH_RATE 1200 304 #define PGBUF_CHKPT_MIN_FLUSH_RATE 50 307 #define PGBUF_CHKPT_BURST_PAGES 16 309 #define INIT_HOLDER_STAT(perf_stat) \ 312 (perf_stat)->dirty_before_hold = 0; \ 313 (perf_stat)->dirtied_by_holder = 0; \ 314 (perf_stat)->hold_has_write_latch = 0; \ 315 (perf_stat)->hold_has_read_latch = 0; \ 321 #undef PGBUF_ORDERED_DEBUG 323 #define PGBUF_LRU_ZONE_MIN_RATIO 0.05f 324 #define PGBUF_LRU_ZONE_MAX_RATIO 0.90f 419 unsigned dirty_before_hold:1;
420 unsigned dirtied_by_holder:1;
421 unsigned hold_has_write_latch:1;
422 unsigned hold_has_read_latch:1;
445 char fixed_at[64 * 1024];
473 #if defined(SERVER_MODE) 474 pthread_mutex_t
mutex;
481 #if defined(SERVER_MODE) 507 #if (__WORDSIZE == 32) 509 #elif !defined(LINUX) && !defined(WINDOWS) && !defined(AIX) 510 #error "you must check that iopage is aligned by 8byte !!" 524 #if defined(SERVER_MODE) 535 #if defined(SERVER_MODE) 536 pthread_mutex_t hash_mutex;
545 #if defined(SERVER_MODE) 546 pthread_mutex_t
mutex;
586 #if defined(SERVER_MODE) 587 pthread_mutex_t invalid_mutex;
610 #if defined(SERVER_MODE) 611 pthread_mutex_t Aout_mutex;
664 #if defined (SERVER_MODE) 695 #if defined (SERVER_MODE) 699 typedef struct pgbuf_direct_victim PGBUF_DIRECT_VICTIM;
700 struct pgbuf_direct_victim
708 #define PGBUF_FLUSHED_BCBS_BUFFER_SIZE (8 * 1024) 758 #if defined(SERVER_MODE) 759 pthread_mutex_t free_holder_set_mutex;
768 #if defined(SERVER_MODE) 769 bool is_flushing_victims;
774 #if defined (SERVER_MODE) 775 PGBUF_DIRECT_VICTIM direct_victims;
786 #if defined (SERVER_MODE) 787 pthread_mutex_t show_status_mutex;
807 #if defined(CUBRID_DEBUG) 812 MEM_REGION_GUARD_MARK
816 #define AOUT_HASH_DIVIDE_RATIO 1000 817 #define AOUT_HASH_IDX(vpid, list) ((vpid)->pageid % list->num_hashes) 827 #if defined (SERVER_MODE) 828 static bool pgbuf_Monitor_locks =
false;
831 #if defined (SERVER_MODE) 832 #define PGBUF_BCB_LOCK(bcb) \ 833 (pgbuf_Monitor_locks ? pgbuf_bcbmon_lock (bcb, __LINE__) : (void) pthread_mutex_lock (&(bcb)->mutex)) 834 #define PGBUF_BCB_TRYLOCK(bcb) \ 835 (pgbuf_Monitor_locks ? pgbuf_bcbmon_trylock (bcb, __LINE__) : pthread_mutex_trylock (&(bcb)->mutex)) 836 #define PGBUF_BCB_UNLOCK(bcb) \ 837 (pgbuf_Monitor_locks ? pgbuf_bcbmon_unlock (bcb) : (void) pthread_mutex_unlock (&(bcb)->mutex)) 838 #define PGBUF_BCB_CHECK_OWN(bcb) if (pgbuf_Monitor_locks) pgbuf_bcbmon_check_own (bcb) 839 #define PGBUF_BCB_CHECK_MUTEX_LEAKS() if (pgbuf_Monitor_locks) pgbuf_bcbmon_check_mutex_leaks () 842 #define PGBUF_BCB_LOCK(bcb) 843 #define PGBUF_BCB_TRYLOCK(bcb) (0) 844 #define PGBUF_BCB_UNLOCK(bcb) 845 #define PGBUF_BCB_CHECK_OWN(bcb) (true) 846 #define PGBUF_BCB_CHECK_MUTEX_LEAKS() 880 #define PGBUF_GET_LRU_LIST(lru_idx) (&pgbuf_Pool.buf_LRU_list[lru_idx]) 882 #define PGBUF_IS_BCB_IN_LRU_VICTIM_ZONE(bcb) (pgbuf_bcb_get_zone (bcb) == PGBUF_LRU_3_ZONE) 883 #define PGBUF_IS_BCB_IN_LRU(bcb) ((pgbuf_bcb_get_zone (bcb) & PGBUF_LRU_ZONE_MASK) != 0) 886 #define PGBUF_AGE_DIFF(bcb_age,list_age) \ 887 (((list_age) >= (bcb_age)) ? ((list_age) - (bcb_age)) : (DB_INT32_MAX - ((bcb_age) - (list_age)))) 890 #define PGBUF_IS_BCB_OLD_ENOUGH(bcb, lru_list) \ 891 (PGBUF_AGE_DIFF ((bcb)->tick_lru_list, (lru_list)->tick_list) >= ((lru_list)->count_lru2 / 2)) 893 #define PGBUF_LRU_ZONE_ONE_TWO_COUNT(list) ((list)->count_lru1 + (list)->count_lru2) 894 #define PGBUF_LRU_LIST_COUNT(list) (PGBUF_LRU_ZONE_ONE_TWO_COUNT(list) + (list)->count_lru3) 895 #define PGBUF_LRU_VICTIM_ZONE_COUNT(list) ((list)->count_lru3) 897 #define PGBUF_LRU_IS_ZONE_ONE_OVER_THRESHOLD(list) ((list)->threshold_lru1 < (list)->count_lru1) 898 #define PGBUF_LRU_IS_ZONE_TWO_OVER_THRESHOLD(list) ((list)->threshold_lru2 < (list)->count_lru2) 899 #define PGBUF_LRU_ARE_ZONES_ONE_TWO_OVER_THRESHOLD(list) \ 900 ((list)->threshold_lru1 + (list)->threshold_lru2 < PGBUF_LRU_ZONE_ONE_TWO_COUNT(list)) 905 #define PGBUF_PRIVATE_LRU_MIN_COUNT 4 906 #define PGBUF_PRIVATE_LRU_MAX_HARD_QUOTA 5000 909 #define PGBUF_MIN_PAGES_IN_SHARED_LIST 1000 910 #define PGBUF_MIN_SHARED_LIST_ADJUST_SIZE 50 912 #define PGBUF_PAGE_QUOTA_IS_ENABLED (pgbuf_Pool.quota.num_private_LRU_list > 0) 917 #if defined (SERVER_MODE) 918 #define PGBUF_PRIVATE_LRU_FROM_THREAD(thread_p) \ 919 ((thread_p) != NULL) ? ((thread_p)->private_lru_index) : (0) 926 #define PGBUF_PRIVATE_LRU_FROM_THREAD(thread_p) 0 927 #define PGBUF_THREAD_HAS_PRIVATE_LRU(thread_p) false 930 #define PGBUF_SHARED_LRU_COUNT (pgbuf_Pool.num_LRU_list) 931 #define PGBUF_PRIVATE_LRU_COUNT (pgbuf_Pool.quota.num_private_LRU_list) 932 #define PGBUF_TOTAL_LRU_COUNT (PGBUF_SHARED_LRU_COUNT + PGBUF_PRIVATE_LRU_COUNT) 934 #define PGBUF_PRIVATE_LIST_FROM_LRU_INDEX(i) ((i) - PGBUF_SHARED_LRU_COUNT) 935 #define PGBUF_LRU_INDEX_FROM_PRIVATE(private_id) (PGBUF_SHARED_LRU_COUNT + (private_id)) 937 #define PGBUF_IS_SHARED_LRU_INDEX(lru_idx) ((lru_idx) < PGBUF_SHARED_LRU_COUNT) 938 #define PGBUF_IS_PRIVATE_LRU_INDEX(lru_idx) ((lru_idx) >= PGBUF_SHARED_LRU_COUNT) 940 #define PGBUF_LRU_LIST_IS_OVER_QUOTA(list) (PGBUF_LRU_LIST_COUNT (list) > (list)->quota) 941 #define PGBUF_LRU_LIST_IS_ONE_TWO_OVER_QUOTA(list) ((PGBUF_LRU_ZONE_ONE_TWO_COUNT (list) > (list)->quota)) 942 #define PGBUF_LRU_LIST_OVER_QUOTA_COUNT(list) (PGBUF_LRU_LIST_COUNT (list) - (list)->quota) 944 #define PGBUF_IS_PRIVATE_LRU_OVER_QUOTA(lru_idx) \ 945 (PGBUF_IS_PRIVATE_LRU_INDEX (lru_idx) && PGBUF_LRU_LIST_IS_OVER_QUOTA (PGBUF_GET_LRU_LIST (lru_idx))) 946 #define PGBUF_IS_PRIVATE_LRU_ONE_TWO_OVER_QUOTA(lru_idx) \ 947 (PGBUF_IS_PRIVATE_LRU_INDEX (lru_idx) && PGBUF_LRU_LIST_IS_ONE_TWO_OVER_QUOTA (PGBUF_GET_LRU_LIST (lru_idx))) 949 #define PGBUF_OVER_QUOTA_BUFFER(quota) MAX (10, (int) (quota * 0.01f)) 950 #define PGBUF_LRU_LIST_IS_OVER_QUOTA_WITH_BUFFER(list) \ 951 (PGBUF_LRU_LIST_COUNT (list) > (list)->quota + PGBUF_OVER_QUOTA_BUFFER ((list)->quota)) 953 #define PBGUF_BIG_PRIVATE_MIN_SIZE 100 956 #define PGBUF_LRU_VICTIM_LFCQ_FLAG ((int) 0x80000000) 964 static int pgbuf_Abort_release_line = 0;
965 #define PGBUF_ABORT_RELEASE() do { pgbuf_Abort_release_line = __LINE__; abort (); } while (false) 967 #define PGBUF_ABORT_RELEASE() assert (false) 996 int request_fcnt,
bool as_promote);
1010 int need_hash_mutex);
1024 float lru_sum_flush_priority,
bool * assigned_directly);
1027 #if defined (SERVER_MODE) 1071 #if defined(SERVER_MODE) 1084 #if defined(CUBRID_DEBUG) 1085 static void pgbuf_scramble (
FILEIO_PAGE * iopage);
1086 static void pgbuf_dump (
void);
1087 static int pgbuf_is_consistent (
const PGBUF_BCB * bufptr,
int likely_bad_after_fixcnt);
1090 #if !defined(NDEBUG) 1094 #if defined(SERVER_MODE) 1095 static void pgbuf_sleep (
THREAD_ENTRY * thread_p, pthread_mutex_t * mutex_p);
1105 #if defined (SERVER_MODE) 1106 static bool pgbuf_is_thread_high_priority (
THREAD_ENTRY * thread_p);
1114 VPID * groupid,
bool do_unfix);
1115 #if !defined(NDEBUG) 1118 const char *caller_file,
const int caller_line)
1128 const LOG_LSA * prev_chkpt_redo_lsa,
LOG_LSA * chkpt_smallest_lsa);
1130 const LOG_LSA * prev_chkpt_redo_lsa,
LOG_LSA * chkpt_smallest_lsa,
int *time_rem);
1144 #if defined (SERVER_MODE) 1157 bool was_vict_count_updated)
__attribute__ ((ALWAYS_INLINE));
1192 #if defined (SERVER_MODE) 1193 static void pgbuf_bcbmon_lock (
PGBUF_BCB * bcb,
int caller_line);
1194 static int pgbuf_bcbmon_trylock (
PGBUF_BCB * bcb,
int caller_line);
1195 static void pgbuf_bcbmon_unlock (
PGBUF_BCB * bcb);
1196 static void pgbuf_bcbmon_check_own (
PGBUF_BCB * bcb);
1197 static void pgbuf_bcbmon_check_mutex_leaks (
void);
1217 #if defined (SERVER_MODE) 1236 #define VOLID_LSB_BITS 8 1238 unsigned int hash_val;
1239 unsigned int volid_lsb;
1240 unsigned int reversed_volid_lsb = 0;
1241 unsigned int lsb_mask;
1242 unsigned int reverse_mask;
1244 volid_lsb = vpid->
volid;
1251 if (volid_lsb & lsb_mask)
1253 reversed_volid_lsb |= reverse_mask;
1255 reverse_mask = reverse_mask >> 1;
1256 lsb_mask = lsb_mask << 1;
1259 hash_val = vpid->
pageid ^ reversed_volid_lsb;
1263 #undef VOLID_LSB_BITS 1275 const VPID *vpid = (
VPID *) key_vpid;
1277 return ((vpid->
pageid | ((
unsigned int) vpid->
volid) << 24) % htsize);
1289 const VPID *vpid1 = (
VPID *) key_vpid1;
1290 const VPID *vpid2 = (
VPID *) key_vpid2;
1315 memset (&pgbuf_Pool, 0,
sizeof (pgbuf_Pool));
1320 #if defined(CUBRID_DEBUG) 1326 #if defined (SERVER_MODE) 1327 #if defined (NDEBUG) 1330 pgbuf_Monitor_locks =
true;
1408 #if defined (SERVER_MODE) 1409 pgbuf_Pool.is_flushing_victims =
false;
1410 pgbuf_Pool.is_checkpoint =
false;
1416 cnt = MIN (cnt, 65536);
1427 #if defined (SERVER_MODE) 1429 if (pgbuf_Pool.direct_victims.bcb_victims ==
NULL)
1438 pgbuf_Pool.direct_victims.waiter_threads_high_priority =
1441 if (pgbuf_Pool.direct_victims.waiter_threads_high_priority ==
NULL)
1448 pgbuf_Pool.direct_victims.waiter_threads_low_priority =
1451 if (pgbuf_Pool.direct_victims.waiter_threads_low_priority ==
NULL)
1460 if (pgbuf_Pool.flushed_bcbs ==
NULL)
1508 #if defined(SERVER_MODE) 1533 size_t hash_size, j;
1535 #if defined(CUBRID_DEBUG) 1536 pgbuf_dump_if_any_fixed ();
1543 for (j = 0; j < hash_size; j++)
1660 #if defined (SERVER_MODE) 1666 if (pgbuf_Pool.direct_victims.bcb_victims !=
NULL)
1670 if (pgbuf_Pool.direct_victims.waiter_threads_high_priority !=
NULL)
1672 delete pgbuf_Pool.direct_victims.waiter_threads_high_priority;
1673 pgbuf_Pool.direct_victims.waiter_threads_high_priority =
NULL;
1675 if (pgbuf_Pool.direct_victims.waiter_threads_low_priority !=
NULL)
1677 delete pgbuf_Pool.direct_victims.waiter_threads_low_priority;
1678 pgbuf_Pool.direct_victims.waiter_threads_low_priority =
NULL;
1680 if (pgbuf_Pool.flushed_bcbs !=
NULL)
1682 delete pgbuf_Pool.flushed_bcbs;
1683 pgbuf_Pool.flushed_bcbs =
NULL;
1709 #if defined(SERVER_MODE) 1728 bool noretry =
false;
1747 if (noretry || i > retry)
1761 #if defined(WINDOWS) 1762 #if !defined(NDEBUG) 1787 #if !defined(NDEBUG) 1801 #if defined(ENABLE_SYSTEMTAP) 1802 bool pgbuf_hit =
false;
1806 bool buf_lock_acquired =
false;
1807 bool is_latch_wait =
false;
1809 #if !defined (NDEBUG) 1810 bool had_holder =
false;
1813 bool maybe_deallocated, force_set_vpid;
1888 buf_lock_acquired =
false;
1897 #if defined (ENABLE_SYSTEMTAP) 1898 CUBRID_PGBUF_HIT ();
1932 buf_lock_acquired =
true;
1934 #if defined(ENABLE_SYSTEMTAP) 1935 if (fetch_mode ==
NEW_PAGE && pgbuf_hit ==
false)
1941 CUBRID_PGBUF_MISS ();
1959 if (buf_lock_acquired)
1992 #if !defined (NDEBUG) 2000 if (buf_lock_acquired)
2020 #if !defined (NDEBUG) 2040 if (buf_lock_acquired)
2054 #if !defined (NDEBUG) 2061 while (watcher !=
NULL)
2064 watcher = watcher->
prev;
2074 #if !defined (NDEBUG) 2075 thread_p->get_pgbuf_tracker ().increment (caller_file, caller_line, pgptr);
2196 #if !defined (NDEBUG) 2199 const char *caller_file,
int caller_line)
2206 #if defined(SERVER_MODE) 2211 UINT64 promote_wait_time;
2212 bool is_perf_tracking;
2216 int stat_success = 0;
2220 #if !defined (NDEBUG) 2232 if (*pgptr_p ==
NULL)
2261 #if defined(SERVER_MODE) 2264 if (is_perf_tracking)
2272 vpid = bufptr->
vpid;
2273 if (is_perf_tracking)
2306 if (bufptr->next_wait_thrd !=
NULL && bufptr->next_wait_thrd->wait_for_latch_promote)
2310 #if !defined(NDEBUG) 2325 || (bufptr->next_wait_thrd !=
NULL && bufptr->next_wait_thrd->wait_for_latch_promote))
2336 #if !defined(NDEBUG) 2346 bufptr->
fcnt -= fix_count;
2362 thread_p->wait_for_latch_promote =
true;
2368 thread_p->wait_for_latch_promote =
false;
2375 thread_p->wait_for_latch_promote =
false;
2398 #if !defined(NDEBUG) 2408 if (is_perf_tracking)
2413 promote_wait_time = tv_diff.tv_sec * 1000000LL + tv_diff.tv_usec;
2422 perfmon_pbx_promote (thread_p, perf_page_type, perf_promote_cond_type, perf_holder_latch, stat_success,
2442 #if !defined (NDEBUG) 2457 bool is_perf_tracking;
2459 #if defined(CUBRID_DEBUG) 2463 #if !defined (NDEBUG) 2479 while (watcher !=
NULL)
2482 watcher = watcher->
prev;
2495 #if defined(CUBRID_DEBUG) 2506 "pgbuf_unfix: WARNING: No logging on dirty pageid = %d of Volume = %s.\n Recovery problems" 2526 if (bufptr->
fcnt <= 0)
2529 "pgbuf_unfix: SYSTEM ERROR Freeing too much buffer of pageid = %d of Volume = %s\n",
2535 if (is_perf_tracking)
2544 if (is_perf_tracking)
2559 perfmon_pbx_unfix (thread_p, perf_page_type, holder_perf_stat.
dirty_before_hold,
2565 #if !defined (NDEBUG) 2566 thread_p->get_pgbuf_tracker ().decrement (pgptr);
2573 #if defined(CUBRID_DEBUG) 2587 if (bufptr->
fcnt == 0)
2665 #if defined(CUBRID_DEBUG) 2668 const char *latch_mode_str, *zone_str, *consistent_str;
2679 while (holder !=
NULL)
2699 #if defined(CUBRID_DEBUG) 2700 consistent = pgbuf_is_consistent (bufptr, 0);
2703 consistent_str =
"UNKNOWN";
2706 "pgbuf_unfix_all: WARNING %4d %5d %6d %4d %9s %1d %1d %1d %11s %6d|%4d %10s %p %p-%p\n",
2746 #if !defined(NDEBUG) 2777 if (bufptr->
fcnt > 1)
2781 #if !defined (NDEBUG) 2782 thread_p->get_pgbuf_tracker ().decrement (pgptr);
2804 temp_vpid = bufptr->
vpid;
2808 #if !defined (NDEBUG) 2809 thread_p->get_pgbuf_tracker ().decrement (pgptr);
2828 #if defined(CUBRID_DEBUG) 2850 #if !defined(NDEBUG) 2867 for (bufid = 0; bufid < pgbuf_Pool.
num_buffers; bufid++)
2885 temp_vpid = bufptr->
vpid;
2906 #if defined(CUBRID_DEBUG) 2941 if (free_page ==
FREE)
3053 if (is_set_lsa_as_null)
3157 bool * assigned_directly)
3159 int lru_idx, victim_cand_count,
i;
3161 int check_count_this_lru;
3162 float victim_flush_priority_this_lru;
3163 int count_checked_lists = 0;
3164 #if defined (SERVER_MODE) 3167 bool try_direct_assign =
true;
3171 victim_cand_count = 0;
3175 if (victim_flush_priority_this_lru <= 0)
3180 ++count_checked_lists;
3182 check_count_this_lru = (int) (victim_flush_priority_this_lru * (
float) check_count / lru_sum_flush_priority);
3183 check_count_this_lru = MAX (check_count_this_lru, 1);
3185 i = check_count_this_lru;
3197 victim_cand_count++;
3199 #if defined (SERVER_MODE) 3200 else if (try_direct_assign && pgbuf_is_any_thread_waiting_for_direct_victim ()
3206 try_direct_assign =
false;
3207 *assigned_directly =
true;
3220 "pgbuf_flush_victim_candidates: pgbuf_get_victim_candidates_from_lru %d candidates in %d lists \n",
3221 victim_cand_count, count_checked_lists);
3224 return victim_cand_count;
3242 int i, victim_count = 0;
3243 int check_count_lru;
3245 int total_flushed_count;
3247 float lru_miss_rate;
3248 float lru_dynamic_flush_adj = 1.0f;
3249 int lru_victim_req_cnt, fix_req_cnt;
3250 float lru_sum_flush_priority;
3251 int count_need_wal = 0;
3253 #if defined(SERVER_MODE) 3256 bool repeated =
false;
3258 bool is_bcb_locked =
false;
3260 bool assigned_directly =
false;
3261 #if !defined (NDEBUG) && defined (SERVER_MODE) 3262 bool empty_flushed_bcb_queue =
false;
3263 bool direct_victim_waiters =
false;
3267 UINT64 num_skipped_already_flushed = 0;
3268 UINT64 num_skipped_fixed_or_hot = 0;
3269 UINT64 num_skipped_need_wal = 0;
3270 UINT64 num_skipped_flush = 0;
3280 #if !defined(NDEBUG) && defined(SERVER_MODE) 3283 if (page_flush_thread ==
NULL)
3285 page_flush_thread = thread_p;
3289 assert (page_flush_thread == thread_p);
3302 total_flushed_count = 0;
3303 check_count_lru = 0;
3308 if (fix_req_cnt > lru_victim_req_cnt)
3310 lru_miss_rate = (float) lru_victim_req_cnt / (
float) fix_req_cnt;
3318 cfg_check_cnt = (int) (pgbuf_Pool.
num_buffers * flush_ratio);
3322 #if defined (SERVER_MODE) 3325 if (pgbuf_Pool.is_checkpoint ==
false)
3333 lru_dynamic_flush_adj = 1.0f;
3336 check_count_lru = (int) (cfg_check_cnt * lru_dynamic_flush_adj);
3338 check_count_lru = MIN (check_count_lru, (200 * 1024 * 1024) /
db_page_size ());
3340 #if !defined (NDEBUG) && defined (SERVER_MODE) 3341 empty_flushed_bcb_queue = pgbuf_Pool.flushed_bcbs->is_empty ();
3342 direct_victim_waiters = pgbuf_is_any_thread_waiting_for_direct_victim ();
3345 if (check_count_lru > 0 && lru_sum_flush_priority > 0)
3350 if (victim_count == 0)
3356 *stop = check_count_lru > 0 && lru_sum_flush_priority > 0;
3360 #if defined (SERVER_MODE) 3377 #if defined (SERVER_MODE) 3378 pgbuf_Pool.is_flushing_victims =
true;
3385 if (perf_tracker->is_perf_tracking)
3395 perf_tracker->start_tick = perf_tracker->end_tick;
3397 #if defined (SERVER_MODE) 3404 for (i = 0; i < victim_count; i++)
3406 int flushed_pages = 0;
3408 bufptr = victim_cand_list[
i].
bufptr;
3419 ++num_skipped_already_flushed;
3427 ++num_skipped_fixed_or_hot;
3441 ++num_skipped_need_wal;
3442 #if defined (SERVER_MODE) 3471 total_flushed_count += flushed_pages;
3474 num_skipped_flush = num_skipped_need_wal + num_skipped_fixed_or_hot + num_skipped_already_flushed;
3475 if (perf_tracker->is_perf_tracking)
3493 perf_tracker->start_tick = perf_tracker->end_tick;
3498 #if defined (SERVER_MODE) 3499 if (pgbuf_is_any_thread_waiting_for_direct_victim () && victim_count != 0 && count_need_wal == victim_count)
3511 save_lsa_need_wal = lsa_need_wal;
3517 pgbuf_Pool.is_flushing_victims =
false;
3523 "pgbuf_flush_victim_candidates: flush %d pages from lru lists.\n" 3524 "\tvictim_count = %d\n" 3525 "\tcheck_count_lru = %d\n" 3526 "\tnum_skipped_need_wal = %d\n" 3527 "\tnum_skipped_fixed_or_hot = %d\n" 3528 "\tnum_skipped_already_flushed = %d\n",
3529 total_flushed_count, victim_count, check_count_lru, num_skipped_need_wal, num_skipped_fixed_or_hot,
3530 num_skipped_already_flushed);
3553 LOG_LSA * smallest_lsa,
int *flushed_page_cnt)
3555 #define detailed_er_log(...) if (detailed_logging) _er_log_debug (ARG_FILE_LINE, __VA_ARGS__) 3558 int flushed_page_cnt_local = 0;
3565 detailed_er_log (
"pgbuf_flush_checkpoint start : flush_upto_LSA:%d, prev_chkpt_redo_LSA:%d\n",
3566 flush_upto_lsa->
pageid, (prev_chkpt_redo_lsa ? prev_chkpt_redo_lsa->
pageid : -1));
3568 if (flushed_page_cnt !=
NULL)
3570 *flushed_page_cnt = -1;
3586 #if defined (SERVER_MODE) 3587 pgbuf_Pool.is_checkpoint =
true;
3590 for (bufid = 0; bufid < pgbuf_Pool.
num_buffers; bufid++)
3595 seq_flusher->
flush_cnt = collected_bcbs;
3603 #if defined (SERVER_MODE) 3604 pgbuf_Pool.is_checkpoint =
false;
3640 f_list[collected_bcbs].
bufptr = bufptr;
3646 #if defined(SERVER_MODE) 3647 if (thread_p !=
NULL && thread_p->shutdown ==
true)
3649 pgbuf_Pool.is_checkpoint =
false;
3655 if (collected_bcbs > 0)
3658 seq_flusher->
flush_cnt = collected_bcbs;
3667 #if defined (SERVER_MODE) 3668 pgbuf_Pool.is_checkpoint =
false;
3671 detailed_er_log (
"pgbuf_flush_checkpoint END flushed:%d\n", flushed_page_cnt_local);
3673 if (flushed_page_cnt !=
NULL)
3675 *flushed_page_cnt = flushed_page_cnt_local;
3680 #undef detailed_er_log 3694 const LOG_LSA * prev_chkpt_redo_lsa,
LOG_LSA * chkpt_smallest_lsa)
3696 #define WAIT_FLUSH_VICTIMS_MAX_MSEC 1500.0f 3698 struct timeval *p_limit_time;
3701 #if defined (SERVER_MODE) 3702 int flush_interval, sleep_msecs;
3704 float chkpt_flush_rate;
3705 struct timeval limit_time = { 0, 0 };
3706 struct timeval cur_time = { 0, 0 };
3709 #if defined (SERVER_MODE) 3711 if (sleep_msecs > 0)
3713 chkpt_flush_rate = 1000.0f / (float) sleep_msecs;
3717 chkpt_flush_rate = 1000.0f;
3729 #if defined (SERVER_MODE) 3730 if (thread_p !=
NULL && thread_p->shutdown)
3736 gettimeofday (&cur_time,
NULL);
3742 p_limit_time = &limit_time;
3744 p_limit_time =
NULL;
3747 #if defined (SERVER_MODE) 3753 wait_victims += 0.1f;
3757 error =
pgbuf_flush_seq_list (thread_p, seq_flusher, p_limit_time, prev_chkpt_redo_lsa, chkpt_smallest_lsa,
3767 #if defined (SERVER_MODE) 3778 #undef WAIT_FLUSH_VICTIMS_MAX_MSEC 3802 const LOG_LSA * prev_chkpt_redo_lsa,
LOG_LSA * chkpt_smallest_lsa,
int *time_rem)
3804 #define detailed_er_log(...) if (detailed_logging) _er_log_debug (ARG_FILE_LINE, __VA_ARGS__) 3808 int avail_time_msec = 0, time_rem_msec = 0;
3809 #if defined (SERVER_MODE) 3810 double sleep_msecs = 0;
3811 struct timeval cur_time = { 0, 0 };
3813 int flush_per_interval;
3817 float control_est_flush_total = 0;
3818 int control_total_cnt_intervals = 0;
3819 bool ignore_time_limit =
false;
3820 bool flush_if_already_flushed;
3821 bool locked_bcb =
false;
3827 #if defined (SERVER_MODE) 3828 gettimeofday (&cur_time,
NULL);
3836 if (limit_time !=
NULL)
3841 control_total_cnt_intervals = (int) (1000.f / (
float) seq_flusher->
interval_msec + 0.5f);
3845 control_est_flush_total =
3847 (float) control_total_cnt_intervals);
3849 flush_per_interval = (int) (control_est_flush_total - seq_flusher->
control_flushed);
3853 flush_per_interval = (int) (seq_flusher->
flush_rate / control_total_cnt_intervals);
3863 avail_time_msec = -1;
3864 flush_per_interval = seq_flusher->
flush_cnt;
3867 flush_per_interval =
3870 flush_per_interval = seq_flusher->
flush_cnt;
3873 detailed_er_log (
"pgbuf_flush_seq_list (%s): start_idx:%d, flush_cnt:%d, LSA_flush:%d, " 3874 "flush_rate:%.2f, control_flushed:%d, this_interval:%d, " 3875 "Est_tot_flush:%.2f, control_intervals:%d, %d Avail_time:%d\n",
"chkpt",
3892 flush_if_already_flushed =
true;
3896 flush_if_already_flushed =
false;
3921 detailed_er_log (
"pgbuf_flush_seq_list: flush again %d|%d; oldest_unflush_lsa=%lld|%d, " 3975 #if defined(SERVER_MODE) 3976 if (limit_time !=
NULL && ignore_time_limit ==
false)
3978 gettimeofday (&cur_time,
NULL);
3979 if (cur_time.tv_sec > limit_time->tv_sec
3980 || (cur_time.tv_sec == limit_time->tv_sec && cur_time.tv_usec >= limit_time->tv_usec))
3988 && seq_flusher->
flushed_pages < flush_per_interval && ignore_time_limit ==
false)
3990 if (limit_time !=
NULL)
3993 sleep_msecs = time_rem_msec / (flush_per_interval - seq_flusher->
flushed_pages);
3997 sleep_msecs = 1000.0f / (double) (seq_flusher->
flush_rate);
4006 if (thread_p && thread_p->shutdown ==
true)
4013 #if defined (SERVER_MODE) 4014 gettimeofday (&cur_time,
NULL);
4015 if (limit_time !=
NULL)
4018 *time_rem = time_rem_msec;
4037 detailed_er_log (
"pgbuf_flush_seq_list end (%s): %s %s pages : %d written/%d dropped, " 4038 "Remaining_time:%d, Avail_time:%d, Curr:%d/%d,",
"ckpt",
4039 ((time_rem_msec <= 0) ?
"[Expired] " :
""), (ignore_time_limit ?
"[boost]" :
""),
4044 #undef detailed_er_log 4079 #if defined(CUBRID_DEBUG) 4080 if (start_offset < 0 || (start_offset + length) >
DB_PAGESIZE)
4083 "pgbuf_copy_to_area: SYSTEM ERROR.. Trying to copy" 4084 " from beyond page boundary limits. Start_offset = %d, length = %d\n", start_offset, length);
4106 if (do_fetch ==
true)
4113 memcpy (area, (
char *) pgptr + start_offset, length);
4121 #if defined(ENABLE_UNUSED_FUNCTION) 4140 length, area) ==
NULL)
4154 memcpy (area, (
char *) pgptr + start_offset, length);
4199 #if defined(ENABLE_UNUSED_FUNCTION) 4220 #if defined(ENABLE_UNUSED_FUNCTION) 4221 if (do_fetch ==
false)
4236 if (fileio_write_user_area (thread_p, vol_fd, vpid->
pageid, start_offset, length, area) ==
NULL)
4257 memcpy ((
char *) pgptr + start_offset, area, length);
4296 #if defined(SERVER_MODE) && !defined(NDEBUG) 4306 if (free_page ==
FREE)
4333 return &io_pgptr->
prv.
lsa;
4348 if (!
LSA_EQ (ref_lsa, &curr_lsa))
4425 if (
LSA_LT (lsa_ptr, &chkpt_redo_lsa))
4440 #if defined (NDEBUG) 4482 if (prev_tde_algo == tde_algo)
4489 #if !defined(NDEBUG) 4595 *vpid = bufptr->
vpid;
4624 return &(bufptr->
vpid);
4929 long long unsigned alloc_size;
4972 #if defined (SERVER_MODE) 4973 bufptr->owner_mutex = -1;
4979 #if defined(SERVER_MODE) 4980 bufptr->next_wait_thrd =
NULL;
5019 ioptr->
bcb = bufptr;
5021 #if defined(CUBRID_DEBUG) 5050 for (i = 0; i < hashsize; i++)
5068 size_t thrd_num_total;
5073 #if defined(SERVER_MODE) 5076 assert (thrd_num_total == 1);
5088 for (i = 0; i < thrd_num_total; i++)
5092 #if defined(SERVER_MODE) 5171 #define PGBUF_LIMIT_AOUT_BUFFERS 32768 5174 size_t alloc_size = 0;
5187 if (aout_ratio <= 0)
5264 #undef PGBUF_LIMIT_AOUT_BUFFERS 5289 size_t thrd_num_total;
5294 #if defined(SERVER_MODE) 5297 assert (thrd_num_total == 1);
5304 thrd_num_total * PGBUF_HOLDER_ANCHOR_SIZEOF);
5325 for (i = 0; i < thrd_num_total; i++)
5343 if (j == (PGBUF_DEFAULT_FIX_COUNT - 1))
5377 #if defined(SERVER_MODE) 5403 if (holder_set ==
NULL)
5462 while (holder !=
NULL)
5466 if (holder->
bufptr == bufptr)
5506 if (holder_perf_stat_p !=
NULL)
5508 *holder_perf_stat_p = holder->
perf_stat;
5686 int request_fcnt = 1;
5695 *is_latch_wait =
false;
5700 is_page_idle =
false;
5703 is_page_idle =
true;
5705 #if defined (SA_MODE) 5714 is_page_idle =
true;
5719 if (is_page_idle ==
true)
5754 #if defined(SERVER_MODE) 5787 #if defined (SA_MODE) 5827 #if defined (SA_MODE) 5840 #if !defined(NDEBUG) 5916 assert (request_fcnt == 1);
5947 #if defined (SA_MODE) 5962 const char *client_prog_name;
5963 const char *client_user_name;
5964 const char *client_host_name;
5975 client_host_name, client_pid, (request_mode ==
PGBUF_LATCH_READ ?
"READ" :
"WRITE"),
6018 *is_latch_wait =
true;
6063 if (bufptr->
fcnt < 0)
6080 if (bufptr->
fcnt == 0)
6217 #if defined(SERVER_MODE) 6218 pgbuf_wakeup_reader_writer (thread_p, bufptr);
6261 bool aout_enabled =
false;
6268 aout_enabled =
true;
6316 if (thread_private_lru_index != -1)
6326 if (!aout_enabled || thread_private_lru_index == aout_list_id)
6380 if (thread_private_lru_index != bcb_lru_idx)
6413 #if defined(SERVER_MODE) 6420 if (thread_p ==
NULL)
6426 cur_thrd_entry = thread_p;
6427 cur_thrd_entry->request_latch_mode = request_mode;
6428 cur_thrd_entry->request_fix_count = request_fcnt;
6435 assert (bufptr->next_wait_thrd ==
NULL || !bufptr->next_wait_thrd->wait_for_latch_promote);
6437 cur_thrd_entry->next_wait_thrd = bufptr->next_wait_thrd;
6438 bufptr->next_wait_thrd = cur_thrd_entry;
6443 cur_thrd_entry->next_wait_thrd =
NULL;
6444 thrd_entry = bufptr->next_wait_thrd;
6445 if (thrd_entry ==
NULL)
6447 bufptr->next_wait_thrd = cur_thrd_entry;
6451 while (thrd_entry->next_wait_thrd !=
NULL)
6453 thrd_entry = thrd_entry->next_wait_thrd;
6455 thrd_entry->next_wait_thrd = cur_thrd_entry;
6472 thrd_entry = bufptr->next_wait_thrd;
6474 while (thrd_entry !=
NULL)
6476 if (thrd_entry == cur_thrd_entry)
6478 if (prev_thrd_entry ==
NULL)
6480 bufptr->next_wait_thrd = thrd_entry->next_wait_thrd;
6484 prev_thrd_entry->next_wait_thrd = thrd_entry->next_wait_thrd;
6487 thrd_entry->next_wait_thrd =
NULL;
6492 prev_thrd_entry = thrd_entry;
6493 thrd_entry = thrd_entry->next_wait_thrd;
6508 if (pgbuf_timed_sleep (thread_p, bufptr, cur_thrd_entry) !=
NO_ERROR)
6513 #if !defined (NDEBUG) 6523 #if defined(SERVER_MODE) 6539 if (bufptr->next_wait_thrd ==
NULL)
6546 if (bufptr->next_wait_thrd != thrd_entry)
6548 prev_thrd_entry = bufptr->next_wait_thrd;
6549 while (prev_thrd_entry->next_wait_thrd !=
NULL)
6551 if (prev_thrd_entry->next_wait_thrd == thrd_entry)
6553 prev_thrd_entry->next_wait_thrd = thrd_entry->next_wait_thrd;
6554 thrd_entry->next_wait_thrd =
NULL;
6557 prev_thrd_entry = prev_thrd_entry->next_wait_thrd;
6563 bufptr->next_wait_thrd = thrd_entry->next_wait_thrd;
6564 thrd_entry->next_wait_thrd =
NULL;
6565 while (bufptr->next_wait_thrd !=
NULL)
6567 curr_thrd_entry = bufptr->next_wait_thrd;
6574 bufptr->
fcnt += curr_thrd_entry->request_fix_count;
6579 bufptr->next_wait_thrd = curr_thrd_entry->next_wait_thrd;
6580 curr_thrd_entry->next_wait_thrd =
NULL;
6583 pgbuf_wakeup (curr_thrd_entry);
6613 int save_request_latch_mode;
6614 const char *client_prog_name;
6615 const char *client_user_name;
6616 const char *client_host_name;
6641 to.tv_sec = (int) time (
NULL) + wait_secs;
6644 if (thrd_entry->event_stats.trace_slow_query ==
true)
6650 r = pthread_cond_timedwait (&thrd_entry->wakeup_cond, &thrd_entry->th_entry_lock, &to);
6652 if (thrd_entry->event_stats.trace_slow_query ==
true)
6673 if (pgbuf_timed_sleep_error_handling (thread_p, bufptr, thrd_entry) ==
NO_ERROR)
6681 else if (r == ETIMEDOUT)
6699 save_request_latch_mode = thrd_entry->request_latch_mode;
6703 if (pgbuf_timed_sleep_error_handling (thread_p, bufptr, thrd_entry) ==
NO_ERROR)
6730 const char *client_prog_name;
6731 const char *client_user_name;
6732 const char *client_host_name;
6741 client_host_name, client_pid);
6750 "pgbuf_timed_sleep: Likely a system error. Trying to abort a transaction twice.\n");
6754 else if (old_wait_msecs > 0)
6761 &client_host_name, &client_pid);
6764 client_host_name, client_pid, (save_request_latch_mode ==
PGBUF_LATCH_READ ?
"READ" :
"WRITE"),
6805 for (thrd_entry = bufptr->next_wait_thrd; thrd_entry !=
NULL; thrd_entry = next_thrd_entry)
6807 next_thrd_entry = thrd_entry->next_wait_thrd;
6813 if (prev_thrd_entry ==
NULL)
6815 bufptr->next_wait_thrd = next_thrd_entry;
6819 prev_thrd_entry->next_wait_thrd = next_thrd_entry;
6821 thrd_entry->next_wait_thrd =
NULL;
6831 prev_thrd_entry = thrd_entry;
6844 bufptr->
fcnt += thrd_entry->request_fix_count;
6849 if (prev_thrd_entry ==
NULL)
6851 bufptr->next_wait_thrd = next_thrd_entry;
6855 prev_thrd_entry->next_wait_thrd = next_thrd_entry;
6857 thrd_entry->next_wait_thrd =
NULL;
6860 pgbuf_wakeup (thrd_entry);
6864 if (prev_thrd_entry ==
NULL)
6866 bufptr->next_wait_thrd = next_thrd_entry;
6870 prev_thrd_entry->next_wait_thrd = next_thrd_entry;
6872 thrd_entry->next_wait_thrd =
NULL;
6879 prev_thrd_entry = thrd_entry;
6902 #if defined(SERVER_MODE) 6907 UINT64 lock_wait_time = 0;
6915 while (bufptr !=
NULL)
6919 #if defined(SERVER_MODE) 6937 if (loop_cnt++ < mbw_cnt)
6966 #if defined(SERVER_MODE) 6989 while (bufptr !=
NULL)
6993 #if defined(SERVER_MODE) 7012 if (loop_cnt++ < mbw_cnt)
7055 #if defined(SERVER_MODE) 7059 UINT64 lock_wait_time = 0;
7104 #if defined(SERVER_MODE) 7108 UINT64 lock_wait_time = 0;
7149 while (curr_bufptr !=
NULL)
7151 if (curr_bufptr == bufptr)
7155 prev_bufptr = curr_bufptr;
7159 if (curr_bufptr ==
NULL)
7173 if (prev_bufptr ==
NULL)
7204 #if defined(SERVER_MODE) 7208 UINT64 lock_wait_time = 0;
7213 if (thread_p ==
NULL)
7219 cur_thrd_entry = thread_p;
7220 cur_buffer_lock = hash_anchor->
lock_next;
7223 while (cur_buffer_lock !=
NULL)
7228 cur_thrd_entry->next_wait_thrd = cur_buffer_lock->next_wait_thrd;
7229 cur_buffer_lock->next_wait_thrd = cur_thrd_entry;
7230 pgbuf_sleep (cur_thrd_entry, &hash_anchor->hash_mutex);
7253 thrd_entry = cur_buffer_lock->next_wait_thrd;
7255 while (thrd_entry !=
NULL)
7257 if (thrd_entry == cur_thrd_entry)
7259 if (prev_thrd_entry ==
NULL)
7261 cur_buffer_lock->next_wait_thrd = thrd_entry->next_wait_thrd;
7265 prev_thrd_entry->next_wait_thrd = thrd_entry->next_wait_thrd;
7268 thrd_entry->next_wait_thrd =
NULL;
7274 prev_thrd_entry = thrd_entry;
7275 thrd_entry = thrd_entry->next_wait_thrd;
7282 cur_buffer_lock = cur_buffer_lock->
lock_next;
7289 cur_buffer_lock = &(pgbuf_Pool.
buf_lock_table[cur_thrd_entry->index]);
7290 cur_buffer_lock->
vpid = *vpid;
7291 cur_buffer_lock->next_wait_thrd =
NULL;
7293 hash_anchor->
lock_next = cur_buffer_lock;
7317 #if defined(SERVER_MODE) 7321 UINT64 lock_wait_time = 0;
7326 if (need_hash_mutex)
7347 prev_buffer_lock =
NULL;
7348 cur_buffer_lock = hash_anchor->
lock_next;
7350 while (cur_buffer_lock !=
NULL)
7357 prev_buffer_lock = cur_buffer_lock;
7358 cur_buffer_lock = cur_buffer_lock->
lock_next;
7361 if (cur_buffer_lock !=
NULL)
7363 if (prev_buffer_lock ==
NULL)
7375 while ((cur_thrd_entry = cur_buffer_lock->next_wait_thrd) !=
NULL)
7377 cur_buffer_lock->next_wait_thrd = cur_thrd_entry->next_wait_thrd;
7378 cur_thrd_entry->next_wait_thrd =
NULL;
7379 pgbuf_wakeup_uncond (cur_thrd_entry);
7403 PERF_UTIME_TRACKER time_tracker_alloc_bcb = PERF_UTIME_TRACKER_INITIALIZER;
7404 PERF_UTIME_TRACKER time_tracker_alloc_search_and_wait = PERF_UTIME_TRACKER_INITIALIZER;
7409 #if defined (SERVER_MODE) 7413 bool high_priority =
false;
7445 PERF_UTIME_TRACKER_START (thread_p, &time_tracker_alloc_bcb);
7448 PERF_UTIME_TRACKER_START (thread_p, &time_tracker_alloc_search_and_wait);
7459 #if defined (SERVER_MODE) 7463 high_priority = high_priority ||
VACUUM_IS_THREAD_VACUUM (thread_p) || pgbuf_is_thread_high_priority (thread_p);
7471 assert (pgbuf_Pool.direct_victims.bcb_victims[thread_p->index] ==
NULL);
7480 if (!pgbuf_Pool.direct_victims.waiter_threads_high_priority->produce (thread_p))
7490 if (!pgbuf_Pool.direct_victims.waiter_threads_low_priority->produce (thread_p))
7502 if (!pgbuf_Pool.direct_victims.waiter_threads_high_priority->produce (thread_p))
7526 PERF_UTIME_TRACKER_TIME (thread_p, &time_tracker_alloc_search_and_wait, pstat_cond_wait);
7532 bufptr = pgbuf_get_direct_victim (thread_p);
7536 high_priority =
true;
7546 if (pgbuf_Pool.direct_victims.bcb_victims[thread_p->index] !=
NULL)
7551 pgbuf_Pool.direct_victims.bcb_victims[thread_p->index] =
NULL;
7627 #if defined (ENABLE_SYSTEMTAP) 7628 bool monitored =
false;
7629 QUERY_ID query_id = NULL_QUERY_ID;
7690 bufptr->
vpid = *vpid;
7703 #if defined(ENABLE_SYSTEMTAP) 7705 if (query_id != NULL_QUERY_ID)
7708 CUBRID_IO_READ_START (query_id);
7718 else if (success ==
true)
7738 #if defined(ENABLE_SYSTEMTAP) 7739 if (monitored ==
true)
7765 #if defined(ENABLE_SYSTEMTAP) 7766 if (monitored ==
true)
7781 #if !defined (NDEBUG) 7805 #if defined(CUBRID_DEBUG) 7847 #if defined(SERVER_MODE) 7848 if (thread_p ==
NULL)
8060 if (synchronous ==
true)
8090 #if defined(SERVER_MODE) 8138 #if defined(SERVER_MODE) 8168 #define PAGE_ADD_REFRESH_STAT \ 8169 MAX (2 * pgbuf_Pool.num_buffers / PGBUF_SHARED_LRU_COUNT, 10000) 8172 unsigned int lru_idx, refresh_stat_cnt;
8178 if (refresh_stat_cnt == 0)
8180 int shared_lru_bcb_sum;
8181 int max_bcb, min_bcb;
8182 int lru_idx_with_max;
8184 int curr_avoid_lru_idx;
8186 shared_lru_bcb_sum = 0;
8189 lru_idx_with_max = -1;
8194 shared_lru_bcb_sum += this_lru_cnt;
8196 if (this_lru_cnt > max_bcb)
8198 max_bcb = this_lru_cnt;
8199 lru_idx_with_max =
i;
8202 if (this_lru_cnt < min_bcb)
8204 min_bcb = this_lru_cnt;
8208 if (shared_lru_bcb_sum > pgbuf_Pool.
num_buffers / 10
8209 && (max_bcb > (
int) (1.3f * shared_lru_bcb_sum) / PGBUF_SHARED_LRU_COUNT || max_bcb > 2 * min_bcb))
8216 if (curr_avoid_lru_idx == -1
8218 < shared_lru_bcb_sum / PGBUF_SHARED_LRU_COUNT))
8235 #undef PAGE_ADD_REFRESH_STAT 8250 #define PERF(id) if (detailed_perf) perfmon_inc_stat (thread_p, id) 8256 int private_lru_idx;
8258 bool restrict_other =
false;
8259 bool searched_own =
false;
8260 UINT64 initial_consume_cursor, current_consume_cursor;
8261 PERF_UTIME_TRACKER perf_tracker = PERF_UTIME_TRACKER_INITIALIZER;
8300 PERF_UTIME_TRACKER_START (thread_p, &perf_tracker);
8328 searched_own =
true;
8341 PERF_UTIME_TRACKER_START (thread_p, &perf_tracker);
8370 PERF_UTIME_TRACKER_START (thread_p, &perf_tracker);
8389 && ((int) (current_consume_cursor - initial_consume_cursor) <= pgbuf_Pool.
num_LRU_list)
8440 #if defined (SERVER_MODE) 8452 return bcb->
fcnt != 0;
8472 #if defined (SERVER_MODE) 8496 #define PERF(pstatid) if (perf_tracking) perfmon_inc_stat (thread_p, pstatid) 8497 #define MAX_DEPTH 1000 8500 int found_victim_cnt = 0;
8502 int lru_victim_cnt = 0;
8538 if (lru_victim_cnt <= 0)
8542 assert (lru_victim_cnt == 0);
8562 found_victim_cnt = 0;
8563 bufptr_victimizable =
NULL;
8567 if (victim_hint ==
NULL)
8569 bufptr_start = lru_list->
bottom;
8573 bufptr_start = victim_hint;
8577 bufptr = bufptr->
prev_BCB, search_cnt++)
8590 if (bufptr_victimizable ==
NULL)
8592 bufptr_victimizable = bufptr;
8595 if (bufptr_victimizable != victim_hint
8596 && ATOMIC_CAS_ADDR (&lru_list->
victim_hint, victim_hint, bufptr_victimizable))
8605 if (found_victim_cnt >= lru_victim_cnt)
8619 if (bufptr_victimizable ==
NULL)
8626 #if defined (SERVER_MODE) 8628 if (pgbuf_Pool.direct_victims.waiter_threads_low_priority->size ()
8631 pgbuf_panic_assign_direct_victims_from_lru (thread_p, lru_list, bufptr->
prev_BCB);
8658 if (bufptr_victimizable ==
NULL)
8660 bufptr_victimizable = bufptr;
8662 if (bufptr != victim_hint && ATOMIC_CAS_ADDR (&lru_list->
victim_hint, victim_hint, bufptr_victimizable))
8670 if (found_victim_cnt >= lru_victim_cnt)
8679 if (bufptr_victimizable ==
NULL && victim_hint !=
NULL)
8710 #if defined (SERVER_MODE) 8722 #define MAX_DEPTH 1000 8729 if (bcb_start ==
NULL)
8737 for (bcb = bcb_start;
8787 pgbuf_direct_victims_maintenance (
THREAD_ENTRY * thread_p)
8789 #define DEFAULT_ASSIGNS_PER_ITERATION 5 8790 int nassigns = DEFAULT_ASSIGNS_PER_ITERATION;
8796 static int prv_index = 0;
8797 static int shr_index = 0;
8800 for (index = prv_index, restarted =
false;
8801 pgbuf_is_any_thread_waiting_for_direct_victim () && nassigns > 0 && index != prv_index && !restarted;
8809 for (index = shr_index, restarted =
false;
8810 pgbuf_is_any_thread_waiting_for_direct_victim () && nassigns > 0 && index != shr_index && !restarted;
8813 pgbuf_lfcq_assign_direct_victims (thread_p, index, &nassigns);
8817 #undef DEFAULT_ASSIGNS_PER_ITERATION 8829 pgbuf_lfcq_assign_direct_victims (
THREAD_ENTRY * thread_p,
int lru_idx,
int *nassign_inout)
8840 nassigned = pgbuf_panic_assign_direct_victims_from_lru (thread_p, lru_list, victim_hint);
8841 if (nassigned == 0 && lru_list->
count_vict_cand > 0 && pgbuf_is_any_thread_waiting_for_direct_victim ())
8855 nassigned = pgbuf_panic_assign_direct_victims_from_lru (thread_p, lru_list, lru_list->
bottom);
8859 (*nassign_inout) -= nassigned;
8895 lru_list->
top = bcb;
8934 lru_list->
top = bcb;
8955 lru_list->
top = bcb;
8973 if (bcb_next ==
NULL)
9021 lru_list->
top = bcb;
9068 threshold = MAX (1, threshold);
9087 for (bcb_bottom = lru_list->
bottom_1; threshold < lru_list->count_lru1; bcb_bottom = bcb_bottom->
prev_BCB)
9122 threshold = MAX (1, threshold);
9135 for (bcb_bottom = lru_list->
bottom_2; threshold < lru_list->count_lru2; bcb_bottom = bcb_prev)
9173 threshold = MAX (1, threshold);
9233 #if defined (SERVER_MODE) 9534 if (lru_list->
top == bufptr)
9539 if (lru_list->
bottom == bufptr)
9568 if (bcb_prev !=
NULL)
9618 if (bcb == lru_list->
bottom)
9644 #if defined(SERVER_MODE) 9725 #if defined(SERVER_MODE) 9743 if (aout_buf ==
NULL)
9753 aout_list_id = aout_buf->
lru_idx;
9799 return aout_list_id;
9814 int cnt_removed = 0;
9824 while (aout_buf !=
NULL)
9826 if (aout_buf->
lru_idx != lru_idx)
9828 aout_buf = aout_buf->
next;
9832 aout_buf_next = aout_buf->
next;
9878 aout_buf = aout_buf_next;
9904 #if defined(ENABLE_SYSTEMTAP) 9905 QUERY_ID query_id = NULL_QUERY_ID;
9906 bool monitored =
false;
9908 bool was_dirty =
false, uses_dwb;
9921 *is_bcb_locked =
true;
9925 #if !defined (NDEBUG) && defined (SERVER_MODE) 9929 int thread_index = thread_p->index;
9936 if (holder->
bufptr == bufptr)
9994 if (dwb_slot !=
NULL)
9997 goto copy_unflushed_lsa;
10001 copy_unflushed_lsa:
10007 *is_bcb_locked =
false;
10024 #if defined(ENABLE_SYSTEMTAP) 10026 if (query_id != NULL_QUERY_ID)
10029 CUBRID_IO_WRITE_START (query_id);
10041 if (dwb_slot ==
NULL)
10046 *is_bcb_locked =
true;
10047 goto start_copy_page;
10066 #if defined(ENABLE_SYSTEMTAP) 10067 if (monitored ==
true)
10076 *is_bcb_locked =
true;
10080 #if defined (SERVER_MODE) 10081 if (bufptr->next_wait_thrd !=
NULL)
10092 #if defined (SERVER_MODE) 10094 if (is_page_flush_thread && (pgbuf_Page_post_flush_daemon !=
NULL)
10095 && pgbuf_is_any_thread_waiting_for_direct_victim () && pgbuf_Pool.flushed_bcbs->produce (bufptr))
10098 pgbuf_Page_post_flush_daemon->
wakeup ();
10108 *is_bcb_locked =
true;
10111 #if defined (SERVER_MODE) 10112 if (bufptr->next_wait_thrd !=
NULL)
10137 #if defined (SERVER_MODE) 10141 PERF_UTIME_TRACKER timetr;
10143 PERF_UTIME_TRACKER_START (thread_p, &timetr);
10147 for (crt_waiter = bcb->next_wait_thrd; crt_waiter !=
NULL; crt_waiter = save_next_waiter)
10149 save_next_waiter = crt_waiter->next_wait_thrd;
10154 if (prev_waiter !=
NULL)
10156 prev_waiter->next_wait_thrd = save_next_waiter;
10160 bcb->next_wait_thrd = save_next_waiter;
10163 crt_waiter->next_wait_thrd =
NULL;
10164 pgbuf_wakeup_uncond (crt_waiter);
10168 prev_waiter = crt_waiter;
10184 #if defined(SERVER_MODE) 10188 thrd_entry = bufptr->next_wait_thrd;
10189 while (thrd_entry !=
NULL)
10196 thrd_entry = thrd_entry->next_wait_thrd;
10211 #if !defined(NDEBUG) 10280 for (bufid = 0; bufid < pgbuf_Pool.
num_buffers; bufid++)
10287 if (bufptr->
fcnt <= 0)
10367 #if defined(NDEBUG) 10444 #if defined(CUBRID_DEBUG) 10483 pgbuf_dump_if_any_fixed (
void)
10488 #if defined(SERVER_MODE) 10493 for (bufid = 0; bufid < pgbuf_Pool.
num_buffers; bufid++)
10506 consistent = pgbuf_is_consistent (bufptr, 0);
10535 const char *latch_mode_str, *zone_str, *consistent_str;
10536 #if defined(SERVER_MODE) 10540 (void) fflush (stderr);
10541 (void) fflush (stdout);
10542 (void) fprintf (stdout,
"\n\n");
10543 (void) fprintf (stdout,
"Num buffers = %d\n", pgbuf_Pool.
num_buffers);
10547 (void) fprintf (stdout,
"Lastperm volid = %d, Num permvols of tmparea = %d\n", pgbuf_Pool.last_perm_volid,
10548 pgbuf_Pool.num_permvols_tmparea);
10550 if (pgbuf_Pool.permvols_tmparea_volids !=
NULL)
10552 (void) fprintf (stdout,
"Permanent volumes with tmp area: ");
10553 for (i = 0; i < pgbuf_Pool.num_permvols_tmparea; i++)
10557 (void) fprintf (stdout,
", ");
10559 (void) fprintf (stdout,
"%d", pgbuf_Pool.permvols_tmparea_volids[i]);
10561 (void) fprintf (stdout,
"\n");
10566 (void) fprintf (stdout,
10567 " Buf Volid Pageid Fcnt LatchMode D A F Zone Lsa consistent Bufaddr Usrarea\n");
10569 for (bufid = 0; bufid < pgbuf_Pool.
num_buffers; bufid++)
10574 if (bufptr->
fcnt > 0)
10585 consistent = pgbuf_is_consistent (bufptr, 0);
10597 fprintf (stdout,
"%4d %5d %6d %4d %9s %1d %1d %1d %11s %lld|%4d %10s %p %p-%p\n",
10608 (void) fprintf (stdout,
"Number of fetched buffers = %d\nNumber of dirty buffers = %d\n", nfetched, ndirty);
10631 pgbuf_is_consistent (
const PGBUF_BCB * bufptr,
int likely_bad_after_fixcnt)
10635 bool is_page_corrupted;
10648 if (malloc_io_pgptr ==
NULL)
10683 &is_page_corrupted) !=
NO_ERROR || is_page_corrupted)
10714 #if !defined(NDEBUG) 10721 p = caller_file +
strlen (caller_file);
10724 if (p == caller_file)
10729 if (*p ==
'/' || *p ==
'\\')
10740 sprintf (holder->
fixed_at,
"%s:%d ", p, caller_line);
10745 sprintf (buf,
"%s:%d ", p, caller_line);
10758 #if defined(SERVER_MODE) 10760 pgbuf_sleep (
THREAD_ENTRY * thread_p, pthread_mutex_t * mutex_p)
10777 r = pthread_cond_signal (&thread_p->wakeup_cond);
10788 thread_p->get_posix_id ());
10804 r = pthread_cond_signal (&thread_p->wakeup_cond);
10848 #if defined (SERVER_MODE) 10851 pgbuf_Page_flush_daemon->
wakeup ();
10856 PERF_UTIME_TRACKER dummy_time_tracker;
10860 dummy_time_tracker.is_perf_tracking =
false;
10894 #if defined (SERVER_MODE) 10903 pgbuf_is_thread_high_priority (
THREAD_ENTRY * thread_p)
10979 #define PGBUF_PAGES_COUNT_THRESHOLD 4 10982 LOG_LSA log_newest_oldest_unflush_lsa;
10983 VPID first_vpid, vpid;
10986 bool prev_page_dirty =
true;
10987 int dirty_pages_cnt = 0;
10990 bool search_nondirty;
10993 bool was_page_flushed =
false;
10994 #if defined(ENABLE_SYSTEMTAP) 10995 QUERY_ID query_id = -1;
10996 bool monitored =
false;
10999 #if defined(ENABLE_SYSTEMTAP) 11001 if (query_id != NULL_QUERY_ID)
11004 CUBRID_IO_WRITE_START (query_id);
11023 search_nondirty =
false;
11027 if (forward ==
true)
11052 search_nondirty =
true;
11061 if (bufptr ==
NULL)
11065 if (search_nondirty ==
true)
11067 if (forward ==
false)
11080 if (forward ==
true)
11087 search_nondirty =
true;
11103 if (search_nondirty ==
true)
11105 if (forward ==
false)
11118 if (forward ==
true)
11125 search_nondirty =
true;
11139 if (search_nondirty ==
false)
11142 if (forward ==
true)
11149 search_nondirty =
true;
11157 if (prev_page_dirty ==
false)
11191 if (prev_page_dirty ==
true)
11206 if (helper->
npages <= 1)
11218 if (was_page_flushed)
11220 *flushed_pages = 1;
11239 save_first_error =
error;
11243 if (was_page_flushed)
11252 "pgbuf_flush_page_and_neighbors_fb: collected_pages:%d, written:%d, back_offset:%d, fwd_offset%d, " 11257 *flushed_pages = written_pages;
11260 return save_first_error;
11261 #undef PGBUF_PAGES_COUNT_THRESHOLD 11310 bool is_bcb_locked =
true;
11428 #if !defined(NDEBUG) 11443 int saved_pages_cnt = 0;
11448 bool req_page_has_watcher;
11449 bool req_page_has_group =
false;
11450 int er_status_get_hfid =
NO_ERROR;
11451 VPID req_page_groupid;
11452 bool has_dealloc_prevent_flag =
false;
11455 #if defined(PGBUF_ORDERED_DEBUG) 11456 static unsigned int global_ordered_fix_id = 0;
11457 unsigned int ordered_fix_id;
11462 #if defined(PGBUF_ORDERED_DEBUG) 11463 ordered_fix_id = global_ordered_fix_id++;
11466 #if !defined(NDEBUG) 11472 req_page_has_watcher =
false;
11491 if (req_page_has_group ==
false)
11500 req_page_holder_info.
watcher[0] = req_watcher;
11514 #if !defined(NDEBUG) 11515 ret_pgptr =
pgbuf_fix_debug (thread_p, req_vpid, fetch_mode, request_mode, latch_condition, caller_file, caller_line);
11517 ret_pgptr = pgbuf_fix_release (thread_p, req_vpid, fetch_mode, request_mode, latch_condition);
11520 if (ret_pgptr !=
NULL)
11542 er_status_get_hfid = er_status;
11548 #if !defined(NDEBUG) 11554 req_page_has_watcher =
true;
11609 has_dealloc_prevent_flag =
true;
11614 while (holder !=
NULL)
11621 holder = next_holder;
11639 #if defined(PGBUF_ORDERED_DEBUG) 11641 "ORDERED_FIX(%u): page VPID:(%d,%d) (GROUP:%d,%d; rank:%d/%d) " 11642 "invalid, while having holder: %X ", ordered_fix_id, req_vpid->
volid, req_vpid->
pageid,
11658 int holder_fix_cnt;
11687 while (pg_watcher !=
NULL)
11689 #if !defined(NDEBUG) 11701 else if (page_rank != pg_watcher->
curr_rank)
11704 char additional_msg[128];
11705 snprintf (additional_msg,
sizeof (additional_msg) - 1,
"different page ranks:%d,%d", page_rank,
11720 char additional_msg[128];
11721 snprintf (additional_msg,
sizeof (additional_msg) - 1,
"different GROUP_ID : (%d,%d) and (%d,%d)",
11731 if (save_page_ptr ==
NULL)
11733 save_page_ptr = pg_watcher->
pgptr;
11740 ordered_holders_info[saved_pages_cnt].
watcher[j] = pg_watcher;
11747 #if defined(PGBUF_ORDERED_DEBUG) 11749 "ordered_fix(%u): check_watcher: pgptr:%X, VPID:(%d,%d), GROUP:%d,%d, rank:%d/%d, " 11750 "holder_fix_count:%d, holder_watch_count:%d, holder_fixed_at:%s", ordered_fix_id,
11755 pg_watcher = pg_watcher->
next;
11760 VPID_COPY (&ordered_holders_info[saved_pages_cnt].group_id, &group_id);
11761 ordered_holders_info[saved_pages_cnt].
rank = page_rank;
11764 if (req_page_has_group ==
true)
11779 #
if defined(PGBUF_ORDERED_DEBUG)
11781 "ordered_fix(%u): save_watchers (%d): pgptr:%X, VPID:(%d,%d), " 11782 "GROUP:(%d,%d), rank:%d(page_rank:%d), holder_fix_count:%d, holder_watch_count:%d",
11783 ordered_fix_id, ordered_holders_info[saved_pages_cnt].watch_count, save_page_ptr,
11784 ordered_holders_info[saved_pages_cnt].vpid.volid,
11785 ordered_holders_info[saved_pages_cnt].
vpid.
pageid,
11788 ordered_holders_info[saved_pages_cnt].
rank, page_rank, holder_fix_cnt,
11793 else if (diff == 0)
11804 #if defined(PGBUF_ORDERED_DEBUG) 11806 "ordered_fix(%u): ignore: pgptr:%X, VPID:(%d,%d) " 11807 "GROUP:(%d,%d), rank:%d --- ignored", ordered_fix_id, save_page_ptr,
11808 ordered_holders_info[saved_pages_cnt].vpid.volid,
11809 ordered_holders_info[saved_pages_cnt].
vpid.
pageid,
11812 ordered_holders_info[saved_pages_cnt].
rank);
11816 holder = next_holder;
11821 for (i = 0; i < saved_pages_cnt; i++)
11823 int j, holder_fix_cnt;
11824 #if defined(PGBUF_ORDERED_DEBUG) 11825 int holder_fix_cnt_save;
11833 if (holder ==
NULL)
11847 #if defined(PGBUF_ORDERED_DEBUG) 11848 holder_fix_cnt_save = holder_fix_cnt;
11852 assert (holder_fix_cnt > 0);
11856 while (holder_fix_cnt-- > 0)
11861 for (j = 0; j < ordered_holders_info[
i].
watch_count; j++)
11865 pg_watcher = ordered_holders_info[
i].
watcher[j];
11870 #if defined(PGBUF_ORDERED_DEBUG) 11872 "ordered_fix(%u): unfix & clear_watcher(%d/%d): pgptr:%X, VPID:(%d,%d), GROUP:%d,%d, " 11873 "rank:%d/%d, latch_mode:%d, holder_fix_cnt:%d", ordered_fix_id, j + 1,
11874 ordered_holders_info[i].watch_count, pg_watcher->
pgptr, ordered_holders_info[i].
vpid.
volid,
11881 #if !defined(NDEBUG) 11885 holder = next_holder;
11896 if (req_page_has_group ==
false)
11898 #if !defined(NDEBUG) 11901 while (holder !=
NULL)
11914 if (has_dealloc_prevent_flag ==
true)
11918 has_dealloc_prevent_flag =
false;
11925 er_status_get_hfid = er_status;
11934 if (er_status_get_hfid ==
NO_ERROR)
11941 #if defined(PGBUF_ORDERED_DEBUG) 11943 "ordered_fix(%u) : restore_pages: %d, req_VPID(%d,%d), GROUP(%d,%d), rank:%d/%d", ordered_fix_id,
11949 if (req_page_has_group ==
true || er_status_get_hfid ==
NO_ERROR)
11951 if (req_page_has_group)
11953 VPID_COPY (&(ordered_holders_info[saved_pages_cnt].group_id), &req_watcher->
group_id);
11959 VPID_COPY (&(ordered_holders_info[saved_pages_cnt].group_id), &req_page_groupid);
11961 VPID_COPY (&(ordered_holders_info[saved_pages_cnt].vpid), req_vpid);
11962 if (req_page_has_group)
11964 ordered_holders_info[saved_pages_cnt].
rank = req_watcher->
curr_rank;
11968 if (
VPID_EQ (&(ordered_holders_info[saved_pages_cnt].group_id), req_vpid))
11975 ordered_holders_info[saved_pages_cnt].
rank = req_watcher->
curr_rank;
11982 if (saved_pages_cnt > 1)
11988 for (i = 0; i < saved_pages_cnt; i++)
11990 if (
VPID_EQ (req_vpid, &(ordered_holders_info[i].vpid)))
11992 curr_request_mode = request_mode;
11997 curr_request_mode = ordered_holders_info[
i].
latch_mode;
12001 #if !defined(NDEBUG) 12003 pgbuf_fix_debug (thread_p, &(ordered_holders_info[i].vpid), curr_fetch_mode, curr_request_mode,
12007 pgbuf_fix_release (thread_p, &(ordered_holders_info[i].vpid), curr_fetch_mode, curr_request_mode,
12026 if (!
VPID_EQ (req_vpid, &(ordered_holders_info[i].vpid)))
12028 int prev_er_status = er_status;
12031 ordered_holders_info[i].
vpid.
pageid, prev_er_status);
12047 if (
VPID_EQ (req_vpid, &(ordered_holders_info[i].vpid)))
12051 if (has_dealloc_prevent_flag ==
true)
12055 has_dealloc_prevent_flag =
false;
12058 if (req_watcher !=
NULL)
12060 #if !defined(NDEBUG) 12066 req_page_has_watcher =
true;
12068 #if defined(PGBUF_ORDERED_DEBUG) 12070 "ordered_fix(%u) : fixed req page, VPID:(%d,%d), GROUP:%d,%d, " 12071 "rank:%d, pgptr:%X, holder_fix_count:%d, holder_watch_count:%d, holder_fixed_at:%s, ",
12072 ordered_fix_id, ordered_holders_info[i].vpid.volid, ordered_holders_info[i].
vpid.
pageid,
12084 assert (ordered_holders_info[i].prevent_dealloc);
12092 #if defined(PGBUF_ORDERED_DEBUG) 12094 "ordered_fix(%u) : restore_holder:%X, VPID:(%d,%d), pgptr:%X, holder_fix_count:%d, " 12095 "holder_watch_count:%d, holder_fixed_at:%s, saved_fix_cnt:%d, saved_watch_cnt:%d",
12096 ordered_fix_id, holder, ordered_holders_info[i].vpid.volid,
12102 for (j = 1; j < ordered_holders_info[
i].
watch_count; j++)
12104 #if !defined(NDEBUG) 12106 pgbuf_fix_debug (thread_p, &(ordered_holders_info[i].vpid), curr_fetch_mode, curr_request_mode,
12110 pgbuf_fix_release (thread_p, &(ordered_holders_info[i].vpid), curr_fetch_mode, curr_request_mode,
12121 for (j = 0; j < ordered_holders_info[
i].
watch_count; j++)
12123 #if !defined(NDEBUG) 12126 false, caller_file, caller_line);
12132 #if defined(PGBUF_ORDERED_DEBUG) 12134 "ordered_fix(%u) : restore_watcher:%X, GROUP:%d,%d, rank:%d/%d," 12135 " pgptr:%X, holder_fix_count:%d, holder_watch_count:%d, holder_fixed_at:%s",
12136 ordered_fix_id, ordered_holders_info[i].watcher[j],
12137 ordered_holders_info[i].watcher[j]->group_id.volid,
12151 er_status = er_status_get_hfid;
12158 if (req_page_has_watcher)
12174 for (i = 0; i < saved_pages_cnt; i++)
12176 if (ordered_holders_info[i].prevent_dealloc)
12182 if (bufptr ==
NULL)
12234 if (do_unfix ==
true)
12245 assert (do_unfix ==
false || *pgptr ==
NULL);
12282 #if !defined (NDEBUG) 12297 #if !defined(NDEBUG) 12307 pgptr = watcher_object->
pgptr;
12316 while (watcher !=
NULL)
12318 if (watcher == watcher_object)
12323 watcher = watcher->
prev;
12332 #if !defined(NDEBUG) 12349 #if !defined(NDEBUG) 12353 const char *caller_file,
const int caller_line)
12360 #if !defined(NDEBUG) 12386 watcher->
pgptr = pgptr;
12388 if (clear_unfix_flag)
12395 #if !defined(NDEBUG) 12396 p = (
char *) caller_file +
strlen (caller_file);
12399 if (p == caller_file)
12404 if (*p ==
'/' || *p ==
'\\')
12427 #if !defined (NDEBUG) 12430 PGBUF_WATCHER * watcher,
const char *caller_file,
const int caller_line)
12464 #if !defined (NDEBUG) 12491 if (bufptr == holder->
bufptr)
12513 #if !defined(NDEBUG) 12517 pgptr = watcher_object->
pgptr;
12524 else if (watcher_object->
prev !=
NULL)
12526 (watcher_object->
prev)->next = watcher_object->
next;
12534 else if (watcher_object->
next !=
NULL)
12536 (watcher_object->
next)->prev = watcher_object->
prev;
12552 #if !defined(NDEBUG) 12555 const char *caller_file,
const int caller_line)
12568 #if !defined(NDEBUG) 12579 page_ptr = old_watcher->
pgptr;
12587 #if !defined(NDEBUG) 12666 #if !defined(NDEBUG) 12678 p = (
char *) caller_file +
strlen (caller_file);
12681 if (p == caller_file)
12686 if (*p ==
'/' || *p ==
'\\')
12697 char prev_init[256];
12698 strncpy (prev_init, watcher->
init_at, sizeof (watcher->
init_at) - 1);
12699 prev_init[
sizeof (prev_init) - 1] =
'\0';
12704 snprintf (watcher->
init_at, sizeof (watcher->
init_at) - 1,
"%s:%d", p, caller_line);
12748 quota = &(pgbuf_Pool.
quota);
12755 #if defined (SERVER_MODE) 12794 quota = &(pgbuf_Pool.
quota);
12840 return error_status;
12853 #if defined (SERVER_MODE) 12857 monitor = &(pgbuf_Pool.
monitor);
12891 #if defined (SERVER_MODE) 12892 if (pgbuf_Monitor_locks)
12895 if (monitor->bcb_locks ==
NULL)
12909 return error_status;
12924 float prv_real_ratio;
12926 float prv_flush_ratio;
12927 float shared_flush_ratio;
12929 bool use_prv_size =
false;
12931 int total_prv_target = 0;
12932 int this_prv_target = 0;
12938 *lru_sum_flush_priority = 0;
12945 diff = prv_quota - prv_real_ratio;
12947 prv_flush_ratio = prv_real_ratio * (1.0f -
diff);
12948 prv_flush_ratio = MIN (1.0f, prv_flush_ratio);
12959 this_prv_target = MIN (this_prv_target, lru_list->
count_lru3);
12960 if (this_prv_target > 0)
12962 total_prv_target += this_prv_target;
12965 if (total_prv_target == 0)
12988 use_prv_size =
true;
12989 prv_flush_ratio = 1.0f;
12996 shared_flush_ratio = 1.0f - prv_flush_ratio;
13007 if (prv_flush_ratio == 0.0f)
13022 this_prv_target = MIN (this_prv_target, lru_list->
count_lru3);
13024 if (this_prv_target > 0)
13027 prv_flush_ratio * ((float) this_prv_target / (
float) total_prv_target);
13054 #define MAX_PRIVATE_RATIO 0.998f 13055 #define MIN_PRIVATE_RATIO 0.01f 13060 int all_private_quota;
13061 int sum_private_lru_activity_total = 0;
13065 int lru_shared_hits = 0;
13066 int lru_private_hits = 0;
13067 float private_ratio;
13068 int avg_shared_lru_size;
13069 int shared_threshold_lru1;
13070 int shared_threshold_lru2;
13072 float new_lru_ratio;
13073 const INT64 onesec_usec = 1000000LL;
13074 const INT64 tensec_usec = 10 * onesec_usec;
13075 int total_victims = 0;
13076 bool low_overall_activity =
false;
13080 if (thread_p ==
NULL)
13086 quota = &(pgbuf_Pool.
quota);
13087 monitor = &(pgbuf_Pool.
monitor);
13098 if (diff_usec < 1000LL)
13117 low_overall_activity =
true;
13122 (void) ATOMIC_INC_32 ("a->
adjust_age, 1);
13132 lru_hits = ATOMIC_TAS_32 (&monitor->
lru_hits[i], 0);
13134 lru_hits = (int) (onesec_usec * lru_hits / diff_usec);
13141 if (diff_usec >= tensec_usec)
13150 (int) (((tensec_usec - diff_usec) * monitor->
lru_activity[
i] + diff_usec * lru_hits) / tensec_usec);
13153 sum_private_lru_activity_total += monitor->
lru_activity[
i];
13156 lru_private_hits += lru_hits;
13161 lru_shared_hits += lru_hits;
13169 if (low_overall_activity)
13176 lru_shared_hits = MAX (1, lru_shared_hits);
13177 private_ratio = (float) (lru_private_hits) / (float) (lru_private_hits + lru_shared_hits);
13181 if (diff_usec >= tensec_usec)
13188 ((quota->
private_pages_ratio * (float) (tensec_usec - diff_usec) + private_ratio * (float) diff_usec)
13189 / (float) tensec_usec);
13192 if (sum_private_lru_activity_total == 0)
13196 all_private_quota = 0;
13201 lru_list->
quota = 0;
13225 all_private_quota =
13233 new_lru_ratio = (float) monitor->
lru_activity[i] / (
float) sum_private_lru_activity_total;
13237 new_lru_ratio = 0.0f;
13240 new_quota = (int) (new_lru_ratio * all_private_quota);
13242 new_quota = MIN (new_quota, pgbuf_Pool.
num_buffers / 2);
13245 lru_list->
quota = new_quota;
13247 lru_list->
threshold_lru2 = (int) (new_quota * PGBUF_LRU_ZONE_MIN_RATIO);
13272 shared_threshold_lru1 = (int) (avg_shared_lru_size * pgbuf_Pool.
ratio_lru1);
13273 shared_threshold_lru2 = (int) (avg_shared_lru_size * pgbuf_Pool.
ratio_lru2);
13315 int min_activitity;
13317 int lru_cand_idx, lru_cand_zero_sessions;
13329 monitor = &pgbuf_Pool.
monitor;
13330 quota = &pgbuf_Pool.
quota;
13337 lru_cand_zero_sessions = -1;
13346 if (cnt_lru < min_bcbs)
13348 min_bcbs = cnt_lru;
13349 lru_cand_zero_sessions =
i;
13364 if (lru_cand_zero_sessions != -1)
13366 lru_cand_idx = lru_cand_zero_sessions;
13369 assert (lru_cand_idx != -1);
13375 if (lru_cand_zero_sessions != -1)
13380 if (retry_cnt++ < 5)
13395 return private_idx;
13434 memset (seq_flusher, 0,
sizeof (*seq_flusher));
13437 if (f_list !=
NULL)
13470 #if defined (SERVER_MODE) 13497 #if defined (SERVER_MODE) 13504 thread_entry_p = bufptr->next_wait_thrd;
13505 while (thread_entry_p !=
NULL)
13511 thread_entry_p = thread_entry_p->next_wait_thrd;
13529 #if defined (SERVER_MODE) 13542 pgbuf_peek_stats (UINT64 * fixed_cnt, UINT64 * dirty_cnt, UINT64 * lru1_cnt, UINT64 * lru2_cnt, UINT64 * lru3_cnt,
13543 UINT64 * victim_candidates, UINT64 * avoid_dealloc_cnt, UINT64 * avoid_victim_cnt,
13544 UINT64 * private_quota, UINT64 * private_cnt, UINT64 * alloc_bcb_waiter_high,
13545 UINT64 * alloc_bcb_waiter_med, UINT64 * flushed_bcbs_waiting_direct_assign,
13546 UINT64 * lfcq_big_prv_num, UINT64 * lfcq_prv_num, UINT64 * lfcq_shr_num)
13558 *avoid_dealloc_cnt = 0;
13559 *avoid_victim_cnt = 0;
13561 *victim_candidates = 0;
13566 if (bufptr->
fcnt > 0)
13568 *fixed_cnt = *fixed_cnt + 1;
13572 bcb_flags = bufptr->
flags;
13575 *dirty_cnt = *dirty_cnt + 1;
13581 *lru1_cnt = *lru1_cnt + 1;
13585 *lru2_cnt = *lru2_cnt + 1;
13589 *lru3_cnt = *lru3_cnt + 1;
13594 *avoid_dealloc_cnt = *avoid_dealloc_cnt + 1;
13599 *avoid_victim_cnt = *avoid_victim_cnt + 1;
13606 *private_cnt = *private_cnt + 1;
13617 #if defined (SERVER_MODE) 13618 *alloc_bcb_waiter_high = pgbuf_Pool.direct_victims.waiter_threads_high_priority->size ();
13619 *alloc_bcb_waiter_med = pgbuf_Pool.direct_victims.waiter_threads_low_priority->size ();
13620 *flushed_bcbs_waiting_direct_assign = pgbuf_Pool.flushed_bcbs->size ();
13622 *alloc_bcb_waiter_high = 0;
13623 *alloc_bcb_waiter_med = 0;
13624 *flushed_bcbs_waiting_direct_assign = 0;
13649 static int prev_dirties_cnt = 0;
13651 int desired_dirty_cnt = pgbuf_Pool.
num_buffers / 2;
13652 int adapt_flush_rate = 0;
13655 if (crt_dirties_cnt > desired_dirty_cnt)
13659 int dirties_above_desired_cnt = crt_dirties_cnt - desired_dirty_cnt;
13660 int total_above_desired_cnt = pgbuf_Pool.
num_buffers - desired_dirty_cnt;
13662 adapt_flush_rate = dirties_above_desired_cnt * dirties_above_desired_cnt / total_above_desired_cnt;
13668 if (crt_dirties_cnt > prev_dirties_cnt)
13670 int diff = crt_dirties_cnt - prev_dirties_cnt;
13673 adapt_flush_rate += diff * crt_dirties_cnt / pgbuf_Pool.
num_buffers;
13675 prev_dirties_cnt = crt_dirties_cnt;
13678 return adapt_flush_rate;
13702 if (page_to_flush ==
NULL)
13734 fprintf (fp,
"Page to flush: %d|%d. \n", vpid_to_flush.
volid, vpid_to_flush.
pageid);
13743 static const char *
13746 const char *latch_mode_str;
13748 switch (latch_mode)
13751 latch_mode_str =
"No Latch";
13754 latch_mode_str =
"Read";
13757 latch_mode_str =
"Write";
13760 latch_mode_str =
"Flush";
13763 latch_mode_str =
"Fault";
13767 return latch_mode_str;
13776 static const char *
13779 const char *zone_str;
13784 zone_str =
"LRU_1_Zone";
13787 zone_str =
"LRU_2_Zone";
13790 zone_str =
"LRU_3_Zone";
13793 zone_str =
"INVALID_Zone";
13796 zone_str =
"VOID_Zone";
13809 static const char *
13812 const char *consistent_str;
13814 switch (consistent)
13817 consistent_str =
"GOOD";
13820 consistent_str =
"BAD";
13823 consistent_str =
"LIKELY BAD";
13827 return consistent_str;
13845 return bufptr->
fcnt;
13884 return perf_page_type;
14006 #if !defined(NDEBUG) 14010 "TDE: pgbuf_dealloc_page(): clear tde bit in pflag, VPID = %d|%d, tde_algorithm = %s\n",
14025 #if !defined (NDEBUG) 14026 thread_p->get_pgbuf_tracker ().decrement (page_dealloc);
14074 if (page_deallocated ==
NULL)
14085 #if !defined(NDEBUG) 14089 "TDE: pgbuf_rv_dealloc_page(): reset tde bit in pflag, VPID = %d|%d, tde_algorithm = %s\n",
14125 #if !defined(NDEBUG) 14129 "TDE: pgbuf_rv_dealloc_page(): reset tde bit in pflag, VPID = %d|%d, tde_algorithm = %s\n",
14154 const char *caller_file,
int caller_line)
14181 #if defined (NDEBUG) 14200 #if defined (SERVER_MODE) 14207 pgbuf_keep_victim_flush_thread_running (
void)
14224 #if defined (SERVER_MODE) 14227 PERF_UTIME_TRACKER timetr;
14229 PERF_UTIME_TRACKER_START (thread_p, &timetr);
14245 while (pgbuf_get_thread_waiting_for_direct_victim (waiter_thread))
14264 pgbuf_Pool.direct_victims.bcb_victims[waiter_thread->index] = bcb;
14280 #if defined (SERVER_MODE) 14293 bool not_empty =
false;
14298 while (pgbuf_Pool.flushed_bcbs->consume (bcb_flushed))
14305 if ((bcb_flushed->
flags & invalidate_flag) != 0)
14341 if (bcb_flushed->next_wait_thrd !=
NULL)
14359 pgbuf_get_thread_waiting_for_direct_victim (
REFPTR (
THREAD_ENTRY, waiting_thread_out))
14361 static INT64
count = 0;
14362 INT64 my_count = ATOMIC_INC_64 (&count, 1);
14365 if (my_count % 4 == 0)
14367 if (pgbuf_Pool.direct_victims.waiter_threads_low_priority->consume (waiting_thread_out))
14373 if (pgbuf_Pool.direct_victims.waiter_threads_high_priority->consume (waiting_thread_out))
14377 if (pgbuf_Pool.direct_victims.waiter_threads_low_priority->consume (waiting_thread_out))
14394 (
PGBUF_BCB *) ATOMIC_TAS_ADDR (&pgbuf_Pool.direct_victims.bcb_victims[thread_p->index], (
PGBUF_BCB *)
NULL);
14453 pgbuf_is_any_thread_waiting_for_direct_victim (
void)
14455 return (!pgbuf_Pool.direct_victims.waiter_threads_high_priority->is_empty ()
14456 || !pgbuf_Pool.direct_victims.waiter_threads_low_priority->is_empty ());
14499 while (!ATOMIC_CAS_ADDR (&lru_list->
victim_hint, old_victim_hint, bcb));
14545 PGBUF_BCB * bcb_new_hint,
bool was_vict_count_updated)
14556 new_victim_hint = ((new_victim_hint ==
NULL && lru_list->
count_vict_cand > (was_vict_count_updated ? 0 : 1))
14557 ? lru_list->
bottom : new_victim_hint);
14560 ? new_victim_hint :
NULL);
14564 if (ATOMIC_CAS_ADDR (&lru_list->
victim_hint, bcb_prev_hint, new_victim_hint))
14588 bool old_dirty, new_dirty;
14598 old_flags = bcb->
flags;
14599 new_flags = old_flags | set_flags;
14600 new_flags = new_flags & (~clear_flags);
14602 if (old_flags == new_flags)
14608 while (!ATOMIC_CAS_32 (&bcb->
flags, old_flags, new_flags));
14620 if (is_old_invalid_victim_candidate && !is_new_invalid_victim_candidate)
14625 else if (!is_old_invalid_victim_candidate && is_new_invalid_victim_candidate)
14639 if (old_dirty && !new_dirty)
14644 else if (!old_dirty && new_dirty)
14687 bool is_valid_victim_candidate;
14701 old_flags = bcb->
flags;
14708 while (!ATOMIC_CAS_32 (&bcb->
flags, old_flags, new_flags));
14739 if (is_valid_victim_candidate)
14750 if (new_zone & PGBUF_LRU_ZONE_MASK)
14769 if (is_valid_victim_candidate)
14834 old_flags = bcb->
flags;
15030 return (
int) (bcb - pgbuf_Pool.
BCB_table);
15060 assert ((count_crt & 0x00008000) == 0);
15082 "pgbuf_bcb_unregister_avoid_deallocation: bcb %p, vpid = %d|%d was probably victimized.\n",
15120 er_log_debug (file, line,
"warning: bcb %p, vpid = %d|%d, should not have avoid deallocation marker.\n",
15138 #if !defined (NDEBUG) 15171 int old_flags = lru_list->
flags;
15180 if (ATOMIC_CAS_32 (&lru_list->
flags, old_flags, old_flags | PGBUF_LRU_VICTIM_LFCQ_FLAG))
15200 lru_list->
flags &= ~PGBUF_LRU_VICTIM_LFCQ_FLAG;
15217 #define PERF(id) if (detailed_perf) perfmon_inc_stat (thread_p, id) 15223 bool added_back =
false;
15309 #define PERF(id) if (detailed_perf) perfmon_inc_stat (thread_p, id) 15411 #if defined (SERVER_MODE) 15413 return !pgbuf_Pool.direct_victims.waiter_threads_low_priority->is_empty ();
15427 #define PGBUF_MIN_VICTIM_REQ 10 15428 #define PGBUF_DESIRED_HIT_VS_MISS_RATE 1000 15433 #undef PGBUF_DESIRED_HIT_VS_MISS_RATE 15434 #undef PGBUF_MIN_VICTIM_REQ 15437 #if defined (SERVER_MODE) 15446 pgbuf_bcbmon_lock (
PGBUF_BCB * bcb,
int caller_line)
15453 if (monitor_bcb_mutex->
bcb !=
NULL)
15463 if (bcb->owner_mutex == index)
15470 if (bcb->owner_mutex >= 0)
15475 monitor_bcb_mutex->
bcb = bcb;
15476 monitor_bcb_mutex->
line = caller_line;
15477 bcb->owner_mutex =
index;
15488 pgbuf_bcbmon_trylock (
PGBUF_BCB * bcb,
int caller_line)
15496 if (bcb->owner_mutex == index)
15506 if (monitor_bcb_mutex->
bcb !=
NULL && monitor_bcb_mutex->
bcb == bcb)
15516 if (monitor_bcb_mutex->
bcb ==
NULL)
15518 monitor_bcb_mutex->
bcb = bcb;
15519 monitor_bcb_mutex->
line = caller_line;
15526 bcb->owner_mutex =
index;
15550 if (bcb->owner_mutex != index)
15555 bcb->owner_mutex = -1;
15557 if (monitor_bcb_mutex->
bcb == bcb)
15560 monitor_bcb_mutex->
bcb =
NULL;
15562 else if (monitor_bcb_mutex->
bcb_second == bcb)
15585 pgbuf_bcbmon_check_own (
PGBUF_BCB * bcb)
15592 if (bcb->owner_mutex != index)
15597 if (monitor_bcb_mutex->
bcb != bcb && monitor_bcb_mutex->
bcb_second != bcb)
15611 pgbuf_bcbmon_check_mutex_leaks (
void)
15618 if (monitor_bcb_mutex->
bcb !=
NULL)
15646 if (PGBUF_ZONE_MASK & PGBUF_LRU_INDEX_MASK)
15665 #if !defined (NDEBUG) 15769 assert (page_flush_interval_msecs >= 0);
15771 if (page_flush_interval_msecs > 0)
15774 is_timed_wait =
true;
15775 period = std::chrono::milliseconds (page_flush_interval_msecs);
15780 is_timed_wait =
false;
15785 #if defined (SERVER_MODE) 15799 pgbuf_direct_victims_maintenance (&thread_ref);
15803 #if defined (SERVER_MODE) 15812 PERF_UTIME_TRACKER m_perf_track;
15815 pgbuf_page_flush_daemon_task ()
15817 PERF_UTIME_TRACKER_START (
NULL, &m_perf_track);
15829 bool force_one_run = pgbuf_Page_flush_daemon->
was_woken_up ();
15830 bool stop_iteration =
false;
15833 while (force_one_run || pgbuf_keep_victim_flush_thread_running ())
15837 force_one_run =
false;
15838 if (stop_iteration)
15845 if (m_perf_track.is_perf_tracking)
15856 PERF_UTIME_TRACKER_START (&thread_ref, &m_perf_track);
15862 #if defined (SERVER_MODE) 15873 if (pgbuf_assign_flushed_pages (&thread_ref))
15881 #if defined (SERVER_MODE) 15890 struct timeval m_end;
15894 pgbuf_flush_control_daemon_task ()
15896 , m_first_run (
true)
15915 gettimeofday (&m_end,
NULL);
15916 m_first_run =
false;
15920 struct timeval begin, diff;
15921 int token_gen, token_consumed;
15923 gettimeofday (&begin,
NULL);
15926 int64_t diff_usec = diff.tv_sec * 1000000LL + diff.tv_usec;
15929 gettimeofday (&m_end,
NULL);
15932 void retire (
void)
override 15940 #if defined (SERVER_MODE) 15945 pgbuf_page_maintenance_daemon_init ()
15947 assert (pgbuf_Page_maintenance_daemon ==
NULL);
15953 "pgbuf_page_maintenance");
15957 #if defined (SERVER_MODE) 15962 pgbuf_page_flush_daemon_init ()
15967 pgbuf_page_flush_daemon_task *daemon_task =
new pgbuf_page_flush_daemon_task ();
15973 #if defined (SERVER_MODE) 15978 pgbuf_page_post_flush_daemon_init ()
15980 assert (pgbuf_Page_post_flush_daemon ==
NULL);
15982 std::array<cubthread::delta_time, 3> looper_interval {{
15983 std::chrono::milliseconds (1),
15984 std::chrono::milliseconds (10),
15985 std::chrono::milliseconds (100)
15992 "pgbuf_page_post_flush");
15996 #if defined (SERVER_MODE) 16001 pgbuf_flush_control_daemon_init ()
16003 assert (pgbuf_Flush_control_daemon ==
NULL);
16005 pgbuf_flush_control_daemon_task *daemon_task =
new pgbuf_flush_control_daemon_task ();
16007 if (daemon_task->initialize () !=
NO_ERROR)
16009 delete daemon_task;
16015 "pgbuf_flush_control");
16019 #if defined (SERVER_MODE) 16024 pgbuf_daemons_init ()
16026 pgbuf_page_maintenance_daemon_init ();
16027 pgbuf_page_flush_daemon_init ();
16028 pgbuf_page_post_flush_daemon_init ();
16029 pgbuf_flush_control_daemon_init ();
16033 #if defined (SERVER_MODE) 16038 pgbuf_daemons_destroy ()
16050 #if defined (SERVER_MODE) 16051 UINT64 *statsp = stats_out;
16053 if (pgbuf_Page_flush_daemon !=
NULL)
16055 pgbuf_Page_flush_daemon->
get_stats (statsp);
16059 if (pgbuf_Page_post_flush_daemon !=
NULL)
16061 pgbuf_Page_post_flush_daemon->
get_stats (statsp);
16065 if (pgbuf_Flush_control_daemon !=
NULL)
16067 pgbuf_Flush_control_daemon->
get_stats (statsp);
16071 if (pgbuf_Page_maintenance_daemon !=
NULL)
16073 pgbuf_Page_maintenance_daemon->
get_stats (statsp);
16086 #if defined (SERVER_MODE) 16087 return pgbuf_Page_flush_daemon !=
NULL;
16123 for (bufid = 0; bufid < pgbuf_Pool.
num_buffers; bufid++)
16127 vpid = bufptr->
vpid;
16128 flags = bufptr->
flags;
16203 const int num_cols = 19;
16208 unsigned long long delta, hit_delta, request_delta;
16218 #if defined(SERVER_MODE) 16245 goto exit_on_error;
16248 cur_time = time (
NULL);
16250 time_delta = difftime (cur_time, status_old->
print_out_time) + 0.0001;
16256 hit_rate = hit_rate * 100;
16264 goto exit_on_error;
16319 goto exit_on_error;
16332 goto exit_on_error;
16338 assert (idx == num_cols);
16350 #if defined(SERVER_MODE) 16363 #if defined(SERVER_MODE) #define MAX_PRIVATE_RATIO
static std::size_t get_stats_value_count(void)
static int pgbuf_unlock_page(THREAD_ENTRY *thread_p, PGBUF_BUFFER_HASH *hash_anchor, const VPID *vpid, int need_hash_mutex)
#define PGBUF_NEIGHBOR_POS(idx)
static PGBUF_BCB * pgbuf_get_victim_from_lru_list(THREAD_ENTRY *thread_p, const int lru_idx)
STATIC_INLINE FILEIO_PAGE_WATERMARK * fileio_get_page_watermark_pos(FILEIO_PAGE *io_page, PGLENGTH page_size)
unsigned int add_shared_lru_idx
#define PGBUF_IS_SHARED_LRU_INDEX(lru_idx)
unsigned int num_flusher_waiting_threads
PAGE_PTR pgbuf_fix_debug(THREAD_ENTRY *thread_p, const VPID *vpid, PAGE_FETCH_MODE fetch_mode, PGBUF_LATCH_MODE request_mode, PGBUF_LATCH_CONDITION condition, const char *caller_file, int caller_line)
#define ER_LK_UNILATERALLY_ABORTED
PGBUF_STATUS * show_status
PGBUF_HOLDER * thrd_reserved_holder
PGBUF_BUFFER_LOCK * buf_lock_table
STATIC_INLINE void pgbuf_lru_advance_victim_hint(THREAD_ENTRY *thread_p, PGBUF_LRU_LIST *lru_list, PGBUF_BCB *bcb_prev_hint, PGBUF_BCB *bcb_new_hint, bool was_vict_count_updated)
#define PGBUF_TRAN_THRESHOLD_ACTIVITY
void disk_volheader_check_magic(THREAD_ENTRY *thread_p, const PAGE_PTR page_volheader)
#define ER_PAGE_LATCH_ABORTED
DISK_ISVALID pgbuf_is_valid_page(THREAD_ENTRY *thread_p, const VPID *vpid, bool no_error, DISK_ISVALID(*fun)(const VPID *vpid, void *args), void *args)
bool logpb_need_wal(const LOG_LSA *lsa)
bool pgbuf_has_perm_pages_fixed(THREAD_ENTRY *thread_p)
#define ER_FAILED_ASSERTION
float * lru_victim_flush_priority_per_lru
#define pgbuf_attach_watcher(...)
cubthread::entry * thread_get_thread_entry_info(void)
STATIC_INLINE void pgbuf_remove_from_lru_list(THREAD_ENTRY *thread_p, PGBUF_BCB *bufptr, PGBUF_LRU_LIST *lru_list)
#define VACUUM_MAX_WORKER_COUNT
#define PGBUF_CHKPT_MAX_FLUSH_RATE
PGBUF_HOLDER_SET * next_set
static void pgbuf_lru_boost_bcb(THREAD_ENTRY *thread_p, PGBUF_BCB *bcb)
bool check_for_interrupts
static PGBUF_BCB * pgbuf_get_victim(THREAD_ENTRY *thread_p)
#define AOUT_HASH_IDX(vpid, list)
int heap_get_class_oid_from_page(THREAD_ENTRY *thread_p, PAGE_PTR page_p, OID *class_oid)
#define PGBUF_BCB_COUNT_FIX_SHIFT_BITS
#define PGBUF_LRU_LIST_IS_ONE_TWO_OVER_QUOTA(list)
int pgbuf_rv_new_page_undo(THREAD_ENTRY *thread_p, LOG_RCV *rcv)
#define PGBUF_AOUT_NOT_FOUND
static int pgbuf_put_bcb_into_invalid_list(THREAD_ENTRY *thread_p, PGBUF_BCB *bufptr)
void log_append_undoredo_data2(THREAD_ENTRY *thread_p, LOG_RCVINDEX rcvindex, const VFID *vfid, PAGE_PTR pgptr, PGLENGTH offset, int undo_length, int redo_length, const void *undo_data, const void *redo_data)
STATIC_INLINE bool pgbuf_bcb_avoid_victim(const PGBUF_BCB *bcb)
static int pgbuf_flush_seq_list(THREAD_ENTRY *thread_p, PGBUF_SEQ_FLUSHER *seq_flusher, struct timeval *limit_time, const LOG_LSA *prev_chkpt_redo_lsa, LOG_LSA *chkpt_smallest_lsa, int *time_rem)
bool pgbuf_is_lsa_temporary(PAGE_PTR pgptr)
#define BO_IS_SERVER_RESTARTED()
static int pgbuf_initialize_bcb_table(void)
#define PGBUF_PRIVATE_LRU_FROM_THREAD(thread_p)
STATIC_INLINE void pgbuf_lru_add_new_bcb_to_top(THREAD_ENTRY *thread_p, PGBUF_BCB *bcb, int lru_idx)
PGBUF_IOPAGE_BUFFER * iopage_table
unsigned long long num_page_request
#define PGBUF_TOTAL_LRU_COUNT
int pgbuf_flush_all_unfixed_and_set_lsa_as_null(THREAD_ENTRY *thread_p, VOLID volid)
void pgbuf_log_new_page(THREAD_ENTRY *thread_p, PAGE_PTR page_new, int data_size, PAGE_TYPE ptype_new)
STATIC_INLINE PGBUF_HOLDER * pgbuf_find_thrd_holder(THREAD_ENTRY *thread_p, PGBUF_BCB *bufptr) __attribute__((ALWAYS_INLINE))
void pgbuf_replace_watcher_debug(THREAD_ENTRY *thread_p, PGBUF_WATCHER *old_watcher, PGBUF_WATCHER *new_watcher, const char *caller_file, const int caller_line)
static int pgbuf_remove_vpid_from_aout_list(THREAD_ENTRY *thread_p, const VPID *vpid)
bool pgbuf_has_any_non_vacuum_waiters(PAGE_PTR pgptr)
static PGBUF_BCB * pgbuf_lfcq_get_victim_from_private_lru(THREAD_ENTRY *thread_p, bool restricted)
void pgbuf_unfix_debug(THREAD_ENTRY *thread_p, PAGE_PTR pgptr, const char *caller_file, int caller_line)
#define ER_CSS_PTHREAD_COND_TIMEDOUT
bool LSA_EQ(const log_lsa *plsa1, const log_lsa *plsa2)
#define ER_PB_ORDERED_NO_HEAP
void showstmt_free_array_context(THREAD_ENTRY *thread_p, SHOWSTMT_ARRAY_CONTEXT *ctx)
STATIC_INLINE int pgbuf_bcb_get_pool_index(const PGBUF_BCB *bcb)
#define PGBUF_LRU_LIST_IS_OVER_QUOTA(list)
static const char * pgbuf_consistent_str(int consistent)
void pgbuf_dealloc_page(THREAD_ENTRY *thread_p, PAGE_PTR page_dealloc)
int pgbuf_rv_dealloc_redo(THREAD_ENTRY *thread_p, LOG_RCV *rcv)
#define PGBUF_MIN_PAGES_IN_SHARED_LIST
static PGBUF_BUFFER_POOL pgbuf_Pool
#define LOG_DATA_ADDR_INITIALIZER
PERF_CONDITIONAL_FIX_TYPE perf_cond_type
#define PGBUF_FLUSH_VICTIM_BOOST_MULT
void LSA_COPY(log_lsa *plsa1, const log_lsa *plsa2)
STATIC_INLINE void pgbuf_bcb_update_flags(THREAD_ENTRY *thread_p, PGBUF_BCB *bcb, int set_flags, int clear_flags)
void pgbuf_attach_watcher_debug(THREAD_ENTRY *thread_p, PAGE_PTR pgptr, PGBUF_LATCH_MODE latch_mode, HFID *hfid, PGBUF_WATCHER *watcher, const char *caller_file, const int caller_line)
void pgbuf_ordered_unfix_debug(THREAD_ENTRY *thread_p, PGBUF_WATCHER *watcher_object, const char *caller_file, int caller_line)
#define PGBUF_NUM_ALLOC_HOLDER
unsigned long long num_pages_created
#define PGBUF_LRU_LIST_COUNT(list)
static int pgbuf_remove_private_from_aout_list(const int lru_idx)
#define VPID_COPY(dest_ptr, src_ptr)
PAGEID pgbuf_get_page_id(PAGE_PTR pgptr)
void * fileio_read(THREAD_ENTRY *thread_p, int vol_fd, void *io_page_p, PAGEID page_id, size_t page_size)
int db_make_bigint(DB_VALUE *value, const DB_BIGINT num)
static int pgbuf_latch_idle_page(THREAD_ENTRY *thread_p, PGBUF_BCB *bufptr, PGBUF_LATCH_MODE request_mode)
static int pgbuf_lock_page(THREAD_ENTRY *thread_p, PGBUF_BUFFER_HASH *hash_anchor, const VPID *vpid)
static int pgbuf_get_groupid_and_unfix(THREAD_ENTRY *thread_p, const VPID *req_vpid, PAGE_PTR *pgptr, VPID *groupid, bool do_unfix)
STATIC_INLINE void pgbuf_bcb_unregister_avoid_deallocation(PGBUF_BCB *bcb)
int pgbuf_compare_vpid(const void *key_vpid1, const void *key_vpid2)
#define PGBUF_NEIGHBOR_PAGES
int pgbuf_start_scan(THREAD_ENTRY *thread_p, int type, DB_VALUE **arg_values, int arg_cnt, void **ptr)
static PGBUF_HOLDER * pgbuf_get_holder(THREAD_ENTRY *thread_p, PAGE_PTR pgptr)
unsigned hold_has_write_latch
STATIC_INLINE int pgbuf_flush_neighbor_safe(THREAD_ENTRY *thread_p, PGBUF_BCB *bufptr, VPID *expected_vpid, bool *flushed)
PGBUF_AOUT_BUF * Aout_top
STATIC_INLINE bool pgbuf_assign_direct_victim(THREAD_ENTRY *thread_p, PGBUF_BCB *bcb)
int pgbuf_promote_read_latch_debug(THREAD_ENTRY *thread_p, PAGE_PTR *pgptr_p, PGBUF_PROMOTE_CONDITION condition, const char *caller_file, int caller_line)
int mht_rem(MHT_TABLE *ht, const void *key, int(*rem_func)(const void *key, void *data, void *args), void *func_args)
bool dwb_is_created(void)
STATIC_INLINE bool pgbuf_is_exist_blocked_reader_writer(PGBUF_BCB *bufptr)
#define PAGE_ADD_REFRESH_STAT
#define PGBUF_PRIVATE_LRU_COUNT
#define PGBUF_IS_BCB_IN_LRU(bcb)
#define pgbuf_unfix(thread_p, pgptr)
STATIC_INLINE void pgbuf_lru_add_bcb_to_top(THREAD_ENTRY *thread_p, PGBUF_BCB *bcb, PGBUF_LRU_LIST *lru_list)
#define PGBUF_BUFFER_HASH_SIZEOF
#define PGBUF_THREAD_SHOULD_IGNORE_UNFIX(th)
#define PGBUF_LRU_ZONE_ONE_TWO_COUNT(list)
UINT64 tsc_elapsed_utime(TSC_TICKS end_tick, TSC_TICKS start_tick)
#define pgbuf_invalidate(thread_p, pgptr)
void pgbuf_unfix_all(THREAD_ENTRY *thread_p)
STATIC_INLINE bool pgbuf_get_check_page_validation_level(int page_validation_level)
void logpb_force_flush_pages(THREAD_ENTRY *thread_p)
const void * mht_put(MHT_TABLE *ht, const void *key, void *data)
STATIC_INLINE void fileio_init_lsa_of_page(FILEIO_PAGE *io_page, PGLENGTH page_size)
unsigned int victim_candidate_pages
#define ASSERT_ERROR_AND_SET(error_code)
void thread_sleep(double millisec)
#define PGBUF_HOLDER_SET_SIZEOF
#define ER_PB_UNKNOWN_PAGEPTR
void get_stats(cubperf::stat_value *stats_out)
unsigned long long num_pages_created
#define assert_release(e)
static int pgbuf_block_bcb(THREAD_ENTRY *thread_p, PGBUF_BCB *bufptr, PGBUF_LATCH_MODE request_mode, int request_fcnt, bool as_promote)
#define PGBUF_AGE_DIFF(bcb_age, list_age)
void thread_wakeup_already_had_mutex(cubthread::entry *thread_p, thread_resume_suspend_status resume_reason)
void pgbuf_set_dirty(THREAD_ENTRY *thread_p, PAGE_PTR pgptr, bool free_page)
#define pthread_mutex_destroy(a)
unsigned int num_system_pages
LOG_LSA * log_get_restart_lsa(void)
static bool pgbuf_is_temp_lsa(const log_lsa &lsa)
static void pgbuf_wake_flush_waiters(THREAD_ENTRY *thread_p, PGBUF_BCB *bcb)
#define PGBUF_MAX_PAGE_FIXED_BY_TRAN
#define VACUUM_IS_THREAD_VACUUM
void pgbuf_notify_vacuum_follows(THREAD_ENTRY *thread_p, PAGE_PTR page)
#define ER_LOG_FLUSH_VICTIM_FINISHED
int thread_get_current_entry_index(void)
#define PGBUF_HOLDER_SIZEOF
static int pgbuf_invalidate_bcb(THREAD_ENTRY *thread_p, PGBUF_BCB *bufptr)
void fileio_flush_control_finalize(void)
STATIC_INLINE void pgbuf_lru_add_bcb_to_middle(THREAD_ENTRY *thread_p, PGBUF_BCB *bcb, PGBUF_LRU_LIST *lru_list)
unsigned int num_temp_pages
bool pgbuf_check_page_type_no_error(THREAD_ENTRY *thread_p, PAGE_PTR pgptr, PAGE_TYPE ptype)
STATIC_INLINE PGBUF_BCB * pgbuf_search_hash_chain(THREAD_ENTRY *thread_p, PGBUF_BUFFER_HASH *hash_anchor, const VPID *vpid) __attribute__((ALWAYS_INLINE))
PGBUF_VICTIM_CANDIDATE_LIST * victim_cand_list
PGBUF_ORDERED_GROUP group_id
#define MEM_SIZE_IS_VALID(size)
#define MEM_REGION_GUARD_MARK
struct timeval TSCTIMEVAL
static INLINE unsigned int pgbuf_hash_func_mirror(const VPID *vpid) __attribute__((ALWAYS_INLINE))
STATIC_INLINE void pgbuf_bcb_change_zone(THREAD_ENTRY *thread_p, PGBUF_BCB *bcb, int new_lru_idx, PGBUF_ZONE new_zone)
#define CAST_PGPTR_TO_IOPGPTR(io_pgptr, pgptr)
void thread_suspend_wakeup_and_unlock_entry(cubthread::entry *thread_p, thread_resume_suspend_status suspended_reason)
LOG_TDES * LOG_FIND_TDES(int tran_index)
int pgbuf_flush_all_unfixed(THREAD_ENTRY *thread_p, VOLID volid)
void tsc_elapsed_time_usec(TSCTIMEVAL *tv, TSC_TICKS end_tick, TSC_TICKS start_tick)
#define PGBUF_MAX_PAGE_WATCHERS
STATIC_INLINE void pgbuf_bcb_check_and_reset_fix_and_avoid_dealloc(PGBUF_BCB *bcb, const char *file, int line)
STATIC_INLINE bool pgbuf_should_move_private_to_shared(THREAD_ENTRY *thread_p, PGBUF_BCB *bcb, int thread_private_lru_index) __attribute__((ALWAYS_INLINE))
#define LSA_AS_ARGS(lsa_ptr)
static int pgbuf_flush_page_and_neighbors_fb(THREAD_ENTRY *thread_p, PGBUF_BCB *bufptr, int *flushed_pages)
PGBUF_STATUS_OLD show_status_old
#define PGBUF_IS_ORDERED_PAGETYPE(ptype)
void pgbuf_ordered_set_dirty_and_free(THREAD_ENTRY *thread_p, PGBUF_WATCHER *pg_watcher)
int numeric_db_value_coerce_to_num(DB_VALUE *src, DB_VALUE *dest, DB_DATA_STATUS *data_status)
static int pgbuf_initialize_page_monitor(void)
int pgbuf_flush_victim_candidates(THREAD_ENTRY *thread_p, float flush_ratio, PERF_UTIME_TRACKER *perf_tracker, bool *stop)
PAGE_PTR pgbuf_flush_with_wal(THREAD_ENTRY *thread_p, PAGE_PTR pgptr)
STATIC_INLINE int perfmon_get_activation_flag(void) __attribute__((ALWAYS_INLINE))
PGBUF_HOLDER_ANCHOR * thrd_holder_info
int pgbuf_get_fix_count(PAGE_PTR pgptr)
int pgbuf_flush_control_from_dirty_ratio(void)
#define PGBUF_IS_CLEAN_WATCHER(w)
int * private_lru_session_cnt
STATIC_INLINE void pgbuf_bcb_clear_dirty(THREAD_ENTRY *thread_p, PGBUF_BCB *bcb)
int dwb_read_page(THREAD_ENTRY *thread_p, const VPID *vpid, void *io_page, bool *success)
#define PGBUF_BCB_DIRTY_FLAG
#define PTR_ALIGN(addr, boundary)
bool logtb_get_check_interrupt(THREAD_ENTRY *thread_p)
STATIC_INLINE int pgbuf_find_current_wait_msecs(THREAD_ENTRY *thread_p)
PERF_PAGE_MODE perf_page_found
SHOWSTMT_ARRAY_CONTEXT * showstmt_alloc_array_context(THREAD_ENTRY *thread_p, int num_total, int num_cols)
#define PGBUF_MIN_VICTIM_REQ
#define ER_CSS_PTHREAD_COND_SIGNAL
#define PGBUF_MAKE_ZONE(list_id, zone)
bool LSA_LT(const log_lsa *plsa1, const log_lsa *plsa2)
#define PGBUF_BCB_FLAGS_MASK
#define er_log_debug(...)
PGBUF_BCB * pages_bufptr[2 *PGBUF_MAX_NEIGHBOR_PAGES-1]
int pgbuf_ordered_fix_debug(THREAD_ENTRY *thread_p, const VPID *req_vpid, PAGE_FETCH_MODE fetch_mode, const PGBUF_LATCH_MODE request_mode, PGBUF_WATCHER *req_watcher, const char *caller_file, int caller_line)
#define VPID_AS_ARGS(vpidp)
static int pgbuf_initialize_lock_table(void)
PGBUF_LATCH_MODE latch_mode
PGBUF_SEQ_FLUSHER seq_chkpt_flusher
unsigned int num_index_pages
STATIC_INLINE PGBUF_HOLDER * pgbuf_allocate_thrd_holder_entry(THREAD_ENTRY *thread_p) __attribute__((ALWAYS_INLINE))
STATIC_INLINE int pgbuf_bcb_flush_with_wal(THREAD_ENTRY *thread_p, PGBUF_BCB *bufptr, bool is_page_flush_thread, bool *is_bcb_locked)
INT64 timeval_diff_in_msec(const struct timeval *end_time, const struct timeval *start_time)
#define pgbuf_invalidate_all(thread_p, volid)
void _er_log_debug(const char *file_name, const int line_no, const char *fmt,...)
void * pgbuf_copy_to_area(THREAD_ENTRY *thread_p, const VPID *vpid, int start_offset, int length, void *area, bool do_fetch)
#define FILEIO_PAGE_FLAG_ENCRYPTED_MASK
void log_wakeup_log_flush_daemon()
void pgbuf_log_redo_new_page(THREAD_ENTRY *thread_p, PAGE_PTR page_new, int data_size, PAGE_TYPE ptype_new)
STATIC_INLINE void pgbuf_bcb_set_dirty(THREAD_ENTRY *thread_p, PGBUF_BCB *bcb)
#define PGBUF_IS_PRIVATE_LRU_ONE_TWO_OVER_QUOTA(lru_idx)
#define PGBUF_CLEAR_WATCHER(w)
static int pgbuf_initialize_lru_list(void)
#define pthread_mutex_init(a, b)
#define PGBUF_SHARED_LRU_COUNT
volatile int count_fix_and_avoid_dealloc
void pgbuf_finalize(void)
#define PGBUF_PRIVATE_LRU_MIN_COUNT
#define PGBUF_LRU_INDEX_FROM_PRIVATE(private_id)
#define PGBUF_ABORT_RELEASE()
#define pgbuf_unfix_and_init(thread_p, pgptr)
#define PGBUF_IS_AUXILIARY_VOLUME(volid)
PGBUF_BUFFER_HASH * buf_hash_table
#define PGBUF_BCB_TRYLOCK(bcb)
#define ER_PB_UNFIXED_PAGEPTR
int thread_get_entry_index(cubthread::entry *thread_p)
volatile int lru_shared_pgs_cnt
void log_append_redo_data2(THREAD_ENTRY *thread_p, LOG_RCVINDEX rcvindex, const VFID *vfid, PAGE_PTR pgptr, PGLENGTH offset, int length, const void *data)
static int pgbuf_flush_all_helper(THREAD_ENTRY *thread_p, VOLID volid, bool is_unfixed_only, bool is_set_lsa_as_null)
STATIC_INLINE void pgbuf_lru_adjust_zone2(THREAD_ENTRY *thread_p, PGBUF_LRU_LIST *lru_list, bool min_one)
#define PGBUF_MIN_SHARED_LIST_ADJUST_SIZE
#define PGBUF_CHKPT_BURST_PAGES
void mht_destroy(MHT_TABLE *ht)
int boot_find_root_heap(HFID *root_hfid_p)
int pgbuf_rv_dealloc_undo(THREAD_ENTRY *thread_p, LOG_RCV *rcv)
manager * get_manager(void)
PAGE_TYPE pgbuf_get_page_ptype(THREAD_ENTRY *thread_p, PAGE_PTR pgptr)
const char * tde_get_algorithm_name(TDE_ALGORITHM tde_algo)
static bool pgbuf_is_valid_page_ptr(const PAGE_PTR pgptr)
#define PGBUF_BCB_INVALID_VICTIM_CANDIDATE_MASK
#define PGBUF_IOPAGE_BUFFER_SIZE
void er_set(int severity, const char *file_name, const int line_no, int err_id, int num_args,...)
STATIC_INLINE PGBUF_ZONE pgbuf_bcb_get_zone(const PGBUF_BCB *bcb)
#define PGBUF_PRIVATE_LRU_MAX_HARD_QUOTA
#define PGBUF_BCB_CHECK_MUTEX_LEAKS()
int pgbuf_initialize(void)
#define ER_PB_ALL_BUFFERS_DIRTY
char * fileio_get_volume_label(VOLID vol_id, bool is_peek)
static int pgbuf_initialize_aout_list(void)
PGBUF_AOUT_BUF * bufarray
static int pgbuf_initialize_seq_flusher(PGBUF_SEQ_FLUSHER *seq_flusher, PGBUF_VICTIM_CANDIDATE_LIST *f_list, const int cnt)
PGBUF_INVALID_LIST buf_invalid_list
#define PGBUF_DEFAULT_FIX_COUNT
static int pgbuf_flush_chkpt_seq_list(THREAD_ENTRY *thread_p, PGBUF_SEQ_FLUSHER *seq_flusher, const LOG_LSA *prev_chkpt_redo_lsa, LOG_LSA *chkpt_smallest_lsa)
static PGBUF_BATCH_FLUSH_HELPER pgbuf_Flush_helper
bool pgbuf_has_prevent_dealloc(PAGE_PTR pgptr)
void log_skip_logging(THREAD_ENTRY *thread_p, LOG_DATA_ADDR *addr)
STATIC_INLINE void pgbuf_set_dirty_buffer_ptr(THREAD_ENTRY *thread_p, PGBUF_BCB *bufptr)
PGBUF_WATCHER * first_watcher
STATIC_INLINE bool pgbuf_bcb_is_invalid_direct_victim(const PGBUF_BCB *bcb)
bool log_is_logged_since_restart(const LOG_LSA *lsa_ptr)
const VOLID LOG_DBFIRST_VOLID
#define ER_LK_PAGE_TIMEOUT
bool pgbuf_check_page_ptype(THREAD_ENTRY *thread_p, PAGE_PTR pgptr, PAGE_TYPE ptype)
static const char * pgbuf_latch_mode_str(PGBUF_LATCH_MODE latch_mode)
DISK_ISVALID disk_is_page_sector_reserved_with_debug_crash(THREAD_ENTRY *thread_p, VOLID volid, PAGEID pageid, bool debug_crash)
int prm_get_integer_value(PARAM_ID prm_id)
#define pgbuf_set_dirty_and_free(thread_p, pgptr)
static const char * pgbuf_zone_str(PGBUF_ZONE zone)
static int pgbuf_initialize_page_quota(void)
#define OID_IS_ROOTOID(oidp)
LOG_LSA * pgbuf_get_lsa(PAGE_PTR pgptr)
const log_lsa PGBUF_TEMP_LSA
DISK_VOLPURPOSE xdisk_get_purpose(THREAD_ENTRY *thread_p, VOLID volid)
void pgbuf_flush_if_requested(THREAD_ENTRY *thread_p, PAGE_PTR page)
#define VACUUM_IS_THREAD_VACUUM_WORKER
#define ER_PAGE_LATCH_TIMEDOUT
lockfree::circular_queue< int > * private_lrus_with_victims
const char * pgbuf_get_volume_label(PAGE_PTR pgptr)
static int pgbuf_victimize_bcb(THREAD_ENTRY *thread_p, PGBUF_BCB *bufptr)
PGBUF_HOLDER * next_holder
PERF_CONDITIONAL_FIX_TYPE
#define ER_OUT_OF_VIRTUAL_MEMORY
#define MEM_REGION_SCRAMBLE_MARK
#define detailed_er_log(...)
#define CAST_IOPGPTR_TO_PGPTR(pgptr, io_pgptr)
static int pgbuf_initialize_invalid_list(void)
#define PGBUF_HASH_VALUE(vpid)
PGBUF_LATCH_MODE pgbuf_get_latch_mode(PAGE_PTR pgptr)
TSC_TICKS last_adjust_time
#define PGBUF_TRAN_MAX_ACTIVITY
bool LSA_LE(const log_lsa *plsa1, const log_lsa *plsa2)
#define PGBUF_IS_BCB_OLD_ENOUGH(bcb, lru_list)
bool log_is_log_flush_daemon_available()
void pgbuf_rv_flush_page_dump(FILE *fp, int length, void *data)
#define pgbuf_replace_watcher(thread_p, old_watcher, new_watcher)
PGBUF_IOPAGE_BUFFER * iopage_buffer
STATIC_INLINE void pgbuf_add_watch_instance_internal(PGBUF_HOLDER *holder, PAGE_PTR pgptr, PGBUF_WATCHER *watcher, const PGBUF_LATCH_MODE latch_mode, const bool clear_unfix_flag, const char *caller_file, const int caller_line)
STATIC_INLINE bool pgbuf_lfcq_add_lru_with_victims(PGBUF_LRU_LIST *lru_list)
#define PGBUF_IS_PRIVATE_LRU_INDEX(lru_idx)
int pgbuf_rv_set_tde_algorithm(THREAD_ENTRY *thread_p, LOG_RCV *rcv)
int pgbuf_rv_new_page_redo(THREAD_ENTRY *thread_p, LOG_RCV *rcv)
#define pthread_mutex_trylock(a)
STATIC_INLINE void pgbuf_lru_fall_bcb_to_zone_3(THREAD_ENTRY *thread_p, PGBUF_BCB *bcb, PGBUF_LRU_LIST *lru_list)
int pgbuf_fix_if_not_deallocated_with_caller(THREAD_ENTRY *thread_p, const VPID *vpid, PGBUF_LATCH_MODE latch_mode, PGBUF_LATCH_CONDITION latch_condition, PAGE_PTR *page, const char *caller_file, int caller_line)
VPID vpids[2 *PGBUF_MAX_NEIGHBOR_PAGES-1]
unsigned long long num_hit
void log_append_compensate_with_undo_nxlsa(THREAD_ENTRY *thread_p, LOG_RCVINDEX rcvindex, const VPID *vpid, PGLENGTH offset, PAGE_PTR pgptr, int length, const void *data, LOG_TDES *tdes, const LOG_LSA *undo_nxlsa)
PGLENGTH db_page_size(void)
#define pthread_mutex_lock(a)
bool pgbuf_is_log_check_for_interrupts(THREAD_ENTRY *thread_p)
void pgbuf_watcher_init_debug(PGBUF_WATCHER *watcher, const char *caller_file, const int caller_line, bool add)
bool logtb_is_current_active(THREAD_ENTRY *thread_p)
PGBUF_BUFFER_LOCK * lock_next
#define VPID_EQ(vpid_ptr1, vpid_ptr2)
unsigned long long num_pages_written
#define PGBUF_LIMIT_AOUT_BUFFERS
void pgbuf_get_page_flush_interval(bool &is_timed_wait, cubthread::delta_time &period)
STATIC_INLINE bool pgbuf_bcb_is_direct_victim(const PGBUF_BCB *bcb)
STATIC_INLINE void pgbuf_add_vpid_to_aout_list(THREAD_ENTRY *thread_p, const VPID *vpid, const int lru_idx)
static void pgbuf_move_bcb_to_bottom_lru(THREAD_ENTRY *thread_p, PGBUF_BCB *bcb)
TDE_ALGORITHM pgbuf_get_tde_algorithm(PAGE_PTR pgptr)
static INLINE bool pgbuf_is_temporary_volume(VOLID volid) __attribute__((ALWAYS_INLINE))
static void pgbuf_flags_mask_sanity_check(void)
#define PGBUF_GET_LRU_INDEX(flags)
STATIC_INLINE bool pgbuf_is_hit_ratio_low(void)
PERF_HOLDER_LATCH perf_latch_mode
STATIC_INLINE bool pgbuf_bcb_should_avoid_deallocation(const PGBUF_BCB *bcb)
void * mht_get(MHT_TABLE *ht, const void *key)
lockfree::circular_queue< int > * shared_lrus_with_victims
const VPID vpid_Null_vpid
#define PGBUF_NEIGHBOR_FLUSH_NONDIRTY
#define ER_PAGE_LATCH_PROMOTE_FAIL
#define PGBUF_FIX_COUNT_THRESHOLD
static void pgbuf_add_fixed_at(PGBUF_HOLDER *holder, const char *caller_file, int caller_line, bool reset)
STATIC_INLINE int pgbuf_latch_bcb_upon_fix(THREAD_ENTRY *thread_p, PGBUF_BCB *bufptr, PGBUF_LATCH_MODE request_mode, int buf_lock_acquired, PGBUF_LATCH_CONDITION condition, bool *is_latch_wait) __attribute__((ALWAYS_INLINE))
STATIC_INLINE void pgbuf_lru_remove_bcb(THREAD_ENTRY *thread_p, PGBUF_BCB *bcb)
#define PGBUF_BCB_UNLOCK(bcb)
STATIC_INLINE void pgbuf_bcb_mark_was_not_flushed(THREAD_ENTRY *thread_p, PGBUF_BCB *bcb, bool mark_dirty)
unsigned int num_data_pages
#define PGBUF_BCB_AVOID_DEALLOC_MASK
#define CAST_BFPTR_TO_PGPTR(pgptr, bufptr)
PERF_PAGE_TYPE btree_get_perf_btree_page_type(THREAD_ENTRY *thread_p, PAGE_PTR page_ptr)
void tsc_getticks(TSC_TICKS *tck)
PGBUF_HOLDER * thrd_hold_list
int pgbuf_rv_flush_page(THREAD_ENTRY *thread_p, LOG_RCV *rcv)
STATIC_INLINE void fileio_set_page_lsa(FILEIO_PAGE *io_page, const LOG_LSA *lsa, PGLENGTH page_size)
int pgbuf_assign_private_lru(THREAD_ENTRY *thread_p, bool is_vacuum, const int id)
STATIC_INLINE bool perfmon_is_perf_tracking(void) __attribute__((ALWAYS_INLINE))
STATIC_INLINE bool perfmon_is_perf_tracking_and_active(int activation_flag) __attribute__((ALWAYS_INLINE))
PGBUF_HOLDER_SET * free_holder_set
bool log_is_in_crash_recovery(void)
bool pgbuf_is_io_stressful(void)
STATIC_INLINE int pgbuf_insert_into_hash_chain(THREAD_ENTRY *thread_p, PGBUF_BUFFER_HASH *hash_anchor, PGBUF_BCB *bufptr) __attribute__((ALWAYS_INLINE))
void pgbuf_force_to_check_for_interrupts(void)
static void pgbuf_wakeup_page_flush_daemon(THREAD_ENTRY *thread_p)
STATIC_INLINE int pgbuf_get_shared_lru_index_for_add(void)
STATIC_INLINE void pgbuf_lru_adjust_zone1(THREAD_ENTRY *thread_p, PGBUF_LRU_LIST *lru_list, bool min_one)
#define PGBUF_BCB_FLUSHING_TO_DISK_FLAG
bool LSA_ISNULL(const log_lsa *lsa_ptr)
#define ER_PB_ORDERED_REFIX_FAILED
static int pgbuf_bcb_safe_flush_force_unlock(THREAD_ENTRY *thread_p, PGBUF_BCB *bufptr, bool synchronous)
static void pgbuf_remove_watcher(PGBUF_HOLDER *holder, PGBUF_WATCHER *watcher_object)
#define PGBUF_FIND_BUFFER_GUARD(bufptr)
#define MIN_PRIVATE_RATIO
int pgbuf_get_hold_count(THREAD_ENTRY *thread_p)
void thread_lock_entry(cubthread::entry *thread_p)
#define pgbuf_fix(thread_p, vpid, fetch_mode, requestmode, condition)
PGBUF_ORDERED_GROUP group_id
MHT_TABLE * mht_create(const char *name, int est_size, unsigned int(*hash_func)(const void *key, unsigned int ht_size), int(*cmp_func)(const void *key1, const void *key2))
DISK_ISVALID disk_is_page_sector_reserved(THREAD_ENTRY *thread_p, VOLID volid, PAGEID pageid)
STATIC_INLINE bool pgbuf_bcb_should_be_moved_to_bottom_lru(const PGBUF_BCB *bcb)
DB_VALUE * showstmt_alloc_tuple_in_context(THREAD_ENTRY *thread_p, SHOWSTMT_ARRAY_CONTEXT *ctx)
PGBUF_HOLDER * thrd_free_list
#define PGBUF_PAGE_QUOTA_IS_ENABLED
#define PGBUF_BCB_VICTIM_DIRECT_FLAG
unsigned dirty_before_hold
int pgbuf_get_condition_for_ordered_fix(const VPID *vpid_new_page, const VPID *vpid_fixed_page, const HFID *hfid)
#define PGBUF_WATCHER_MAGIC_NUMBER
unsigned dirtied_by_holder
std::uint64_t get_consumer_cursor()
STATIC_INLINE void pgbuf_bcb_register_hit_for_lru(PGBUF_BCB *bcb)
#define FILEIO_PAGE_FLAG_ENCRYPTED_AES
STATIC_INLINE void pgbuf_lru_add_victim_candidate(THREAD_ENTRY *thread_p, PGBUF_LRU_LIST *lru_list, PGBUF_BCB *bcb)
int pgbuf_flush_all(THREAD_ENTRY *thread_p, VOLID volid)
STATIC_INLINE void pgbuf_lru_add_new_bcb_to_middle(THREAD_ENTRY *thread_p, PGBUF_BCB *bcb, int lru_idx)
void er_set_with_oserror(int severity, const char *file_name, const int line_no, int err_id, int num_args,...)
int count(int &result, const cub_regex_object ®, const std::string &src, const int position, const INTL_CODESET codeset)
static bool pgbuf_is_page_flush_daemon_available()
PGBUF_PAGE_MONITOR monitor
static int pgbuf_bcb_safe_flush_force_lock(THREAD_ENTRY *thread_p, PGBUF_BCB *bufptr, bool synchronous)
#define ER_CSS_PTHREAD_COND_TIMEDWAIT
STATIC_INLINE bool pgbuf_bcb_is_to_vacuum(const PGBUF_BCB *bcb)
void pgbuf_get_vpid(PAGE_PTR pgptr, VPID *vpid)
const LOG_LSA * pgbuf_set_lsa(THREAD_ENTRY *thread_p, PAGE_PTR pgptr, const LOG_LSA *lsa_ptr)
int dwb_set_data_on_next_slot(THREAD_ENTRY *thread_p, FILEIO_PAGE *io_page_p, bool can_wait, DWB_SLOT **p_dwb_slot)
#define PGBUF_BCB_LOCK(bcb)
STATIC_INLINE void perfmon_diff_timeval(struct timeval *elapsed, struct timeval *start, struct timeval *end) __attribute__((ALWAYS_INLINE))
#define PGBUF_FIND_IOPAGE_PTR(i)
STATIC_INLINE bool pgbuf_bcb_is_hot(const PGBUF_BCB *bcb)
STATIC_INLINE int pgbuf_delete_from_hash_chain(THREAD_ENTRY *thread_p, PGBUF_BCB *bufptr) __attribute__((ALWAYS_INLINE))
#define FILEIO_PAGE_FLAG_ENCRYPTED_ARIA
static int pgbuf_get_victim_candidates_from_lru(THREAD_ENTRY *thread_p, int check_count, float lru_sum_flush_priority, bool *assigned_directly)
int pgbuf_invalidate_all_debug(THREAD_ENTRY *thread_p, VOLID volid, const char *caller_file, int caller_line)
STATIC_INLINE int pgbuf_unlatch_bcb_upon_unfix(THREAD_ENTRY *thread_p, PGBUF_BCB *bufptr, int holder_status) __attribute__((ALWAYS_INLINE))
bool logtb_is_interrupted(THREAD_ENTRY *thread_p, bool clear, bool *continue_checking)
#define PGBUF_GET_ZONE(flags)
static void error(const char *msg)
int control_intervals_cnt
#define pthread_mutex_unlock(a)
#define VPID_ISNULL(vpid_ptr)
void thread_unlock_entry(cubthread::entry *thread_p)
void * fileio_write(THREAD_ENTRY *thread_p, int vol_fd, void *io_page_p, PAGEID page_id, size_t page_size, FILEIO_WRITE_MODE write_mode)
STATIC_INLINE void perfmon_inc_stat(THREAD_ENTRY *thread_p, PERF_STAT_ID psid) __attribute__((ALWAYS_INLINE))
STATIC_INLINE void pgbuf_bcb_register_fix(PGBUF_BCB *bcb)
std::chrono::system_clock::duration delta_time
LOG_TDES * LOG_FIND_CURRENT_TDES(THREAD_ENTRY *thread_p=NULL)
#define PBGUF_BIG_PRIVATE_MIN_SIZE
static int pgbuf_bcb_safe_flush_internal(THREAD_ENTRY *thread_p, PGBUF_BCB *bufptr, bool synchronous, bool *locked)
#define LOG_FIND_THREAD_TRAN_INDEX(thrd)
PGBUF_VICTIM_CANDIDATE_LIST * flush_list
STATIC_INLINE bool pgbuf_bcb_mark_is_flushing(THREAD_ENTRY *thread_p, PGBUF_BCB *bcb)
#define HFID_IS_NULL(hfid)
static int pgbuf_compare_hold_vpid_for_sort(const void *p1, const void *p2)
QUERY_ID qmgr_get_current_query_id(THREAD_ENTRY *thread_p)
static PGBUF_BCB * pgbuf_get_bcb_from_invalid_list(THREAD_ENTRY *thread_p)
#define TSC_ADD_TIMEVAL(total, diff)
void pgbuf_daemons_get_stats(UINT64 *stats_out)
#define PGBUF_BUFFER_LOCK_SIZEOF
void destroy_daemon(daemon *&daemon_arg)
PERF_PAGE_TYPE pgbuf_get_page_type_for_stat(THREAD_ENTRY *thread_p, PAGE_PTR pgptr)
void logpb_flush_log_for_wal(THREAD_ENTRY *thread_p, const LOG_LSA *lsa_ptr)
static void pgbuf_lru_move_from_private_to_shared(THREAD_ENTRY *thread_p, PGBUF_BCB *bcb)
#define snprintf_dots_truncate(dest, max_len,...)
VOLID pgbuf_get_volume_id(PAGE_PTR pgptr)
PGBUF_AOUT_LIST buf_AOUT_list
STATIC_INLINE void pgbuf_lru_remove_victim_candidate(THREAD_ENTRY *thread_p, PGBUF_LRU_LIST *lru_list, PGBUF_BCB *bcb)
STATIC_INLINE void perfmon_time_stat(THREAD_ENTRY *thread_p, PERF_STAT_ID psid, UINT64 timediff) __attribute__((ALWAYS_INLINE))
float prm_get_float_value(PARAM_ID prm_id)
PGBUF_AOUT_BUF * Aout_free
void * pgbuf_copy_from_area(THREAD_ENTRY *thread_p, const VPID *vpid, int start_offset, int length, void *area, bool do_fetch, TDE_ALGORITHM tde_algo)
int er_errid_if_has_error(void)
#define PGBUF_IS_BCB_IN_LRU_VICTIM_ZONE(bcb)
STATIC_INLINE int pgbuf_unlatch_thrd_holder(THREAD_ENTRY *thread_p, PGBUF_BCB *bufptr, PGBUF_HOLDER_STAT *holder_perf_stat_p) __attribute__((ALWAYS_INLINE))
PGBUF_BUFFER_LOCK * lock_next
#define free_and_init(ptr)
#define LOG_ISRESTARTED()
void pgbuf_flush(THREAD_ENTRY *thread_p, PAGE_PTR pgptr, bool free_page)
int tde_decrypt_data_page(const FILEIO_PAGE *iopage_cipher, TDE_ALGORITHM tde_algo, bool is_temp, FILEIO_PAGE *iopage_plain)
unsigned long long num_page_request
void LSA_SET_NULL(log_lsa *lsa_ptr)
bool pgbuf_is_page_fixed_by_thread(THREAD_ENTRY *thread_p, const VPID *vpid_p)
#define ER_LOG_CHECKPOINT_SKIP_INVALID_PAGE
bool LSA_GT(const log_lsa *plsa1, const log_lsa *plsa2)
PAGE_PTR pgbuf_fix_with_retry(THREAD_ENTRY *thread_p, const VPID *vpid, PAGE_FETCH_MODE fetch_mode, PGBUF_LATCH_MODE request_mode, int retry)
#define PGBUF_BCB_CHECK_OWN(bcb)
void log_append_empty_record(THREAD_ENTRY *thread_p, LOG_RECTYPE logrec_type, LOG_DATA_ADDR *addr)
#define PGBUF_LRU_ZONE_MIN_RATIO
STATIC_INLINE bool pgbuf_bcb_is_flushing(const PGBUF_BCB *bcb)
#define PGBUF_LRU_ARE_ZONES_ONE_TWO_OVER_THRESHOLD(list)
#define ER_CSS_PTHREAD_MUTEX_TRYLOCK
PGBUF_STATUS_SNAPSHOT show_status_snapshot
float private_pages_ratio
#define PGBUF_BCB_TO_VACUUM_FLAG
void pgbuf_set_page_ptype(THREAD_ENTRY *thread_p, PAGE_PTR pgptr, PAGE_TYPE ptype)
#define AOUT_HASH_DIVIDE_RATIO
STATIC_INLINE bool pgbuf_bcb_is_dirty(const PGBUF_BCB *bcb)
bool heap_is_page_header(THREAD_ENTRY *thread_p, PAGE_PTR page)
bool prm_get_bool_value(PARAM_ID prm_id)
unsigned long long num_pages_written
int pgbuf_page_has_changed(PAGE_PTR pgptr, LOG_LSA *ref_lsa)
int logtb_find_client_name_host_pid(int tran_index, const char **client_prog_name, const char **client_user_name, const char **client_host_name, int *client_pid)
int thread_suspend_timeout_wakeup_and_unlock_entry(cubthread::entry *thread_p, struct timespec *time_p, thread_resume_suspend_status suspended_reason)
int pgbuf_invalidate_debug(THREAD_ENTRY *thread_p, PAGE_PTR pgptr, const char *caller_file, int caller_line)
unsigned page_was_unfixed
static PGBUF_BCB * pgbuf_lfcq_get_victim_from_shared_lru(THREAD_ENTRY *thread_p, bool multi_threaded)
#define PGBUF_DESIRED_HIT_VS_MISS_RATE
PGBUF_HOLDER element[PGBUF_NUM_ALLOC_HOLDER]
unsigned long long num_hit
std::size_t thread_num_total_threads(void)
#define INIT_HOLDER_STAT(perf_stat)
HFID * pgbuf_ordered_null_hfid
STATIC_INLINE void pgbuf_lru_adjust_zones(THREAD_ENTRY *thread_p, PGBUF_LRU_LIST *lru_list, bool min_one)
PGBUF_WATCHER * last_watcher
STATIC_INLINE void pgbuf_bcb_mark_was_flushed(THREAD_ENTRY *thread_p, PGBUF_BCB *bcb)
#define PGBUF_THREAD_HAS_PRIVATE_LRU(thread_p)
struct pgbuf_aout_buf PGBUF_AOUT_BUF
unsigned int pgbuf_hash_vpid(const void *key_vpid, unsigned int htsize)
lockfree::circular_queue< int > * big_private_lrus_with_victims
bool log_is_in_crash_recovery_and_not_yet_completes_redo(void)
#define ER_LOG_FLUSH_VICTIM_STARTED
#define PGBUF_LRU_ZONE_MAX_RATIO
#define CAST_PGPTR_TO_BFPTR(bufptr, pgptr)
STATIC_INLINE void pgbuf_add_bufptr_to_batch(PGBUF_BCB *bufptr, int idx)
int db_make_double(DB_VALUE *value, const DB_C_DOUBLE num)
PGBUF_WATCHER * watcher[PGBUF_MAX_PAGE_WATCHERS]
STATIC_INLINE void perfmon_add_stat(THREAD_ENTRY *thread_p, PERF_STAT_ID psid, UINT64 amount) __attribute__((ALWAYS_INLINE))
#define PGBUF_LRU_INDEX_MASK
int pgbuf_rv_dealloc_undo_compensate(THREAD_ENTRY *thread_p, LOG_RCV *rcv)
#define PGBUF_BCB_INVALIDATE_DIRECT_VICTIM_FLAG
PGBUF_BCB *volatile victim_hint
STATIC_INLINE bool pgbuf_bcb_is_async_flush_request(const PGBUF_BCB *bcb)
static int pgbuf_initialize_page_quota_parameters(void)
int db_make_int(DB_VALUE *value, const int num)
STATIC_INLINE bool pgbuf_check_page_ptype_internal(PAGE_PTR pgptr, PAGE_TYPE ptype, bool no_error)
STATIC_INLINE bool pgbuf_check_bcb_page_vpid(PGBUF_BCB *bufptr, bool maybe_deallocated)
bool pgbuf_has_any_waiters(PAGE_PTR pgptr)
#define PGBUF_PRIVATE_LIST_FROM_LRU_INDEX(i)
#define ER_PB_ORDERED_INCONSISTENCY
#define PGBUF_FIND_BCB_PTR(i)
STATIC_INLINE void pgbuf_lru_add_bcb_to_bottom(THREAD_ENTRY *thread_p, PGBUF_BCB *bcb, PGBUF_LRU_LIST *lru_list)
bool produce(const T &element)
#define PGBUF_GET_LRU_LIST(lru_idx)
int tde_encrypt_data_page(const FILEIO_PAGE *iopage_plain, TDE_ALGORITHM tde_algo, bool is_temp, FILEIO_PAGE *iopage_cipher)
STATIC_INLINE int pgbuf_bcb_get_lru_index(const PGBUF_BCB *bcb)
#define PGBUF_BCB_ASYNC_FLUSH_REQ
#define PGBUF_MAX_NEIGHBOR_PAGES
STATIC_INLINE void pgbuf_bcb_register_avoid_deallocation(PGBUF_BCB *bcb)
void pgbuf_peek_stats(UINT64 *fixed_cnt, UINT64 *dirty_cnt, UINT64 *lru1_cnt, UINT64 *lru2_cnt, UINT64 *lru3_cnt, UINT64 *victim_candidates, UINT64 *avoid_dealloc_cnt, UINT64 *avoid_victim_cnt, UINT64 *private_quota, UINT64 *private_cnt, UINT64 *alloc_bcb_waiter_high, UINT64 *alloc_bcb_waiter_med, UINT64 *flushed_bcbs_waiting_direct_assign, UINT64 *lfcq_big_prv_num, UINT64 *lfcq_prv_num, UINT64 *lfcq_shr_num)
daemon * create_daemon(const looper &looper_arg, entry_task *exec_p, const char *daemon_name="", entry_manager *context_manager=NULL)
static void pgbuf_lru_sanity_check(const PGBUF_LRU_LIST *lru)
int heap_get_class_info(THREAD_ENTRY *thread_p, const OID *class_oid, HFID *hfid_out, FILE_TYPE *ftype_out, char **classname_out)
STATIC_INLINE bool pgbuf_is_bcb_victimizable(PGBUF_BCB *bcb, bool has_mutex_lock)
#define PGBUF_LRU_LIST_SIZEOF
#define pgbuf_ordered_unfix(thread_p, watcher_object)
STATIC_INLINE PGBUF_LRU_LIST * pgbuf_lru_list_from_bcb(const PGBUF_BCB *bcb)
int dwb_add_page(THREAD_ENTRY *thread_p, FILEIO_PAGE *io_page_p, VPID *vpid, DWB_SLOT **p_dwb_slot)
static void pgbuf_unlatch_void_zone_bcb(THREAD_ENTRY *thread_p, PGBUF_BCB *bcb, int thread_private_lru_index)
STATIC_INLINE void pgbuf_set_bcb_page_vpid(PGBUF_BCB *bufptr, bool force_set_vpid)
PGBUF_HOLDER_STAT perf_stat
PERF_PAGE_TYPE perf_page_type
#define PGBUF_LRU_VICTIM_LFCQ_FLAG
static void pgbuf_compute_lru_vict_target(float *lru_sum_flush_priority)
#define PGBUF_CHKPT_MIN_FLUSH_RATE
#define PGBUF_PAGES_COUNT_THRESHOLD
int timeval_add_msec(struct timeval *added_time, const struct timeval *start_time, int msec)
TSC_TICKS start_holder_tick
#define PGBUF_BCB_MOVE_TO_LRU_BOTTOM_FLAG
callable_task< entry > entry_callable_task
#define pgbuf_ordered_unfix_and_init(thread_p, page, pg_watcher)
int fileio_flush_control_initialize(void)
unsigned long long num_pages_read
#define PGBUF_LRU_LIST_IS_OVER_QUOTA_WITH_BUFFER(list)
PGBUF_LATCH_MODE latch_mode
#define VPID_SET_NULL(vpid_ptr)
#define PGBUF_MINIMUM_BUFFERS
void pgbuf_set_lsa_as_temporary(THREAD_ENTRY *thread_p, PAGE_PTR pgptr)
void pgbuf_set_tde_algorithm(THREAD_ENTRY *thread_p, PAGE_PTR pgptr, TDE_ALGORITHM tde_algo, bool skip_logging)
static int pgbuf_initialize_hash_table(void)
int pgbuf_flush_checkpoint(THREAD_ENTRY *thread_p, const LOG_LSA *flush_upto_lsa, const LOG_LSA *prev_chkpt_redo_lsa, LOG_LSA *smallest_lsa, int *flushed_page_cnt)
unsigned hold_has_read_latch
int pgbuf_release_private_lru(THREAD_ENTRY *thread_p, const int private_idx)
void pgbuf_adjust_quotas(THREAD_ENTRY *thread_p)
static void pgbuf_init_temp_page_lsa(FILEIO_PAGE *io_page, PGLENGTH page_size)
int logtb_find_wait_msecs(int tran_index)
static PGBUF_BCB * pgbuf_allocate_bcb(THREAD_ENTRY *thread_p, const VPID *src_vpid)
#define PGBUF_INIT_WATCHER(w, rank, hfid)
int fileio_page_check_corruption(THREAD_ENTRY *thread_p, FILEIO_PAGE *io_page, bool *is_page_corrupted)
static int pgbuf_initialize_thrd_holder(void)
PGBUF_AOUT_BUF * Aout_bottom
#define MEM_REGION_INIT(region, size)
#define PGBUF_HOLDER_ANCHOR_SIZEOF
#define PGBUF_BCB_INIT_FLAGS
STATIC_INLINE bool pgbuf_is_bcb_fixed_by_any(PGBUF_BCB *bcb, bool has_mutex_lock)
STATIC_INLINE void pgbuf_lru_add_new_bcb_to_bottom(THREAD_ENTRY *thread_p, PGBUF_BCB *bcb, int lru_idx)
PGBUF_LRU_LIST * buf_LRU_list
VPID * pgbuf_get_vpid_ptr(PAGE_PTR pgptr)
static int pgbuf_compare_victim_list(const void *p1, const void *p2)
void pgbuf_reset_temp_lsa(PAGE_PTR pgptr)
static void pgbuf_scan_bcb_table()
static PGBUF_BCB * pgbuf_claim_bcb_for_fix(THREAD_ENTRY *thread_p, const VPID *vpid, PAGE_FETCH_MODE fetch_mode, PGBUF_BUFFER_HASH *hash_anchor, PGBUF_FIX_PERF *perf, bool *try_again)
LOG_LSA oldest_unflush_lsa
int db_value_domain_init(DB_VALUE *value, const DB_TYPE type, const int precision, const int scale)
#define WAIT_FLUSH_VICTIMS_MAX_MSEC
unsigned long long num_pages_read
STATIC_INLINE int pgbuf_remove_thrd_holder(THREAD_ENTRY *thread_p, PGBUF_HOLDER *holder) __attribute__((ALWAYS_INLINE))
int fileio_get_volume_descriptor(VOLID vol_id)
int fileio_flush_control_add_tokens(THREAD_ENTRY *thread_p, INT64 diff_usec, int *token_gen, int *token_consumed)
bool thread_get_sort_stats_active(cubthread::entry *thread_p)