CUBRID Engine  latest
log_impl.h
Go to the documentation of this file.
1 /*
2  * Copyright 2008 Search Solution Corporation
3  * Copyright 2016 CUBRID Corporation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 
20 /*
21  * log_impl.h -
22  *
23  */
24 
25 #ifndef _LOG_IMPL_H_
26 #define _LOG_IMPL_H_
27 
28 #ident "$Id$"
29 
30 #if !defined (SERVER_MODE) && !defined (SA_MODE)
31 #error Wrong module
32 #endif // not SERVER/SA modes
33 
34 #include "boot.h"
35 #include "btree_unique.hpp"
36 #include "client_credentials.hpp"
37 #include "config.h"
38 #include "connection_globals.h"
39 #include "critical_section.h"
40 #include "es.h"
41 #include "file_io.h"
42 #include "lock_free.h"
43 #include "lock_manager.h"
44 #include "log_2pc.h"
45 #include "log_append.hpp"
46 #include "log_archives.hpp"
47 #include "log_comm.h"
48 #include "log_common_impl.h"
49 #include "log_lsa.hpp"
50 #include "log_postpone_cache.hpp"
51 #include "log_storage.hpp"
52 #include "mvcc.h"
53 #include "mvcc_table.hpp"
54 #include "porting.h"
55 #include "recovery.h"
56 #include "release_string.h"
57 #include "storage_common.h"
58 #include "thread_entry.hpp"
60 #include "tde.h"
61 
62 #include <assert.h>
63 #if defined(SOLARIS)
64 #include <netdb.h> /* for MAXHOSTNAMELEN */
65 #endif /* SOLARIS */
66 #include <signal.h>
67 
68 // forward declarations
69 struct bo_restart_arg;
70 struct logwr_info;
71 
72 #if defined(SERVER_MODE)
73 #define TR_TABLE_CS_ENTER(thread_p) \
74  csect_enter((thread_p), CSECT_TRAN_TABLE, INF_WAIT)
75 #define TR_TABLE_CS_ENTER_READ_MODE(thread_p) \
76  csect_enter_as_reader((thread_p), CSECT_TRAN_TABLE, INF_WAIT)
77 #define TR_TABLE_CS_EXIT(thread_p) \
78  csect_exit((thread_p), CSECT_TRAN_TABLE)
79 
80 #define LOG_ARCHIVE_CS_ENTER(thread_p) \
81  csect_enter (thread_p, CSECT_LOG_ARCHIVE, INF_WAIT)
82 #define LOG_ARCHIVE_CS_ENTER_READ_MODE(thread_p) \
83  csect_enter_as_reader (thread_p, CSECT_LOG_ARCHIVE, INF_WAIT)
84 #define LOG_ARCHIVE_CS_EXIT(thread_p) \
85  csect_exit (thread_p, CSECT_LOG_ARCHIVE)
86 
87 #else /* SERVER_MODE */
88 #define TR_TABLE_CS_ENTER(thread_p)
89 #define TR_TABLE_CS_ENTER_READ_MODE(thread_p)
90 #define TR_TABLE_CS_EXIT(thread_p)
91 
92 #define LOG_ARCHIVE_CS_ENTER(thread_p)
93 #define LOG_ARCHIVE_CS_ENTER_READ_MODE(thread_p)
94 #define LOG_ARCHIVE_CS_EXIT(thread_p)
95 #endif /* SERVER_MODE */
96 
97 #if defined(SERVER_MODE)
98 
99 #define LOG_ARCHIVE_CS_OWN(thread_p) \
100  (csect_check (thread_p, CSECT_LOG_ARCHIVE) >= 1)
101 #define LOG_ARCHIVE_CS_OWN_WRITE_MODE(thread_p) \
102  (csect_check_own (thread_p, CSECT_LOG_ARCHIVE) == 1)
103 #define LOG_ARCHIVE_CS_OWN_READ_MODE(thread_p) \
104  (csect_check_own (thread_p, CSECT_LOG_ARCHIVE) == 2)
105 
106 #else /* SERVER_MODE */
107 #define LOG_ARCHIVE_CS_OWN(thread_p) (true)
108 #define LOG_ARCHIVE_CS_OWN_WRITE_MODE(thread_p) (true)
109 #define LOG_ARCHIVE_CS_OWN_READ_MODE(thread_p) (true)
110 #endif /* !SERVER_MODE */
111 
112 #define LOG_ESTIMATE_NACTIVE_TRANS 100 /* Estimate num of trans */
113 #define LOG_ESTIMATE_NOBJ_LOCKS 977 /* Estimate num of locks */
114 
115 /* Log data area */
116 #define LOGAREA_SIZE (LOG_PAGESIZE - SSIZEOF(LOG_HDRPAGE))
117 
118 /* check if group commit is active */
119 #define LOG_IS_GROUP_COMMIT_ACTIVE() \
120  (prm_get_integer_value (PRM_ID_LOG_GROUP_COMMIT_INTERVAL_MSECS) > 0)
121 
122 #define LOG_READ_ALIGN(thread_p, lsa, log_pgptr) \
123  do \
124  { \
125  (lsa)->offset = DB_ALIGN ((lsa)->offset, DOUBLE_ALIGNMENT); \
126  while ((lsa)->offset >= (int) LOGAREA_SIZE) \
127  { \
128  assert (log_pgptr != NULL); \
129  (lsa)->pageid++; \
130  if (logpb_fetch_page ((thread_p), (lsa), LOG_CS_FORCE_USE, (log_pgptr)) != NO_ERROR) \
131  { \
132  logpb_fatal_error ((thread_p), true, ARG_FILE_LINE, \
133  "LOG_READ_ALIGN"); \
134  } \
135  (lsa)->offset -= LOGAREA_SIZE; \
136  (lsa)->offset = DB_ALIGN ((lsa)->offset, DOUBLE_ALIGNMENT); \
137  } \
138  } \
139  while (0)
140 
141 #define LOG_READ_ADD_ALIGN(thread_p, add, lsa, log_pgptr) \
142  do \
143  { \
144  (lsa)->offset += (add); \
145  LOG_READ_ALIGN ((thread_p), (lsa), (log_pgptr)); \
146  } \
147  while (0)
148 
149 #define LOG_READ_ADVANCE_WHEN_DOESNT_FIT(thread_p, length, lsa, log_pgptr) \
150  do \
151  { \
152  if ((lsa)->offset + (int) (length) >= (int) LOGAREA_SIZE) \
153  { \
154  assert (log_pgptr != NULL); \
155  (lsa)->pageid++; \
156  if ((logpb_fetch_page ((thread_p), (lsa), LOG_CS_FORCE_USE, log_pgptr))!= NO_ERROR) \
157  { \
158  logpb_fatal_error ((thread_p), true, ARG_FILE_LINE, \
159  "LOG_READ_ADVANCE_WHEN_DOESNT_FIT"); \
160  } \
161  (lsa)->offset = 0; \
162  } \
163  } \
164  while (0)
165 
166 #if defined(SERVER_MODE)
167 // todo - separate the client & server/sa_mode transaction index
168 #if !defined(LOG_FIND_THREAD_TRAN_INDEX)
169 #define LOG_FIND_THREAD_TRAN_INDEX(thrd) \
170  ((thrd) ? (thrd)->tran_index : logtb_get_current_tran_index ())
171 #endif
172 #define LOG_SET_CURRENT_TRAN_INDEX(thrd, index) \
173  ((thrd) ? (void) ((thrd)->tran_index = (index)) : logtb_set_current_tran_index ((thrd), (index)))
174 #else /* SERVER_MODE */
175 #if !defined(LOG_FIND_THREAD_TRAN_INDEX)
176 #define LOG_FIND_THREAD_TRAN_INDEX(thrd) (log_Tran_index)
177 #endif
178 #define LOG_SET_CURRENT_TRAN_INDEX(thrd, index) \
179  log_Tran_index = (index)
180 #endif /* SERVER_MODE */
181 
182 #define LOG_ISTRAN_ACTIVE(tdes) \
183  ((tdes)->state == TRAN_ACTIVE && LOG_ISRESTARTED ())
184 
185 #define LOG_ISTRAN_COMMITTED(tdes) \
186  ((tdes)->state == TRAN_UNACTIVE_COMMITTED \
187  || (tdes)->state == TRAN_UNACTIVE_WILL_COMMIT \
188  || (tdes)->state == TRAN_UNACTIVE_COMMITTED_WITH_POSTPONE \
189  || (tdes)->state == TRAN_UNACTIVE_2PC_COMMIT_DECISION \
190  || (tdes)->state == TRAN_UNACTIVE_COMMITTED_INFORMING_PARTICIPANTS)
191 
192 #define LOG_ISTRAN_ABORTED(tdes) \
193  ((tdes)->state == TRAN_UNACTIVE_ABORTED \
194  || (tdes)->state == TRAN_UNACTIVE_UNILATERALLY_ABORTED \
195  || (tdes)->state == TRAN_UNACTIVE_2PC_ABORT_DECISION \
196  || (tdes)->state == TRAN_UNACTIVE_ABORTED_INFORMING_PARTICIPANTS)
197 
198 #define LOG_ISTRAN_LOOSE_ENDS(tdes) \
199  ((tdes)->state == TRAN_UNACTIVE_COMMITTED_INFORMING_PARTICIPANTS \
200  || (tdes)->state == TRAN_UNACTIVE_ABORTED_INFORMING_PARTICIPANTS \
201  || (tdes)->state == TRAN_UNACTIVE_2PC_COLLECTING_PARTICIPANT_VOTES \
202  || (tdes)->state == TRAN_UNACTIVE_2PC_PREPARE)
203 
204 #define LOG_ISTRAN_2PC_IN_SECOND_PHASE(tdes) \
205  ((tdes)->state == TRAN_UNACTIVE_2PC_ABORT_DECISION \
206  || (tdes)->state == TRAN_UNACTIVE_2PC_COMMIT_DECISION \
207  || (tdes)->state == TRAN_UNACTIVE_WILL_COMMIT \
208  || (tdes)->state == TRAN_UNACTIVE_COMMITTED_WITH_POSTPONE \
209  || (tdes)->state == TRAN_UNACTIVE_ABORTED_INFORMING_PARTICIPANTS \
210  || (tdes)->state == TRAN_UNACTIVE_COMMITTED_INFORMING_PARTICIPANTS)
211 
212 #define LOG_ISTRAN_2PC(tdes) \
213  ((tdes)->state == TRAN_UNACTIVE_2PC_COLLECTING_PARTICIPANT_VOTES \
214  || (tdes)->state == TRAN_UNACTIVE_2PC_PREPARE \
215  || LOG_ISTRAN_2PC_IN_SECOND_PHASE (tdes))
216 
217 #define LOG_ISTRAN_2PC_PREPARE(tdes) \
218  ((tdes)->state == TRAN_UNACTIVE_2PC_PREPARE)
219 
220 #define LOG_ISTRAN_2PC_INFORMING_PARTICIPANTS(tdes) \
221  ((tdes)->state == TRAN_UNACTIVE_COMMITTED_INFORMING_PARTICIPANTS \
222  || (tdes)->state == TRAN_UNACTIVE_ABORTED_INFORMING_PARTICIPANTS)
223 
226 
227 #define LOG_READ_NEXT_TRANID (log_Gl.hdr.next_trid)
228 #define LOG_READ_NEXT_MVCCID (log_Gl.hdr.mvcc_next_id)
229 #define LOG_HAS_LOGGING_BEEN_IGNORED() \
230  (log_Gl.hdr.has_logging_been_skipped == true)
231 
232 #define LOG_ISRESTARTED() (log_Gl.rcv_phase == LOG_RESTARTED)
233 
234 /* special action for log applier */
235 #if defined (SERVER_MODE)
236 #define LOG_CHECK_LOG_APPLIER(thread_p) \
237  (thread_p != NULL \
238  && logtb_find_client_type (thread_p->tran_index) == DB_CLIENT_TYPE_LOG_APPLIER)
239 #else
240 #define LOG_CHECK_LOG_APPLIER(thread_p) (0)
241 #endif /* !SERVER_MODE */
242 
243 #if !defined(_DB_DISABLE_MODIFICATIONS_)
244 #define _DB_DISABLE_MODIFICATIONS_
245 extern int db_Disable_modifications;
246 #endif /* _DB_DISABLE_MODIFICATIONS_ */
247 
248 #ifndef CHECK_MODIFICATION_NO_RETURN
249 #if defined (SA_MODE)
250 #define CHECK_MODIFICATION_NO_RETURN(thread_p, error) \
251  (error) = NO_ERROR
252 #else /* SA_MODE */
253 #define CHECK_MODIFICATION_NO_RETURN(thread_p, error) \
254  do \
255  { \
256  int mod_disabled; \
257  mod_disabled = logtb_is_tran_modification_disabled (thread_p); \
258  if (mod_disabled) \
259  { \
260  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_DB_NO_MODIFICATIONS, \
261  0); \
262  er_log_debug (ARG_FILE_LINE, "tdes->disable_modification = %d\n", \
263  mod_disabled); \
264  error = ER_DB_NO_MODIFICATIONS; \
265  } \
266  else \
267  { \
268  error = NO_ERROR; \
269  } \
270  } \
271  while (0)
272 #endif /* !SA_MODE */
273 #endif /* CHECK_MODIFICATION_NO_RETURN */
274 
275 #define MAX_NUM_EXEC_QUERY_HISTORY 100
276 
279 typedef enum log_flush LOG_FLUSH;
280 
284 
288 
292 
293 /*
294  * Flush information shared by LFT and normal transaction.
295  * Transaction in commit phase has to flush all toflush array's pages.
296  */
299 {
300  /* Size of array to log append pages to flush */
302 
303  /* Number of log append pages that can be flush Not all of the append pages may be full. */
305 
306  /* A sorted order of log append free pages to flush */
308 
309 #if defined(SERVER_MODE)
310  /* for protecting LOG_FLUSH_INFO */
311  pthread_mutex_t flush_mutex;
312 #endif /* SERVER_MODE */
313 };
314 
317 {
318  /* group commit waiters count */
319  pthread_mutex_t gc_mutex;
320  pthread_cond_t gc_cond;
321 };
322 
323 #define LOG_GROUP_COMMIT_INFO_INITIALIZER \
324  { PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER }
325 
326 
327 
330 {
331  LOG_LSA lastparent_lsa; /* The last address of the parent transaction. This is needed for undo of the top
332  * system action */
333  LOG_LSA posp_lsa; /* The first address of a postpone log record for top system operation. We add this
334  * since it is reset during recovery to the last reference postpone address. */
335 };
336 
338 {
343 };
345 
348 {
349  int max; /* Size of stack */
350  int last; /* Last entry in stack */
351  LOG_TOPOPS_ADDRESSES *stack; /* Stack for push and pop of top system actions */
352 };
353 
355 {
359 };
361 
364 {
365  int num_nulls; /* number of nulls */
366  int num_keys; /* number of keys */
367  int num_oids; /* number of oids */
368 };
369 
372 {
373  BTID btid; /* id of B-tree */
374  bool deleted; /* true if the B-tree was deleted */
375 
376  LOG_UNIQUE_STATS tran_stats; /* statistics accumulated during entire transaction */
377  LOG_UNIQUE_STATS global_stats; /* statistics loaded from index */
378 };
379 
381 {
382  COS_NOT_LOADED = 0, /* the global statistics was not loaded yet */
383  COS_TO_LOAD = 1, /* the global statistics must be loaded when snapshot is taken */
384  COS_LOADED = 2 /* the global statistics were loaded */
385 };
387 
388 #define TRAN_UNIQUE_STATS_CHUNK_SIZE 128 /* size of the memory chunk for unique statistics */
389 
390 /* LOG_TRAN_BTID_UNIQUE_STATS_CHUNK
391  * Represents a chunk of memory for transaction unique statistics
392  */
395 {
396  LOG_TRAN_BTID_UNIQUE_STATS_CHUNK *next_chunk; /* address of next chunk of memory */
397  LOG_TRAN_BTID_UNIQUE_STATS buffer[1]; /* more than one */
398 };
399 
400 /* LOG_TRAN_CLASS_COS
401  * Structure used to store the state of the count optimization for classes.
402  */
405 {
406  OID class_oid; /* class object identifier. */
407  COUNT_OPTIM_STATE count_state; /* count optimization state for class_oid */
408 };
409 
410 #define COS_CLASSES_CHUNK_SIZE 64 /* size of the memory chunk for count optimization classes */
411 
412 /* LOG_TRAN_CLASS_COS_CHUNK
413  * Represents a chunk of memory for count optimization states
414  */
417 {
418  LOG_TRAN_CLASS_COS_CHUNK *next_chunk; /* address of next chunk of memory */
419  LOG_TRAN_CLASS_COS buffer[1]; /* more than one */
420 };
421 
422 /* LOG_TRAN_UPDATE_STATS
423  * Structure used for transaction local unique statistics and count optimization
424  * management
425  */
428 {
429  int cos_count; /* the number of hashed elements */
430  LOG_TRAN_CLASS_COS_CHUNK *cos_first_chunk; /* address of first chunk in the chunks list */
431  LOG_TRAN_CLASS_COS_CHUNK *cos_current_chunk; /* address of current chunk from which new elements are assigned */
432  MHT_TABLE *classes_cos_hash; /* hash of count optimization states for classes that were or will be subject to count
433  * optimization. */
434 
435  int stats_count; /* the number of hashed elements */
436  LOG_TRAN_BTID_UNIQUE_STATS_CHUNK *stats_first_chunk; /* address of first chunk in the chunks list */
437  LOG_TRAN_BTID_UNIQUE_STATS_CHUNK *stats_current_chunk; /* address of current chunk from which new elements are
438  * assigned */
439  MHT_TABLE *unique_stats_hash; /* hash of unique statistics for indexes used during transaction. */
440 };
441 
442 typedef struct log_rcv_tdes LOG_RCV_TDES;
444 {
445  /* structure stored in transaction descriptor and used for recovery purpose.
446  * currently we store the LSA of a system op start postpone. it is required to finish the system op postpone phase
447  * correctly */
449  /* we need to know where transaction postpone has started. */
451  /* we need to know if file_perm_alloc or file_perm_dealloc operations have been interrupted. these operation must be
452  * executed atomically (all changes applied or all rollbacked) before executing finish all postpones. to know what
453  * to abort, we remember the starting LSA of such operation. */
455  LOG_LSA analysis_last_aborted_sysop_lsa; /* to recover logical redo operation. */
456  LOG_LSA analysis_last_aborted_sysop_start_lsa; /* to recover logical redo operation. */
457 };
458 
459 typedef struct log_tdes LOG_TDES;
460 struct log_tdes
461 {
462 /* Transaction descriptor */
463  MVCC_INFO mvccinfo; /* MVCC info */
464 
465  int tran_index; /* Index onto transaction table */
466  TRANID trid; /* Transaction identifier */
467 
469  TRAN_STATE state; /* Transaction state (e.g., Active, aborted) */
470  TRAN_ISOLATION isolation; /* Isolation level */
471  int wait_msecs; /* Wait until this number of milliseconds for locks; also see xlogtb_reset_wait_msecs */
472  LOG_LSA head_lsa; /* First log address of transaction */
473  LOG_LSA tail_lsa; /* Last log record address of transaction */
474  LOG_LSA undo_nxlsa; /* Next log record address of transaction for UNDO purposes. Needed since compensating
475  * log records are logged during UNDO */
476  LOG_LSA posp_nxlsa; /* Next address of a postpone record to be executed. Most of the time is the first
477  * address of a postpone log record */
478  LOG_LSA savept_lsa; /* Address of last savepoint */
479  LOG_LSA topop_lsa; /* Address of last top operation */
480  LOG_LSA tail_topresult_lsa; /* Address of last partial abort/commit */
481  int client_id; /* unique client id */
482  int gtrid; /* Global transaction identifier; used only if this transaction is a participant to a
483  * global transaction and it is prepared to commit. */
484  CLIENTIDS client; /* Client identification */
485  SYNC_RMUTEX rmutex_topop; /* reentrant mutex to serialize system top operations */
486  LOG_TOPOPS_STACK topops; /* Active top system operations. Used for system permanent nested operations which are
487  * independent from current transaction outcome. */
488  LOG_2PC_GTRINFO gtrinfo; /* Global transaction user information; used to store XID of XA interface. */
489  LOG_2PC_COORDINATOR *coord; /* Information about the participants of the distributed transactions. Used only if
490  * this site is the coordinator. Will be NULL if the transaction is a local one, or if
491  * this site is a participant. */
492  int num_unique_btrees; /* # of unique btrees contained in unique_stat_info array */
493  int max_unique_btrees; /* size of unique_stat_info array */
495 #if defined(_AIX)
496  sig_atomic_t interrupt;
497 #else /* _AIX */
498  volatile sig_atomic_t interrupt;
499 #endif /* _AIX */
500  /* Set to one when the current execution must be stopped somehow. We stop it by sending an error message during
501  * fetching of a page. */
502  tx_transient_class_registry m_modified_classes; // list of classes made dirty
503 
504  int num_transient_classnames; /* # of transient classnames by this transaction */
505  int num_repl_records; /* # of replication records */
506  int cur_repl_record; /* # of replication records */
507  int append_repl_recidx; /* index of append replication records */
508  int fl_mark_repl_recidx; /* index of flush marked replication record at first */
509  struct log_repl *repl_records; /* replication records */
510  LOG_LSA repl_insert_lsa; /* insert or mvcc update target lsa */
511  LOG_LSA repl_update_lsa; /* in-place update target lsa */
512  void *first_save_entry; /* first save entry for the transaction */
513 
514  int suppress_replication; /* suppress writing replication logs when flag is set */
515 
516  struct lob_rb_root lob_locator_root; /* all LOB locators to be created or delete during a transaction */
517 
518  INT64 query_timeout; /* a query should be executed before query_timeout time. */
519 
522  XASL_ID xasl_id; /* xasl id of current query */
523  LK_RES *waiting_for_res; /* resource that i'm waiting for */
524  int disable_modifications; /* db_Disable_modification for each tran */
525 
527 
528  /* bind values of executed queries in transaction */
531 
532  int num_log_records_written; /* # of log records generated */
533 
534  LOG_TRAN_UPDATE_STATS log_upd_stats; /* Collects data about inserted/ deleted records during last
535  * command/transaction */
537 
540 
542 
544 
545  // *INDENT-OFF*
546 #if defined (SERVER_MODE) || (defined (SA_MODE) && defined (__cplusplus))
547 
548  bool is_active_worker_transaction () const;
549  bool is_system_transaction () const;
550  bool is_system_main_transaction () const;
551  bool is_system_worker_transaction () const;
552  bool is_allowed_undo () const;
553  bool is_allowed_sysop () const;
554  bool is_under_sysop () const;
555 
556  void lock_topop ();
557  void unlock_topop ();
558 
559  void on_sysop_start ();
560  void on_sysop_end ();
561 
562  // lock global oldest visible mvccid to current value; required for heavy operations that need to do their own
563  // vacuuming, like upgrade domain / reorganize partitions
564  void lock_global_oldest_visible_mvccid ();
565  void unlock_global_oldest_visible_mvccid ();
566 #endif
567  // *INDENT-ON*
568 };
569 
572 {
575 };
576 
577 /* Transaction Table */
578 typedef struct trantable TRANTABLE;
579 struct trantable
580 {
581  int num_total_indices; /* Number of total transaction indices */
582  int num_assigned_indices; /* Number of assigned transaction indices (i.e., number of active thread/clients) */
583  /* Number of coordinator loose end indices */
585  /* Number of prepared participant loose end indices */
587  int hint_free_index; /* Hint for a free index */
588  /* Number of transactions that must be interrupted */
589 #if defined(_AIX)
590  sig_atomic_t num_interrupts;
591 #else /* _AIX */
592  volatile sig_atomic_t num_interrupts;
593 #endif /* _AIX */
594  LOG_ADDR_TDESAREA *area; /* Contiguous area to transaction descriptors */
595  LOG_TDES **all_tdes; /* Pointers to all transaction descriptors */
596 };
597 
598 #define TRANTABLE_INITIALIZER \
599  { 0, 0, 0, 0, 0, 0, NULL, NULL }
600 
601 /* state of recovery process */
603 {
604  LOG_RESTARTED, /* Normal processing.. recovery has been executed. */
605  LOG_RECOVERY_ANALYSIS_PHASE, /* Start recovering. Find the transactions that were active at the time of the crash */
606  LOG_RECOVERY_REDO_PHASE, /* Redoing phase */
607  LOG_RECOVERY_UNDO_PHASE, /* Undoing phase */
608  LOG_RECOVERY_FINISH_2PC_PHASE /* Finishing up transactions that were in 2PC protocol at the time of the crash */
609 };
611 
612 /* stores global statistics for a unique btree */
615 {
616  BTID btid; /* btree id */
617  GLOBAL_UNIQUE_STATS *stack; /* used in freelist */
618  GLOBAL_UNIQUE_STATS *next; /* used in hash table */
619  pthread_mutex_t mutex; /* state mutex */
620  UINT64 del_id; /* delete transaction ID (for lock free) */
621 
622  LOG_UNIQUE_STATS unique_stats; /* statistics for btid unique btree */
623  LOG_LSA last_log_lsa; /* The log lsa of the last RVBT_LOG_GLOBAL_UNIQUE_STATS_COMMIT record logged into the
624  * btree header page of btid */
625 };
626 
627 /* stores global statistics for all unique btrees */
630 {
631  LF_HASH_TABLE unique_stats_hash; /* hash with btid as key and GLOBAL_UNIQUE_STATS as data */
632  LF_ENTRY_DESCRIPTOR unique_stats_descriptor; /* used by unique_stats_hash */
633  LF_FREELIST unique_stats_freelist; /* used by unique_stats_hash */
634 
635  LOG_LSA curr_rcv_rec_lsa; /* This is used at recovery stage to pass the lsa of the log record to be processed, to
636  * the record processing funtion, in order to restore the last_log_lsa from
637  * GLOBAL_UNIQUE_STATS */
638  bool initialized; /* true if the current instance was initialized */
639 };
640 
641 #define GLOBAL_UNIQUE_STATS_TABLE_INITIALIZER \
642  { LF_HASH_TABLE_INITIALIZER, LF_ENTRY_DESCRIPTOR_INITIALIZER, LF_FREELIST_INITIALIZER, LSA_INITIALIZER, false }
643 
644 #define GLOBAL_UNIQUE_STATS_HASH_SIZE 1000
645 
646 /* Global structure to trantable, log buffer pool, etc */
647 typedef struct log_global LOG_GLOBAL;
649 {
650  TRANTABLE trantable; /* Transaction table */
651  LOG_APPEND_INFO append; /* The log append info */
653  LOG_HEADER hdr; /* The log header */
654  LOG_ARCHIVES archive; /* Current archive information */
656 #if defined(SERVER_MODE)
657  LOG_LSA flushed_lsa_lower_bound; /* lsa */
658  pthread_mutex_t chkpt_lsa_lock;
659 #endif /* SERVER_MODE */
661  DKNPAGES chkpt_every_npages; /* How frequent a checkpoint should be taken ? */
662  LOG_RECVPHASE rcv_phase; /* Phase of the recovery */
663  LOG_LSA rcv_phase_lsa; /* LSA of phase (e.g. Restart) */
664 
665 #if defined(SERVER_MODE)
666  bool backup_in_progress;
667 #else /* SERVER_MODE */
669 #endif /* SERVER_MODE */
670 
671  /* Buffer for log hdr I/O, size : SIZEOF_LOG_PAGE_SIZE */
673 
674  /* Flush information for dirty log pages */
676 
677  /* group commit information */
679  /* remote log writer information */
681  /* background log archiving info */
683 
684  mvcctable mvcc_table; /* MVCC table */
685  GLOBAL_UNIQUE_STATS_TABLE unique_stats_table; /* global unique statistics */
686 
687  // *INDENT-OFF*
688  log_global ();
689  ~log_global ();
690  // *INDENT-ON*
691 };
692 
693 /* logging statistics */
694 typedef struct log_logging_stat
695 {
696  /* logpb_next_append_page() call count */
697  unsigned long total_append_page_count;
698  /* last created page id for logging */
700  /* time taken to use a page for logging */
702 
703  /* log buffer full count */
704  unsigned long log_buffer_full_count;
705  /* log buffer flush count by replacement */
707 
708  /* normal flush */
709  /* logpb_flush_all_append_pages() call count */
711  /* pages count to flush in logpb_flush_all_append_pages() */
713  /* total pages count to flush in logpb_flush_all_append_pages() */
715  /* time taken to flush in logpb_flush_all_append_pages() */
717  /* total time taken to flush in logpb_flush_all_append_pages() */
719  /* logpb_flush_pages_direct() count */
720  unsigned long direct_flush_count;
721 
722  /* logpb_flush_header() call count */
723  unsigned long flush_hdr_call_count;
724  /* page count to flush in logpb_flush_header() */
726  /* total page count to flush in logpb_flush_header() */
728 
729  /* total sync count */
730  unsigned long total_sync_count;
731 
732  /* commit count */
733  unsigned long commit_count;
734  /* group commit count */
735  unsigned long last_group_commit_count;
736  /* total group commit count */
738 
739  /* commit count while using a log page */
741  /* total commit count while using a log page */
743 
744  /* commit count included logpb_flush_all_append_pages */
746  /* total commit count included logpb_flush_all_append_pages */
748 
749  /* group commit request count */
750  unsigned long gc_commit_request_count;
751 
752  /* wait time for group commit */
754 
755  /* flush count in group commit mode by LFT */
756  unsigned long gc_flush_count;
757 
758  /* async commit request count */
761 
762 // todo - move to manager
766 
767 #if !defined(SERVER_MODE)
768 #if !defined(LOG_TRAN_INDEX)
769 #define LOG_TRAN_INDEX
770 extern int log_Tran_index; /* Index onto transaction table for current thread of execution (client) */
771 #endif /* !LOG_TRAN_INDEX */
772 #endif /* !SERVER_MODE */
773 
774 extern LOG_GLOBAL log_Gl;
775 
777 
778 /* Name of the database and logs */
779 extern char log_Path[];
780 extern char log_Archive_path[];
781 extern char log_Prefix[];
782 
783 extern const char *log_Db_fullname;
784 extern char log_Name_active[];
785 extern char log_Name_info[];
786 extern char log_Name_bkupinfo[];
787 extern char log_Name_volinfo[];
788 extern char log_Name_bg_archive[];
789 extern char log_Name_removed_archive[];
790 
791 /* logging */
792 #if defined (SA_MODE)
793 #define LOG_THREAD_TRAN_MSG "%s"
794 #define LOG_THREAD_TRAN_ARGS(thread_p) "(SA_MODE)"
795 #else /* !SA_MODE */ /* SERVER_MODE */
796 #define LOG_THREAD_TRAN_MSG "(thr=%d, trid=%d)"
797 #define LOG_THREAD_TRAN_ARGS(thread_p) thread_get_current_entry_index (), LOG_FIND_CURRENT_TDES (thread_p)
798 #endif /* SERVER_MODE */
799 
800 extern int logpb_initialize_pool (THREAD_ENTRY * thread_p);
801 extern void logpb_finalize_pool (THREAD_ENTRY * thread_p);
802 extern bool logpb_is_pool_initialized (void);
803 extern void logpb_invalidate_pool (THREAD_ENTRY * thread_p);
804 extern LOG_PAGE *logpb_create_page (THREAD_ENTRY * thread_p, LOG_PAGEID pageid);
805 extern LOG_PAGE *log_pbfetch (LOG_PAGEID pageid);
806 extern void logpb_set_dirty (THREAD_ENTRY * thread_p, LOG_PAGE * log_pgptr);
807 extern int logpb_flush_page (THREAD_ENTRY * thread_p, LOG_PAGE * log_pgptr);
808 extern LOG_PAGEID logpb_get_page_id (LOG_PAGE * log_pgptr);
809 extern int logpb_initialize_header (THREAD_ENTRY * thread_p, LOG_HEADER * loghdr, const char *prefix_logname,
810  DKNPAGES npages, INT64 * db_creation);
811 extern LOG_PAGE *logpb_create_header_page (THREAD_ENTRY * thread_p);
812 extern void logpb_fetch_header (THREAD_ENTRY * thread_p, LOG_HEADER * hdr);
813 extern void logpb_fetch_header_with_buffer (THREAD_ENTRY * thread_p, LOG_HEADER * hdr, LOG_PAGE * log_pgptr);
814 extern void logpb_flush_header (THREAD_ENTRY * thread_p);
815 extern int logpb_fetch_page (THREAD_ENTRY * thread_p, const LOG_LSA * req_lsa, LOG_CS_ACCESS_MODE access_mode,
816  LOG_PAGE * log_pgptr);
817 extern int logpb_copy_page_from_log_buffer (THREAD_ENTRY * thread_p, LOG_PAGEID pageid, LOG_PAGE * log_pgptr);
818 extern int logpb_copy_page_from_file (THREAD_ENTRY * thread_p, LOG_PAGEID pageid, LOG_PAGE * log_pgptr);
819 extern int logpb_read_page_from_file (THREAD_ENTRY * thread_p, LOG_PAGEID pageid, LOG_CS_ACCESS_MODE access_mode,
820  LOG_PAGE * log_pgptr);
821 extern int logpb_read_page_from_active_log (THREAD_ENTRY * thread_p, LOG_PAGEID pageid, int num_pages,
822  bool decrypt_needed, LOG_PAGE * log_pgptr);
823 extern int logpb_write_page_to_disk (THREAD_ENTRY * thread_p, LOG_PAGE * log_pgptr, LOG_PAGEID logical_pageid);
824 extern PGLENGTH logpb_find_header_parameters (THREAD_ENTRY * thread_p, const bool force_read_log_header,
825  const char *db_fullname, const char *logpath,
826  const char *prefix_logname, PGLENGTH * io_page_size,
827  PGLENGTH * log_page_size, INT64 * db_creation, float *db_compatibility,
828  int *db_charset);
829 extern int logpb_fetch_start_append_page (THREAD_ENTRY * thread_p);
831 extern void logpb_flush_pages_direct (THREAD_ENTRY * thread_p);
832 extern void logpb_flush_pages (THREAD_ENTRY * thread_p, LOG_LSA * flush_lsa);
833 extern void logpb_force_flush_pages (THREAD_ENTRY * thread_p);
834 extern void logpb_force_flush_header_and_pages (THREAD_ENTRY * thread_p);
835 extern void logpb_invalid_all_append_pages (THREAD_ENTRY * thread_p);
836 extern void logpb_flush_log_for_wal (THREAD_ENTRY * thread_p, const LOG_LSA * lsa_ptr);
837 
838 
839 #if defined (ENABLE_UNUSED_FUNCTION)
840 extern void logpb_remove_append (LOG_TDES * tdes);
841 #endif
842 extern void logpb_create_log_info (const char *logname_info, const char *db_fullname);
843 extern bool logpb_find_volume_info_exist (void);
844 extern int logpb_create_volume_info (const char *db_fullname);
845 extern int logpb_recreate_volume_info (THREAD_ENTRY * thread_p);
846 extern VOLID logpb_add_volume (const char *db_fullname, VOLID new_volid, const char *new_volfullname,
847  DISK_VOLPURPOSE new_volpurpose);
848 extern int logpb_scan_volume_info (THREAD_ENTRY * thread_p, const char *db_fullname, VOLID ignore_volid,
849  VOLID start_volid, int (*fun) (THREAD_ENTRY * thread_p, VOLID xvolid,
850  const char *vlabel, void *args), void *args);
851 extern LOG_PHY_PAGEID logpb_to_physical_pageid (LOG_PAGEID logical_pageid);
852 extern bool logpb_is_page_in_archive (LOG_PAGEID pageid);
853 extern bool logpb_is_smallest_lsa_in_archive (THREAD_ENTRY * thread_p);
854 extern int logpb_get_archive_number (THREAD_ENTRY * thread_p, LOG_PAGEID pageid);
855 extern void logpb_decache_archive_info (THREAD_ENTRY * thread_p);
856 extern LOG_PAGE *logpb_fetch_from_archive (THREAD_ENTRY * thread_p, LOG_PAGEID pageid, LOG_PAGE * log_pgptr,
857  int *ret_arv_num, LOG_ARV_HEADER * arv_hdr, bool is_fatal);
858 extern void logpb_remove_archive_logs (THREAD_ENTRY * thread_p, const char *info_reason);
859 extern int logpb_remove_archive_logs_exceed_limit (THREAD_ENTRY * thread_p, int max_count);
860 extern void logpb_copy_from_log (THREAD_ENTRY * thread_p, char *area, int length, LOG_LSA * log_lsa,
861  LOG_PAGE * log_pgptr);
862 extern int logpb_initialize_log_names (THREAD_ENTRY * thread_p, const char *db_fullname, const char *logpath,
863  const char *prefix_logname);
864 extern bool logpb_exist_log (THREAD_ENTRY * thread_p, const char *db_fullname, const char *logpath,
865  const char *prefix_logname);
866 extern LOG_PAGEID logpb_checkpoint (THREAD_ENTRY * thread_p);
867 extern void logpb_dump_checkpoint_trans (FILE * out_fp, int length, void *data);
868 extern int logpb_backup (THREAD_ENTRY * thread_p, int num_perm_vols, const char *allbackup_path,
869  FILEIO_BACKUP_LEVEL backup_level, bool delete_unneeded_logarchives,
870  const char *backup_verbose_file_path, int num_threads, FILEIO_ZIP_METHOD zip_method,
871  FILEIO_ZIP_LEVEL zip_level, int skip_activelog, int sleep_msecs, bool separate_keys);
872 extern int logpb_restore (THREAD_ENTRY * thread_p, const char *db_fullname, const char *logpath,
873  const char *prefix_logname, bo_restart_arg * r_args);
874 extern int logpb_copy_database (THREAD_ENTRY * thread_p, VOLID num_perm_vols, const char *to_db_fullname,
875  const char *to_logpath, const char *to_prefix_logname, const char *toext_path,
876  const char *fileof_vols_and_copypaths);
877 extern int logpb_rename_all_volumes_files (THREAD_ENTRY * thread_p, VOLID num_perm_vols, const char *to_db_fullname,
878  const char *to_logpath, const char *to_prefix_logname,
879  const char *toext_path, const char *fileof_vols_and_renamepaths,
880  bool extern_rename, bool force_delete);
881 extern int logpb_delete (THREAD_ENTRY * thread_p, VOLID num_perm_vols, const char *db_fullname, const char *logpath,
882  const char *prefix_logname, bool force_delete);
883 extern int logpb_check_exist_any_volumes (THREAD_ENTRY * thread_p, const char *db_fullname, const char *logpath,
884  const char *prefix_logname, char *first_vol, bool * is_exist);
885 extern void logpb_fatal_error (THREAD_ENTRY * thread_p, bool logexit, const char *file_name, const int lineno,
886  const char *fmt, ...);
887 extern void logpb_fatal_error_exit_immediately_wo_flush (THREAD_ENTRY * thread_p, const char *file_name,
888  const int lineno, const char *fmt, ...);
889 extern int logpb_check_and_reset_temp_lsa (THREAD_ENTRY * thread_p, VOLID volid);
890 extern void logpb_initialize_arv_page_info_table (void);
891 extern void logpb_initialize_logging_statistics (void);
892 extern int logpb_background_archiving (THREAD_ENTRY * thread_p);
893 extern void xlogpb_dump_stat (FILE * outfp);
894 
895 extern void logpb_dump (THREAD_ENTRY * thread_p, FILE * out_fp);
896 
897 extern int logpb_remove_all_in_log_path (THREAD_ENTRY * thread_p, const char *db_fullname, const char *logpath,
898  const char *prefix_logname);
899 extern TDE_ALGORITHM logpb_get_tde_algorithm (const LOG_PAGE * log_pgptr);
900 extern void logpb_set_tde_algorithm (THREAD_ENTRY * thread_p, LOG_PAGE * log_pgptr, const TDE_ALGORITHM tde_algo);
901 
902 
903 
904 extern void log_recovery (THREAD_ENTRY * thread_p, int ismedia_crash, time_t * stopat);
905 extern LOG_LSA *log_startof_nxrec (THREAD_ENTRY * thread_p, LOG_LSA * lsa, bool canuse_forwaddr);
906 
907 extern void *logtb_realloc_topops_stack (LOG_TDES * tdes, int num_elms);
908 extern void logtb_define_trantable (THREAD_ENTRY * thread_p, int num_expected_tran_indices, int num_expected_locks);
909 extern int logtb_define_trantable_log_latch (THREAD_ENTRY * thread_p, int num_expected_tran_indices);
910 extern void logtb_undefine_trantable (THREAD_ENTRY * thread_p);
913 #if defined(ENABLE_UNUSED_FUNCTION)
914 extern bool logtb_am_i_sole_tran (THREAD_ENTRY * thread_p);
915 extern void logtb_i_am_not_sole_tran (THREAD_ENTRY * thread_p);
916 #endif
917 extern bool logtb_am_i_dba_client (THREAD_ENTRY * thread_p);
918 extern int logtb_assign_tran_index (THREAD_ENTRY * thread_p, TRANID trid, TRAN_STATE state,
919  const BOOT_CLIENT_CREDENTIAL * client_credential, TRAN_STATE * current_state,
920  int wait_msecs, TRAN_ISOLATION isolation);
922 extern void logtb_rv_assign_mvccid_for_undo_recovery (THREAD_ENTRY * thread_p, MVCCID mvccid);
923 extern void logtb_release_tran_index (THREAD_ENTRY * thread_p, int tran_index);
924 extern void logtb_free_tran_index (THREAD_ENTRY * thread_p, int tran_index);
925 extern void logtb_free_tran_index_with_undo_lsa (THREAD_ENTRY * thread_p, const LOG_LSA * undo_lsa);
926 extern void logtb_initialize_tdes (LOG_TDES * tdes, int tran_index);
927 extern void logtb_clear_tdes (THREAD_ENTRY * thread_p, LOG_TDES * tdes);
928 extern void logtb_finalize_tdes (THREAD_ENTRY * thread_p, LOG_TDES * tdes);
929 extern int logtb_get_new_tran_id (THREAD_ENTRY * thread_p, LOG_TDES * tdes);
930 extern int logtb_find_tran_index (THREAD_ENTRY * thread_p, TRANID trid);
931 #if defined (ENABLE_UNUSED_FUNCTION)
932 extern int logtb_find_tran_index_host_pid (THREAD_ENTRY * thread_p, const char *host_name, int process_id);
933 #endif
934 extern TRANID logtb_find_tranid (int tran_index);
935 extern TRANID logtb_find_current_tranid (THREAD_ENTRY * thread_p);
936 #if defined (ENABLE_UNUSED_FUNCTION)
937 extern int logtb_count_clients_with_type (THREAD_ENTRY * thread_p, int client_type);
938 #endif
939 extern int logtb_count_clients (THREAD_ENTRY * thread_p);
941 extern int logtb_find_client_type (int tran_index);
942 extern const char *logtb_find_client_name (int tran_index);
943 extern void logtb_set_user_name (int tran_index, const char *client_name);
944 extern void logtb_set_current_user_name (THREAD_ENTRY * thread_p, const char *client_name);
945 extern const char *logtb_find_client_hostname (int tran_index);
946 extern void logtb_set_current_user_active (THREAD_ENTRY * thread_p, bool is_user_active);
947 extern int logtb_find_client_name_host_pid (int tran_index, const char **client_prog_name,
948  const char **client_user_name, const char **client_host_name,
949  int *client_pid);
950 #if !defined(NDEBUG)
951 extern void logpb_debug_check_log_page (THREAD_ENTRY * thread_p, void *log_pgptr_ptr);
952 #endif
953 #if defined (SERVER_MODE)
954 extern int logtb_find_client_tran_name_host_pid (int &tran_index, const char **client_prog_name,
955  const char **client_user_name, const char **client_host_name,
956  int *client_pid);
957 #endif // SERVER_MODE
958 extern int logtb_get_client_ids (int tran_index, CLIENTIDS * client_info);
959 
960 extern int logtb_find_current_client_type (THREAD_ENTRY * thread_p);
961 extern const char *logtb_find_current_client_name (THREAD_ENTRY * thread_p);
962 extern const char *logtb_find_current_client_hostname (THREAD_ENTRY * thread_p);
964 extern TRAN_STATE logtb_find_state (int tran_index);
965 extern int logtb_find_wait_msecs (int tran_index);
966 
967 extern int logtb_find_interrupt (int tran_index, bool * interrupt);
968 extern TRAN_ISOLATION logtb_find_isolation (int tran_index);
970 extern bool logtb_set_tran_index_interrupt (THREAD_ENTRY * thread_p, int tran_index, bool set);
971 extern bool logtb_set_suppress_repl_on_transaction (THREAD_ENTRY * thread_p, int tran_index, int set);
972 extern bool logtb_is_interrupted (THREAD_ENTRY * thread_p, bool clear, bool * continue_checking);
973 extern bool logtb_is_interrupted_tran (THREAD_ENTRY * thread_p, bool clear, bool * continue_checking, int tran_index);
974 extern bool logtb_is_active (THREAD_ENTRY * thread_p, TRANID trid);
975 extern bool logtb_is_current_active (THREAD_ENTRY * thread_p);
976 extern bool logtb_istran_finished (THREAD_ENTRY * thread_p, TRANID trid);
977 extern void logtb_disable_update (THREAD_ENTRY * thread_p);
978 extern void logtb_enable_update (THREAD_ENTRY * thread_p);
979 extern void logtb_set_to_system_tran_index (THREAD_ENTRY * thread_p);
980 
981 #if defined (ENABLE_UNUSED_FUNCTION)
982 extern LOG_LSA *logtb_find_largest_lsa (THREAD_ENTRY * thread_p);
983 #endif
984 extern int logtb_set_num_loose_end_trans (THREAD_ENTRY * thread_p);
985 extern void log_find_unilaterally_largest_undo_lsa (THREAD_ENTRY * thread_p, LOG_LSA & max_undo_lsa);
986 extern void logtb_find_smallest_lsa (THREAD_ENTRY * thread_p, LOG_LSA * lsa);
987 extern void logtb_find_smallest_and_largest_active_pages (THREAD_ENTRY * thread_p, LOG_PAGEID * smallest,
988  LOG_PAGEID * largest);
989 extern int logtb_is_tran_modification_disabled (THREAD_ENTRY * thread_p);
990 extern bool logtb_has_deadlock_priority (int tran_index);
991 /* For Debugging */
992 extern void xlogtb_dump_trantable (THREAD_ENTRY * thread_p, FILE * out_fp);
993 
994 extern bool logpb_need_wal (const LOG_LSA * lsa);
995 extern char *logpb_backup_level_info_to_string (char *buf, int buf_size, const LOG_HDR_BKUP_LEVEL_INFO * info);
996 extern const char *tran_abort_reason_to_string (TRAN_ABORT_REASON val);
997 extern int logtb_descriptors_start_scan (THREAD_ENTRY * thread_p, int type, DB_VALUE ** arg_values, int arg_cnt,
998  void **ctx);
999 
1001 extern int logpb_find_oldest_available_arv_num (THREAD_ENTRY * thread_p);
1002 
1003 extern void logtb_get_new_subtransaction_mvccid (THREAD_ENTRY * thread_p, MVCC_INFO * curr_mvcc_info);
1004 
1005 extern MVCCID logtb_find_current_mvccid (THREAD_ENTRY * thread_p);
1006 extern MVCCID logtb_get_current_mvccid (THREAD_ENTRY * thread_p);
1007 extern int logtb_invalidate_snapshot_data (THREAD_ENTRY * thread_p);
1008 extern int xlogtb_get_mvcc_snapshot (THREAD_ENTRY * thread_p);
1009 
1010 extern bool logtb_is_current_mvccid (THREAD_ENTRY * thread_p, MVCCID mvccid);
1011 extern bool logtb_is_mvccid_committed (THREAD_ENTRY * thread_p, MVCCID mvccid);
1013 extern void logtb_complete_mvcc (THREAD_ENTRY * thread_p, LOG_TDES * tdes, bool committed);
1014 extern void logtb_complete_sub_mvcc (THREAD_ENTRY * thread_p, LOG_TDES * tdes);
1015 
1016 extern LOG_TRAN_CLASS_COS *logtb_tran_find_class_cos (THREAD_ENTRY * thread_p, const OID * class_oid, bool create);
1017 extern int logtb_tran_update_unique_stats (THREAD_ENTRY * thread_p, const BTID * btid, int n_keys, int n_oids,
1018  int n_nulls, bool write_to_log);
1019 
1020 // *INDENT-OFF*
1021 extern int logtb_tran_update_unique_stats (THREAD_ENTRY * thread_p, const BTID &btid, const btree_unique_stats &ustats,
1022  bool write_to_log);
1023 extern int logtb_tran_update_unique_stats (THREAD_ENTRY * thread_p, const multi_index_unique_stats &multi_stats,
1024  bool write_to_log);
1025 // *INDENT-ON*
1026 
1027 extern int logtb_tran_update_btid_unique_stats (THREAD_ENTRY * thread_p, const BTID * btid, int n_keys, int n_oids,
1028  int n_nulls);
1029 extern LOG_TRAN_BTID_UNIQUE_STATS *logtb_tran_find_btid_stats (THREAD_ENTRY * thread_p, const BTID * btid, bool create);
1030 extern int logtb_tran_prepare_count_optim_classes (THREAD_ENTRY * thread_p, const char **classes,
1031  LC_PREFETCH_FLAGS * flags, int n_classes);
1032 extern void logtb_tran_reset_count_optim_state (THREAD_ENTRY * thread_p);
1033 extern int logtb_find_log_records_count (int tran_index);
1034 
1037 extern int logtb_get_global_unique_stats (THREAD_ENTRY * thread_p, BTID * btid, int *num_oids, int *num_nulls,
1038  int *num_keys);
1039 extern int logtb_rv_update_global_unique_stats_by_abs (THREAD_ENTRY * thread_p, BTID * btid, int num_oids,
1040  int num_nulls, int num_keys);
1041 extern int logtb_update_global_unique_stats_by_delta (THREAD_ENTRY * thread_p, BTID * btid, int oid_delta,
1042  int null_delta, int key_delta, bool log);
1043 extern int logtb_delete_global_unique_stats (THREAD_ENTRY * thread_p, BTID * btid);
1046 
1047 extern int log_rv_undoredo_record_partial_changes (THREAD_ENTRY * thread_p, char *rcv_data, int rcv_data_length,
1048  RECDES * record, bool is_undo);
1049 extern int log_rv_redo_record_modify (THREAD_ENTRY * thread_p, LOG_RCV * rcv);
1050 extern int log_rv_undo_record_modify (THREAD_ENTRY * thread_p, LOG_RCV * rcv);
1051 extern char *log_rv_pack_redo_record_changes (char *ptr, int offset_to_data, int old_data_size, int new_data_size,
1052  char *new_data);
1053 extern char *log_rv_pack_undo_record_changes (char *ptr, int offset_to_data, int old_data_size, int new_data_size,
1054  char *old_data);
1055 
1056 extern void log_set_ha_promotion_time (THREAD_ENTRY * thread_p, INT64 ha_promotion_time);
1057 extern void log_set_db_restore_time (THREAD_ENTRY * thread_p, INT64 db_restore_time);
1058 
1059 extern int logpb_prior_lsa_append_all_list (THREAD_ENTRY * thread_p);
1060 
1061 extern bool logtb_check_class_for_rr_isolation_err (const OID * class_oid);
1062 
1063 extern void logpb_vacuum_reset_log_header_cache (THREAD_ENTRY * thread_p, LOG_HEADER * loghdr);
1064 
1066 extern int logpb_page_check_corruption (THREAD_ENTRY * thread_p, LOG_PAGE * log_pgptr, bool * is_page_corrupted);
1067 extern void logpb_dump_log_page_area (THREAD_ENTRY * thread_p, LOG_PAGE * log_pgptr, int offset, int length);
1068 extern void logpb_page_get_first_null_block_lsa (THREAD_ENTRY * thread_p, LOG_PAGE * log_pgptr,
1069  LOG_LSA * first_null_block_lsa);
1070 
1071 extern void logtb_slam_transaction (THREAD_ENTRY * thread_p, int tran_index);
1072 extern int xlogtb_kill_tran_index (THREAD_ENTRY * thread_p, int kill_tran_index, char *kill_user, char *kill_host,
1073  int kill_pid);
1074 extern int xlogtb_kill_or_interrupt_tran (THREAD_ENTRY * thread_p, int tran_id, bool is_dba_group_member,
1075  bool interrupt_only);
1076 extern THREAD_ENTRY *logtb_find_thread_by_tran_index (int tran_index);
1078 extern int logtb_get_current_tran_index (void);
1079 extern void logtb_set_current_tran_index (THREAD_ENTRY * thread_p, int tran_index);
1080 #if defined (SERVER_MODE)
1081 extern void logtb_wakeup_thread_with_tran_index (int tran_index, thread_resume_suspend_status resume_reason);
1082 #endif // SERVER_MODE
1083 
1084 extern bool logtb_set_check_interrupt (THREAD_ENTRY * thread_p, bool flag);
1085 extern bool logtb_get_check_interrupt (THREAD_ENTRY * thread_p);
1086 extern int logpb_set_page_checksum (THREAD_ENTRY * thread_p, LOG_PAGE * log_pgptr);
1087 
1088 extern LOG_TDES *logtb_get_system_tdes (THREAD_ENTRY * thread_p = NULL);
1089 
1091 // inline/template implementation
1093 
1094 inline LOG_TDES *
1095 LOG_FIND_TDES (int tran_index)
1096 {
1097  if (tran_index >= LOG_SYSTEM_TRAN_INDEX && tran_index < log_Gl.trantable.num_total_indices)
1098  {
1099  if (tran_index == LOG_SYSTEM_TRAN_INDEX)
1100  {
1101  return logtb_get_system_tdes ();
1102  }
1103  else
1104  {
1105  return log_Gl.trantable.all_tdes[tran_index];
1106  }
1107  }
1108  else
1109  {
1110  return NULL;
1111  }
1112 }
1113 
1114 inline LOG_TDES *
1116 {
1117  return LOG_FIND_TDES (LOG_FIND_THREAD_TRAN_INDEX (thread_p));
1118 }
1119 
1120 inline bool
1122 {
1123  return trid < NULL_TRANID;
1124 }
1125 
1126 #endif /* _LOG_IMPL_H_ */
int logpb_find_oldest_available_arv_num(THREAD_ENTRY *thread_p)
unsigned long log_buffer_full_count
Definition: log_impl.h:704
TRANID logtb_find_current_tranid(THREAD_ENTRY *thread_p)
int num_coord_loose_end_indices
Definition: log_impl.h:584
LOG_FLUSH_INFO flush_info
Definition: log_impl.h:675
unsigned long gc_flush_count
Definition: log_impl.h:756
bool logpb_need_wal(const LOG_LSA *lsa)
int tran_index
Definition: log_impl.h:465
int cur_repl_record
Definition: log_impl.h:506
int logpb_initialize_log_names(THREAD_ENTRY *thread_p, const char *db_fullname, const char *logpath, const char *prefix_logname)
int logtb_find_tran_index(THREAD_ENTRY *thread_p, TRANID trid)
bool logtb_is_current_mvccid(THREAD_ENTRY *thread_p, MVCCID mvccid)
int xlogtb_get_mvcc_snapshot(THREAD_ENTRY *thread_p)
LOG_TDES * tdesarea
Definition: log_impl.h:573
MVCC_SNAPSHOT * logtb_get_mvcc_snapshot(THREAD_ENTRY *thread_p)
void logtb_complete_mvcc(THREAD_ENTRY *thread_p, LOG_TDES *tdes, bool committed)
void logtb_disable_update(THREAD_ENTRY *thread_p)
MHT_TABLE * unique_stats_hash
Definition: log_impl.h:439
LOG_PAGE * logpb_fetch_start_append_page_new(THREAD_ENTRY *thread_p)
TRANTABLE trantable
Definition: log_impl.h:650
int num_total_indices
Definition: log_impl.h:581
void logtb_rv_assign_mvccid_for_undo_recovery(THREAD_ENTRY *thread_p, MVCCID mvccid)
int logpb_initialize_header(THREAD_ENTRY *thread_p, LOG_HEADER *loghdr, const char *prefix_logname, DKNPAGES npages, INT64 *db_creation)
LOG_UNIQUE_STATS global_stats
Definition: log_impl.h:377
const char * logtb_find_current_client_name(THREAD_ENTRY *thread_p)
pthread_mutex_t gc_mutex
Definition: log_impl.h:319
LOG_LSA chkpt_redo_lsa
Definition: log_impl.h:660
void logpb_fatal_error(THREAD_ENTRY *thread_p, bool logexit, const char *file_name, const int lineno, const char *fmt,...)
int TRANID
LOG_TRAN_UPDATE_STATS log_upd_stats
Definition: log_impl.h:534
LOG_TRAN_CLASS_COS_CHUNK * next_chunk
Definition: log_impl.h:418
LOG_PAGEID last_append_pageid
Definition: log_impl.h:699
LOG_LSA repl_update_lsa
Definition: log_impl.h:511
bool logtb_istran_finished(THREAD_ENTRY *thread_p, TRANID trid)
GLOBAL_UNIQUE_STATS * next
Definition: log_impl.h:618
bool logpb_find_volume_info_exist(void)
enum log_getnewtrid LOG_GETNEWTRID
Definition: log_impl.h:287
void logtb_release_tran_index(THREAD_ENTRY *thread_p, int tran_index)
PAGEID DKNPAGES
unsigned long total_flush_count_by_trans
Definition: log_impl.h:714
bool logtb_check_class_for_rr_isolation_err(const OID *class_oid)
LOG_2PC_COORDINATOR * coord
Definition: log_impl.h:489
int logpb_set_page_checksum(THREAD_ENTRY *thread_p, LOG_PAGE *log_pgptr)
LOG_TRAN_BTID_UNIQUE_STATS_CHUNK * stats_first_chunk
Definition: log_impl.h:436
int logtb_get_number_of_total_tran_indices(void)
LOG_PAGEID logpb_find_oldest_available_page_id(THREAD_ENTRY *thread_p)
LOG_LSA sysop_start_postpone_lsa
Definition: log_impl.h:448
int logpb_fetch_page(THREAD_ENTRY *thread_p, const LOG_LSA *req_lsa, LOG_CS_ACCESS_MODE access_mode, LOG_PAGE *log_pgptr)
LOG_LSA * logtb_find_current_tran_lsa(THREAD_ENTRY *thread_p)
#define DISK_VOLPURPOSE
int logpb_remove_all_in_log_path(THREAD_ENTRY *thread_p, const char *db_fullname, const char *logpath, const char *prefix_logname)
const int LOG_SYSTEM_TRAN_INDEX
void logpb_vacuum_reset_log_header_cache(THREAD_ENTRY *thread_p, LOG_HEADER *loghdr)
LOG_GLOBAL log_Gl
LOG_HEADER hdr
Definition: log_impl.h:653
TRAN_ABORT_REASON tran_abort_reason
Definition: log_impl.h:526
#define NULL_TRANID
bool logpb_is_smallest_lsa_in_archive(THREAD_ENTRY *thread_p)
int logtb_tran_update_all_global_unique_stats(THREAD_ENTRY *thread_p)
int xlogtb_kill_tran_index(THREAD_ENTRY *thread_p, int kill_tran_index, char *kill_user, char *kill_host, int kill_pid)
char * log_rv_pack_undo_record_changes(char *ptr, int offset_to_data, int old_data_size, int new_data_size, char *old_data)
int log_rv_redo_record_modify(THREAD_ENTRY *thread_p, LOG_RCV *rcv)
int disable_modifications
Definition: log_impl.h:524
LOG_LSA topop_lsa
Definition: log_impl.h:479
bool has_deadlock_priority
Definition: log_impl.h:536
char log_Name_bkupinfo[]
Definition: log_global.c:92
MVCCID logtb_find_current_mvccid(THREAD_ENTRY *thread_p)
int logpb_flush_page(THREAD_ENTRY *thread_p, LOG_PAGE *log_pgptr)
unsigned long total_group_commit_count
Definition: log_impl.h:737
int logpb_background_archiving(THREAD_ENTRY *thread_p)
pthread_mutex_t mutex
Definition: log_impl.h:619
int logtb_rv_update_global_unique_stats_by_abs(THREAD_ENTRY *thread_p, BTID *btid, int num_oids, int num_nulls, int num_keys)
LOG_TRAN_BTID_UNIQUE_STATS_CHUNK * stats_current_chunk
Definition: log_impl.h:437
void logpb_force_flush_pages(THREAD_ENTRY *thread_p)
int logtb_count_not_allowed_clients_in_maintenance_mode(THREAD_ENTRY *thread_p)
void xlogtb_dump_trantable(THREAD_ENTRY *thread_p, FILE *out_fp)
int num_repl_records
Definition: log_impl.h:505
bool logtb_is_system_worker_tranid(TRANID trid)
Definition: log_impl.h:1121
void logtb_set_to_system_tran_index(THREAD_ENTRY *thread_p)
int logtb_find_current_client_type(THREAD_ENTRY *thread_p)
PAGEID LOG_PHY_PAGEID
bool logtb_set_tran_index_interrupt(THREAD_ENTRY *thread_p, int tran_index, bool set)
void logtb_clear_tdes(THREAD_ENTRY *thread_p, LOG_TDES *tdes)
Definition: lock_free.h:63
enum log_wrote_eot_log LOG_WRITE_EOT_LOG
Definition: log_impl.h:291
LOG_PAGE * loghdr_pgptr
Definition: log_impl.h:672
int max_unique_btrees
Definition: log_impl.h:493
int num_assigned_indices
Definition: log_impl.h:582
enum log_setdirty LOG_SETDIRTY
Definition: log_impl.h:283
const char * logtb_find_current_client_hostname(THREAD_ENTRY *thread_p)
THREAD_ENTRY * logtb_find_thread_by_tran_index_except_me(int tran_index)
VOLID logpb_add_volume(const char *db_fullname, VOLID new_volid, const char *new_volfullname, DISK_VOLPURPOSE new_volpurpose)
unsigned long gc_commit_request_count
Definition: log_impl.h:750
LOG_LSA analysis_last_aborted_sysop_lsa
Definition: log_impl.h:455
INT16 VOLID
LOG_PAGEID logpb_get_page_id(LOG_PAGE *log_pgptr)
bool logtb_is_mvccid_committed(THREAD_ENTRY *thread_p, MVCCID mvccid)
unsigned long commit_count
Definition: log_impl.h:733
int logpb_write_page_to_disk(THREAD_ENTRY *thread_p, LOG_PAGE *log_pgptr, LOG_PAGEID logical_pageid)
GLOBAL_UNIQUE_STATS_TABLE unique_stats_table
Definition: log_impl.h:685
LOG_LSA tail_lsa
Definition: log_impl.h:473
log_postpone_cache m_log_postpone_cache
Definition: log_impl.h:543
LOG_ADDR_TDESAREA * next
Definition: log_impl.h:574
LOG_PAGE * logpb_fetch_from_archive(THREAD_ENTRY *thread_p, LOG_PAGEID pageid, LOG_PAGE *log_pgptr, int *ret_arv_num, LOG_ARV_HEADER *arv_hdr, bool is_fatal)
double use_append_page_sec
Definition: log_impl.h:701
LOG_PAGE * logpb_create_page(THREAD_ENTRY *thread_p, LOG_PAGEID pageid)
void logtb_define_trantable(THREAD_ENTRY *thread_p, int num_expected_tran_indices, int num_expected_locks)
int logtb_get_number_assigned_tran_indices(void)
void logtb_get_new_subtransaction_mvccid(THREAD_ENTRY *thread_p, MVCC_INFO *curr_mvcc_info)
LOG_GROUP_COMMIT_INFO group_commit_info
Definition: log_impl.h:678
char log_Archive_path[]
Definition: log_global.c:86
LOG_TDES * LOG_FIND_TDES(int tran_index)
Definition: log_impl.h:1095
int logpb_create_volume_info(const char *db_fullname)
log_cs_access_mode
Definition: log_impl.h:763
enum lc_prefetch_flags LC_PREFETCH_FLAGS
Definition: locator.h:339
SYNC_RMUTEX rmutex_topop
Definition: log_impl.h:485
bool block_global_oldest_active_until_commit
Definition: log_impl.h:538
void logtb_enable_update(THREAD_ENTRY *thread_p)
const int LOG_SYSTEM_WORKER_INCR_TRANID
Definition: log_impl.h:225
enum log_topops_type LOG_TOPOPS_TYPE
Definition: log_impl.h:344
LOG_PHY_PAGEID logpb_to_physical_pageid(LOG_PAGEID logical_pageid)
void logpb_page_get_first_null_block_lsa(THREAD_ENTRY *thread_p, LOG_PAGE *log_pgptr, LOG_LSA *first_null_block_lsa)
void logpb_remove_archive_logs(THREAD_ENTRY *thread_p, const char *info_reason)
bool logtb_get_check_interrupt(THREAD_ENTRY *thread_p)
int logpb_check_and_reset_temp_lsa(THREAD_ENTRY *thread_p, VOLID volid)
int logpb_get_archive_number(THREAD_ENTRY *thread_p, LOG_PAGEID pageid)
TRAN_ISOLATION logtb_find_isolation(int tran_index)
int logtb_find_log_records_count(int tran_index)
void xlogpb_dump_stat(FILE *outfp)
tx_transient_class_registry m_modified_classes
Definition: log_impl.h:502
void logpb_flush_header(THREAD_ENTRY *thread_p)
LOG_LSA lastparent_lsa
Definition: log_impl.h:331
thread_resume_suspend_status
LF_ENTRY_DESCRIPTOR unique_stats_descriptor
Definition: log_impl.h:632
int logpb_scan_volume_info(THREAD_ENTRY *thread_p, const char *db_fullname, VOLID ignore_volid, VOLID start_volid, int(*fun)(THREAD_ENTRY *thread_p, VOLID xvolid, const char *vlabel, void *args), void *args)
void logpb_set_dirty(THREAD_ENTRY *thread_p, LOG_PAGE *log_pgptr)
char * log_rv_pack_redo_record_changes(char *ptr, int offset_to_data, int old_data_size, int new_data_size, char *new_data)
log_wrote_eot_log
Definition: log_impl.h:289
INT64 query_start_time
Definition: log_impl.h:520
unsigned long last_commit_count_while_using_a_page
Definition: log_impl.h:740
void THREAD_ENTRY
double total_flush_hdr_sec_by_LFT
Definition: log_impl.h:727
mvcctable mvcc_table
Definition: log_impl.h:684
LOG_LSA tail_topresult_lsa
Definition: log_impl.h:480
void logpb_force_flush_header_and_pages(THREAD_ENTRY *thread_p)
LOG_TDES ** all_tdes
Definition: log_impl.h:595
const char * logtb_find_client_hostname(int tran_index)
int logtb_get_client_ids(int tran_index, CLIENTIDS *client_info)
COUNT_OPTIM_STATE count_state
Definition: log_impl.h:407
const char * log_Db_fullname
Definition: log_global.c:89
bool logtb_set_suppress_repl_on_transaction(THREAD_ENTRY *thread_p, int tran_index, int set)
int client_id
Definition: log_impl.h:481
unsigned long total_append_page_count
Definition: log_impl.h:697
struct log_logging_stat LOG_LOGGING_STAT
void logpb_flush_pages_direct(THREAD_ENTRY *thread_p)
int logtb_get_global_unique_stats(THREAD_ENTRY *thread_p, BTID *btid, int *num_oids, int *num_nulls, int *num_keys)
int gtrid
Definition: log_impl.h:482
unsigned long last_flush_count_by_trans
Definition: log_impl.h:712
char log_Name_volinfo[]
Definition: log_global.c:93
LOG_RECVPHASE rcv_phase
Definition: log_impl.h:662
LOG_APPEND_INFO append
Definition: log_impl.h:651
FILEIO_ZIP_LEVEL
Definition: file_io.h:113
std::int64_t VACUUM_LOG_BLOCKID
Definition: log_storage.hpp:91
void logpb_fatal_error_exit_immediately_wo_flush(THREAD_ENTRY *thread_p, const char *file_name, const int lineno, const char *fmt,...)
unsigned long flush_hdr_call_count
Definition: log_impl.h:723
TDE_ALGORITHM
Definition: tde.h:71
int logpb_copy_page_from_file(THREAD_ENTRY *thread_p, LOG_PAGEID pageid, LOG_PAGE *log_pgptr)
int logpb_fetch_start_append_page(THREAD_ENTRY *thread_p)
LOG_LOGGING_STAT log_Stat
LOG_LSA undo_nxlsa
Definition: log_impl.h:474
int logtb_count_clients(THREAD_ENTRY *thread_p)
int num_exec_queries
Definition: log_impl.h:529
log_flush
Definition: log_impl.h:277
void logtb_set_current_user_name(THREAD_ENTRY *thread_p, const char *client_name)
void * logtb_realloc_topops_stack(LOG_TDES *tdes, int num_elms)
log_topops_type
Definition: log_impl.h:337
unsigned long last_commit_count_in_flush_pages
Definition: log_impl.h:745
void logpb_initialize_logging_statistics(void)
log_getnewtrid
Definition: log_impl.h:285
int logpb_initialize_pool(THREAD_ENTRY *thread_p)
int logpb_recreate_volume_info(THREAD_ENTRY *thread_p)
TRAN_ISOLATION logtb_find_current_isolation(THREAD_ENTRY *thread_p)
int logtb_initialize_global_unique_stats_table(THREAD_ENTRY *thread_p)
bool logtb_is_interrupted_tran(THREAD_ENTRY *thread_p, bool clear, bool *continue_checking, int tran_index)
void logpb_dump_log_page_area(THREAD_ENTRY *thread_p, LOG_PAGE *log_pgptr, int offset, int length)
LOG_LSA final_restored_lsa
Definition: log_impl.h:668
void logpb_invalid_all_append_pages(THREAD_ENTRY *thread_p)
enum log_recvphase LOG_RECVPHASE
Definition: log_impl.h:610
int logtb_find_interrupt(int tran_index, bool *interrupt)
void logtb_set_user_name(int tran_index, const char *client_name)
void logpb_decache_archive_info(THREAD_ENTRY *thread_p)
LOG_TRAN_BTID_UNIQUE_STATS_CHUNK * next_chunk
Definition: log_impl.h:396
LOG_LSA savept_lsa
Definition: log_impl.h:478
multi_index_unique_stats m_multiupd_stats
Definition: log_impl.h:494
DB_TRAN_ISOLATION
Definition: dbtran_def.h:26
bool logtb_is_current_active(THREAD_ENTRY *thread_p)
GLOBAL_UNIQUE_STATS * stack
Definition: log_impl.h:617
int logtb_update_global_unique_stats_by_delta(THREAD_ENTRY *thread_p, BTID *btid, int oid_delta, int null_delta, int key_delta, bool log)
void logtb_slam_transaction(THREAD_ENTRY *thread_p, int tran_index)
MVCC_INFO mvccinfo
Definition: log_impl.h:463
void logtb_finalize_global_unique_stats_table(THREAD_ENTRY *thread_p)
volatile sig_atomic_t num_interrupts
Definition: log_impl.h:592
LOG_LSA last_log_lsa
Definition: log_impl.h:623
int num_prepared_loose_end_indices
Definition: log_impl.h:586
LOG_LSA posp_nxlsa
Definition: log_impl.h:476
LOG_LSA * log_startof_nxrec(THREAD_ENTRY *thread_p, LOG_LSA *lsa, bool canuse_forwaddr)
LOG_PAGE * logpb_create_header_page(THREAD_ENTRY *thread_p)
VACUUM_LOG_BLOCKID logpb_last_complete_blockid(void)
DKNPAGES chkpt_every_npages
Definition: log_impl.h:661
void logpb_debug_check_log_page(THREAD_ENTRY *thread_p, void *log_pgptr_ptr)
INT64 LOG_PAGEID
char log_Name_removed_archive[]
Definition: log_global.c:95
LOG_LSA rcv_phase_lsa
Definition: log_impl.h:663
#define NULL
Definition: freelistheap.h:34
LOG_ARCHIVES archive
Definition: log_impl.h:654
unsigned long last_group_commit_count
Definition: log_impl.h:735
UINT64 MVCCID
bool is_user_active
Definition: log_impl.h:539
THREAD_ENTRY * logtb_find_thread_by_tran_index(int tran_index)
int logpb_backup(THREAD_ENTRY *thread_p, int num_perm_vols, const char *allbackup_path, FILEIO_BACKUP_LEVEL backup_level, bool delete_unneeded_logarchives, const char *backup_verbose_file_path, int num_threads, FILEIO_ZIP_METHOD zip_method, FILEIO_ZIP_LEVEL zip_level, int skip_activelog, int sleep_msecs, bool separate_keys)
int logtb_invalidate_snapshot_data(THREAD_ENTRY *thread_p)
double last_flush_sec_by_trans
Definition: log_impl.h:716
int num_unique_btrees
Definition: log_impl.h:492
int num_log_records_written
Definition: log_impl.h:532
int logtb_get_current_tran_index(void)
void logpb_initialize_arv_page_info_table(void)
count_optim_state
Definition: log_impl.h:380
int logtb_define_trantable_log_latch(THREAD_ENTRY *thread_p, int num_expected_tran_indices)
int logtb_reflect_global_unique_stats_to_btree(THREAD_ENTRY *thread_p)
bool logpb_exist_log(THREAD_ENTRY *thread_p, const char *db_fullname, const char *logpath, const char *prefix_logname)
int logtb_assign_tran_index(THREAD_ENTRY *thread_p, TRANID trid, TRAN_STATE state, const BOOT_CLIENT_CREDENTIAL *client_credential, TRAN_STATE *current_state, int wait_msecs, TRAN_ISOLATION isolation)
int logtb_find_client_type(int tran_index)
int logpb_restore(THREAD_ENTRY *thread_p, const char *db_fullname, const char *logpath, const char *prefix_logname, bo_restart_arg *r_args)
LOG_LSA head_lsa
Definition: log_impl.h:472
int log_Tran_index
Definition: log_global.c:43
bool logtb_has_deadlock_priority(int tran_index)
int logtb_tran_update_unique_stats(THREAD_ENTRY *thread_p, const BTID *btid, int n_keys, int n_oids, int n_nulls, bool write_to_log)
int logpb_read_page_from_file(THREAD_ENTRY *thread_p, LOG_PAGEID pageid, LOG_CS_ACCESS_MODE access_mode, LOG_PAGE *log_pgptr)
LOG_UNIQUE_STATS tran_stats
Definition: log_impl.h:376
int log_rv_undo_record_modify(THREAD_ENTRY *thread_p, LOG_RCV *rcv)
LOG_LSA analysis_last_aborted_sysop_start_lsa
Definition: log_impl.h:456
LF_HASH_TABLE unique_stats_hash
Definition: log_impl.h:631
LOG_TRAN_CLASS_COS * logtb_tran_find_class_cos(THREAD_ENTRY *thread_p, const OID *class_oid, bool create)
bool logtb_set_check_interrupt(THREAD_ENTRY *thread_p, bool flag)
void logtb_initialize_tdes(LOG_TDES *tdes, int tran_index)
CLIENTIDS client
Definition: log_impl.h:484
LOG_PRIOR_LSA_INFO prior_info
Definition: log_impl.h:652
int logpb_remove_archive_logs_exceed_limit(THREAD_ENTRY *thread_p, int max_count)
void log_find_unilaterally_largest_undo_lsa(THREAD_ENTRY *thread_p, LOG_LSA &max_undo_lsa)
char log_Path[]
Definition: log_global.c:47
int logtb_tran_prepare_count_optim_classes(THREAD_ENTRY *thread_p, const char **classes, LC_PREFETCH_FLAGS *flags, int n_classes)
PGLENGTH logpb_find_header_parameters(THREAD_ENTRY *thread_p, const bool force_read_log_header, const char *db_fullname, const char *logpath, const char *prefix_logname, PGLENGTH *io_page_size, PGLENGTH *log_page_size, INT64 *db_creation, float *db_compatibility, int *db_charset)
int hint_free_index
Definition: log_impl.h:587
XASL_ID xasl_id
Definition: log_impl.h:522
pthread_cond_t gc_cond
Definition: log_impl.h:320
logwr_info * writer_info
Definition: log_impl.h:680
struct log_repl * repl_records
Definition: log_impl.h:509
TRANID logtb_find_tranid(int tran_index)
MVCCID logtb_get_current_mvccid(THREAD_ENTRY *thread_p)
LOG_PAGEID run_nxchkpt_atpageid
Definition: log_impl.h:655
bool logtb_is_interrupted(THREAD_ENTRY *thread_p, bool clear, bool *continue_checking)
int append_repl_recidx
Definition: log_impl.h:507
void logtb_set_current_tran_index(THREAD_ENTRY *thread_p, int tran_index)
void logpb_set_tde_algorithm(THREAD_ENTRY *thread_p, LOG_PAGE *log_pgptr, const TDE_ALGORITHM tde_algo)
LOG_TDES * LOG_FIND_CURRENT_TDES(THREAD_ENTRY *thread_p=NULL)
Definition: log_impl.h:1115
void logtb_free_tran_index(THREAD_ENTRY *thread_p, int tran_index)
void log_set_db_restore_time(THREAD_ENTRY *thread_p, INT64 db_restore_time)
Definition: log_manager.c:9351
TDE_ALGORITHM logpb_get_tde_algorithm(const LOG_PAGE *log_pgptr)
char log_Name_active[]
Definition: log_global.c:90
INT64 tran_start_time
Definition: log_impl.h:521
log_recvphase
Definition: log_impl.h:602
double total_flush_sec_by_trans
Definition: log_impl.h:718
int fl_mark_repl_recidx
Definition: log_impl.h:508
int logpb_page_check_corruption(THREAD_ENTRY *thread_p, LOG_PAGE *log_pgptr, bool *is_page_corrupted)
void logpb_flush_log_for_wal(THREAD_ENTRY *thread_p, const LOG_LSA *lsa_ptr)
int logtb_is_tran_modification_disabled(THREAD_ENTRY *thread_p)
int db_Disable_modifications
Definition: db_macro.c:90
int logpb_prior_lsa_append_all_list(THREAD_ENTRY *thread_p)
LOG_TOPOPS_STACK topops
Definition: log_impl.h:486
INT16 PGLENGTH
int wait_msecs
Definition: log_impl.h:471
unsigned long direct_flush_count
Definition: log_impl.h:720
enum log_flush LOG_FLUSH
Definition: log_impl.h:279
void * first_save_entry
Definition: log_impl.h:512
LOG_ADDR_TDESAREA * area
Definition: log_impl.h:594
int logpb_check_exist_any_volumes(THREAD_ENTRY *thread_p, const char *db_fullname, const char *logpath, const char *prefix_logname, char *first_vol, bool *is_exist)
LOG_PAGE * log_pbfetch(LOG_PAGEID pageid)
BACKGROUND_ARCHIVING_INFO bg_archive_info
Definition: log_impl.h:682
MHT_TABLE * classes_cos_hash
Definition: log_impl.h:432
bool isloose_end
Definition: log_impl.h:468
unsigned long total_sync_count
Definition: log_impl.h:730
const char * tran_abort_reason_to_string(TRAN_ABORT_REASON val)
LOG_LSA repl_insert_lsa
Definition: log_impl.h:510
int logpb_read_page_from_active_log(THREAD_ENTRY *thread_p, LOG_PAGEID pageid, int num_pages, bool decrypt_needed, LOG_PAGE *log_pgptr)
void logpb_fetch_header_with_buffer(THREAD_ENTRY *thread_p, LOG_HEADER *hdr, LOG_PAGE *log_pgptr)
int xlogtb_kill_or_interrupt_tran(THREAD_ENTRY *thread_p, int tran_id, bool is_dba_group_member, bool interrupt_only)
LOG_UNIQUE_STATS unique_stats
Definition: log_impl.h:622
TRANID trid
Definition: log_impl.h:466
void logpb_flush_pages(THREAD_ENTRY *thread_p, LOG_LSA *flush_lsa)
void logpb_copy_from_log(THREAD_ENTRY *thread_p, char *area, int length, LOG_LSA *log_lsa, LOG_PAGE *log_pgptr)
LF_FREELIST unique_stats_freelist
Definition: log_impl.h:633
LOG_RCV_TDES rcv
Definition: log_impl.h:541
bool logpb_is_pool_initialized(void)
double last_flush_hdr_sec_by_LFT
Definition: log_impl.h:725
int suppress_replication
Definition: log_impl.h:514
char log_Prefix[]
Definition: log_global.c:87
bool logpb_is_page_in_archive(LOG_PAGEID pageid)
INT64 query_timeout
Definition: log_impl.h:518
void logtb_tran_reset_count_optim_state(THREAD_ENTRY *thread_p)
int logpb_copy_database(THREAD_ENTRY *thread_p, VOLID num_perm_vols, const char *to_db_fullname, const char *to_logpath, const char *to_prefix_logname, const char *toext_path, const char *fileof_vols_and_copypaths)
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)
TRAN_STATE logtb_find_state(int tran_index)
log_setdirty
Definition: log_impl.h:281
unsigned long async_commit_request_count
Definition: log_impl.h:759
LOG_TRAN_CLASS_COS_CHUNK * cos_first_chunk
Definition: log_impl.h:430
void logpb_dump_checkpoint_trans(FILE *out_fp, int length, void *data)
const TRANID LOG_SYSTEM_WORKER_FIRST_TRANID
Definition: log_impl.h:224
volatile sig_atomic_t interrupt
Definition: log_impl.h:498
LOG_TDES * logtb_get_system_tdes(THREAD_ENTRY *thread_p=NULL)
void log_recovery(THREAD_ENTRY *thread_p, int ismedia_crash, time_t *stopat)
Definition: log_recovery.c:648
LOG_2PC_GTRINFO gtrinfo
Definition: log_impl.h:488
void logpb_fetch_header(THREAD_ENTRY *thread_p, LOG_HEADER *hdr)
bool logtb_am_i_dba_client(THREAD_ENTRY *thread_p)
int num_transient_classnames
Definition: log_impl.h:504
#define LOG_FIND_THREAD_TRAN_INDEX(thrd)
Definition: log_impl.h:176
LOG_TOPOPS_ADDRESSES * stack
Definition: log_impl.h:351
char log_Name_info[]
Definition: log_global.c:91
TRAN_ISOLATION isolation
Definition: log_impl.h:470
TRAN_STATE state
Definition: log_impl.h:469
enum log_cs_access_mode LOG_CS_ACCESS_MODE
Definition: log_impl.h:765
TRAN_STATE
Definition: log_comm.h:36
unsigned long total_commit_count_in_flush_pages
Definition: log_impl.h:747
unsigned long log_buffer_flush_count_by_replacement
Definition: log_impl.h:706
tran_abort_reason
Definition: log_impl.h:354
int logtb_get_new_tran_id(THREAD_ENTRY *thread_p, LOG_TDES *tdes)
LK_RES * waiting_for_res
Definition: log_impl.h:523
LOG_TDES * logtb_rv_find_allocate_tran_index(THREAD_ENTRY *thread_p, TRANID trid, const LOG_LSA *log_lsa)
unsigned long flushall_append_pages_call_count
Definition: log_impl.h:710
void logtb_undefine_trantable(THREAD_ENTRY *thread_p)
bool logtb_is_active(THREAD_ENTRY *thread_p, TRANID trid)
void logtb_find_smallest_lsa(THREAD_ENTRY *thread_p, LOG_LSA *lsa)
int logpb_delete(THREAD_ENTRY *thread_p, VOLID num_perm_vols, const char *db_fullname, const char *logpath, const char *prefix_logname, bool force_delete)
void logtb_free_tran_index_with_undo_lsa(THREAD_ENTRY *thread_p, const LOG_LSA *undo_lsa)
LOG_PAGEID logpb_checkpoint(THREAD_ENTRY *thread_p)
LOG_TRAN_CLASS_COS_CHUNK * cos_current_chunk
Definition: log_impl.h:431
void logpb_finalize_pool(THREAD_ENTRY *thread_p)
int logtb_set_num_loose_end_trans(THREAD_ENTRY *thread_p)
void logtb_find_smallest_and_largest_active_pages(THREAD_ENTRY *thread_p, LOG_PAGEID *smallest, LOG_PAGEID *largest)
int logtb_delete_global_unique_stats(THREAD_ENTRY *thread_p, BTID *btid)
void logpb_dump(THREAD_ENTRY *thread_p, FILE *out_fp)
LOG_PAGE ** toflush
Definition: log_impl.h:307
void logtb_set_current_user_active(THREAD_ENTRY *thread_p, bool is_user_active)
char * logpb_backup_level_info_to_string(char *buf, int buf_size, const LOG_HDR_BKUP_LEVEL_INFO *info)
LOG_LSA tran_start_postpone_lsa
Definition: log_impl.h:450
void logpb_create_log_info(const char *logname_info, const char *db_fullname)
LOG_TRAN_BTID_UNIQUE_STATS * logtb_tran_find_btid_stats(THREAD_ENTRY *thread_p, const BTID *btid, bool create)
int logpb_copy_page_from_log_buffer(THREAD_ENTRY *thread_p, LOG_PAGEID pageid, LOG_PAGE *log_pgptr)
double gc_total_wait_time
Definition: log_impl.h:753
void log_set_ha_promotion_time(THREAD_ENTRY *thread_p, INT64 ha_promotion_time)
Definition: log_manager.c:9334
FILEIO_BACKUP_LEVEL
Definition: file_io.h:96
FILEIO_ZIP_METHOD
Definition: file_io.h:104
void logtb_finalize_tdes(THREAD_ENTRY *thread_p, LOG_TDES *tdes)
int logtb_find_wait_msecs(int tran_index)
LOG_LSA atomic_sysop_start_lsa
Definition: log_impl.h:454
enum tran_abort_reason TRAN_ABORT_REASON
Definition: log_impl.h:360
int logtb_descriptors_start_scan(THREAD_ENTRY *thread_p, int type, DB_VALUE **arg_values, int arg_cnt, void **ctx)
int logtb_tran_update_btid_unique_stats(THREAD_ENTRY *thread_p, const BTID *btid, int n_keys, int n_oids, int n_nulls)
unsigned long total_commit_count_while_using_a_page
Definition: log_impl.h:742
enum count_optim_state COUNT_OPTIM_STATE
Definition: log_impl.h:386
void logtb_complete_sub_mvcc(THREAD_ENTRY *thread_p, LOG_TDES *tdes)
#define MAX_NUM_EXEC_QUERY_HISTORY
Definition: log_impl.h:275
int log_rv_undoredo_record_partial_changes(THREAD_ENTRY *thread_p, char *rcv_data, int rcv_data_length, RECDES *record, bool is_undo)
void clear(cub_regex_object *&regex, char *&pattern)
const char * logtb_find_client_name(int tran_index)
char log_Name_bg_archive[]
Definition: log_global.c:94
int logpb_rename_all_volumes_files(THREAD_ENTRY *thread_p, VOLID num_perm_vols, const char *to_db_fullname, const char *to_logpath, const char *to_prefix_logname, const char *toext_path, const char *fileof_vols_and_renamepaths, bool extern_rename, bool force_delete)
void logpb_invalidate_pool(THREAD_ENTRY *thread_p)