CUBRID Engine  latest
compactdb_sr.c
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 #ident "$Id$"
20 
21 #include "config.h"
22 
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <sys/types.h>
26 #include <sys/stat.h>
27 
28 #if defined(SOLARIS)
29 #include <netdb.h>
30 #endif /* SOLARIS */
31 
32 #include <assert.h>
33 
34 #include "btree.h" // for SINGLE_ROW_UPDATE
35 #include "thread_compat.hpp"
36 #include "heap_file.h"
37 #include "dbtype.h"
38 #include "boot_sr.h"
39 #include "locator_sr.h"
40 #include "set_object.h"
41 #include "xserver_interface.h"
42 #include "server_interface.h"
43 
44 static bool compact_started = false;
45 static int last_tran_index = -1;
46 
47 static bool is_class (OID * obj_oid, OID * class_oid);
48 static int process_set (THREAD_ENTRY * thread_p, DB_SET * set);
49 static int process_value (THREAD_ENTRY * thread_p, DB_VALUE * value);
50 static int process_object (THREAD_ENTRY * thread_p, HEAP_SCANCACHE * upd_scancache, HEAP_CACHE_ATTRINFO * attr_info,
51  OID * oid);
52 static int desc_disk_to_attr_info (THREAD_ENTRY * thread_p, OID * oid, RECDES * recdes,
53  HEAP_CACHE_ATTRINFO * attr_info);
54 static int process_class (THREAD_ENTRY * thread_p, OID * class_oid, HFID * hfid, int max_space_to_process,
55  int *instance_lock_timeout, int *space_to_process, OID * last_processed_oid,
56  int *total_objects, int *failed_objects, int *modified_objects, int *big_objects);
57 
58 /*
59  * is_class () - check if an object is a class
60  *
61  * return : bool
62  * obj_oid - the oid of the object
63  * class_oid - the class oid of obj_oid
64  *
65  */
66 static bool
67 is_class (OID * obj_oid, OID * class_oid)
68 {
69  if (OID_EQ (class_oid, oid_Root_class_oid))
70  {
71  return true;
72  }
73  return false;
74 }
75 
76 /*
77  * process_value () - process a value
78  *
79  * return : error status
80  * value(in,out) - the processed value
81  *
82  */
83 static int
84 process_value (THREAD_ENTRY * thread_p, DB_VALUE * value)
85 {
86  int return_value = 0;
87  SCAN_CODE scan_code;
88 
89  switch (DB_VALUE_TYPE (value))
90  {
91  case DB_TYPE_OID:
92  {
93  OID *ref_oid;
94  OID ref_class_oid;
95  HEAP_SCANCACHE scan_cache;
96 
97  ref_oid = db_get_oid (value);
98 
99  if (OID_ISNULL (ref_oid))
100  {
101  break;
102  }
103 
104  heap_scancache_quick_start (&scan_cache);
105  scan_cache.mvcc_snapshot = logtb_get_mvcc_snapshot (thread_p);
106  scan_code = heap_get_visible_version (thread_p, ref_oid, &ref_class_oid, NULL, &scan_cache, PEEK, NULL_CHN);
107  heap_scancache_end (thread_p, &scan_cache);
108 
109  if (scan_code == S_ERROR)
110  {
111  ASSERT_ERROR_AND_SET (return_value);
112  break;
113  }
114  else if (scan_code != S_SUCCESS)
115  {
116  OID_SET_NULL (ref_oid);
117  return_value = 1;
118  break;
119  }
120 
121  if (is_class (ref_oid, &ref_class_oid))
122  {
123  break;
124  }
125 
126 #if defined(CUBRID_DEBUG)
128  ref_oid->pageid, ref_oid->slotid, ref_class_oid.volid, ref_class_oid.pageid, ref_class_oid.slotid);
129 #endif
130 
131  break;
132  }
133 
134  case DB_TYPE_POINTER:
135  case DB_TYPE_SET:
136  case DB_TYPE_MULTISET:
137  case DB_TYPE_SEQUENCE:
138  {
139  return_value = process_set (thread_p, db_get_set (value));
140  break;
141  }
142 
143  default:
144  break;
145  }
146 
147  return return_value;
148 }
149 
150 /*
151  * process_set - process one set
152  * return: whether the object should be updated.
153  * set(in): the set to process
154  */
155 static int
156 process_set (THREAD_ENTRY * thread_p, DB_SET * set)
157 {
158  SET_ITERATOR *it;
159  DB_VALUE *element_value;
160  int return_value = 0;
161  int error_code;
162 
163  it = set_iterate (set);
164  while ((element_value = set_iterator_value (it)) != NULL)
165  {
166  error_code = process_value (thread_p, element_value);
167  if (error_code > 0)
168  {
169  return_value += error_code;
170  }
171  else if (error_code != NO_ERROR)
172  {
173  set_iterator_free (it);
174  return error_code;
175  }
176  set_iterator_next (it);
177  }
178  set_iterator_free (it);
179 
180  return return_value;
181 }
182 
183 /*
184  * process_object - process an object
185  * return: 1 - object has changed
186  * 0 - object has not changed
187  * -1 - object failed
188  * upd_scancache(in):
189  * attr_info(in):
190  * oid(in): the oid of the object to process
191  */
192 static int
193 process_object (THREAD_ENTRY * thread_p, HEAP_SCANCACHE * upd_scancache, HEAP_CACHE_ATTRINFO * attr_info, OID * oid)
194 {
195  int i, result = 0;
196  HEAP_ATTRVALUE *value = NULL;
197  int force_count = 0, updated_n_attrs_id = 0;
198  int *atts_id = NULL;
199  int error_code;
200  SCAN_CODE scan_code;
201  RECDES copy_recdes;
202 
203  if (upd_scancache == NULL || attr_info == NULL || oid == NULL)
204  {
205  return -1;
206  }
207 
208  copy_recdes.data = NULL;
209 
210  /* get object with X_LOCK */
211  scan_code = locator_lock_and_get_object (thread_p, oid, &upd_scancache->node.class_oid, &copy_recdes, upd_scancache,
213  if (scan_code != S_SUCCESS)
214  {
216  {
217  assert (scan_code == S_DOESNT_EXIST || scan_code == S_SNAPSHOT_NOT_SATISFIED);
218  er_clear ();
219  }
220 
221  if (scan_code == S_DOESNT_EXIST || scan_code == S_SNAPSHOT_NOT_SATISFIED)
222  {
223  return 0;
224  }
225 
226  return -1;
227  }
228 
229  atts_id = (int *) db_private_alloc (thread_p, attr_info->num_values * sizeof (int));
230  if (atts_id == NULL)
231  {
232  return -1;
233  }
234 
235  for (i = 0, value = attr_info->values; i < attr_info->num_values; i++, value++)
236  {
237  error_code = process_value (thread_p, &value->dbvalue);
238  if (error_code > 0)
239  {
240  value->state = HEAP_WRITTEN_ATTRVALUE;
241  atts_id[updated_n_attrs_id] = value->attrid;
242  updated_n_attrs_id++;
243  }
244  else if (error_code != NO_ERROR)
245  {
246  db_private_free (thread_p, atts_id);
247  return error_code;
248  }
249  }
250 
251  if ((updated_n_attrs_id > 0)
252  || (attr_info->read_classrepr != NULL && attr_info->last_classrepr != NULL
253  && attr_info->read_classrepr->id != attr_info->last_classrepr->id))
254  {
255  /* oid already locked at locator_lock_and_get_object */
256  error_code =
257  locator_attribute_info_force (thread_p, &upd_scancache->node.hfid, oid, attr_info, atts_id, updated_n_attrs_id,
258  LC_FLUSH_UPDATE, SINGLE_ROW_UPDATE, upd_scancache, &force_count, false,
260  UPDATE_INPLACE_NONE, &copy_recdes, false);
261  if (error_code != NO_ERROR)
262  {
263  if (error_code == ER_MVCC_NOT_SATISFIED_REEVALUATION)
264  {
265  result = 0;
266  }
267  else
268  {
269  result = -1;
270  }
271  }
272  else
273  {
274  result = 1;
275  }
276  }
277 
278  if (atts_id)
279  {
280  db_private_free (thread_p, atts_id);
281  atts_id = NULL;
282  }
283 
284  return result;
285 }
286 
287 /*
288  * desc_disk_to_attr_info - convert RECDES for specified oid to
289  * HEAP_CACHE_ATTRINFO structure
290  * return: error status
291  * oid(in): the oid of the object
292  * recdes(in): RECDES structure to convert
293  * attr_info(out): the HEAP_CACHE_ATTRINFO structure
294  */
295 static int
297 {
298  if (oid == NULL || recdes == NULL || attr_info == NULL)
299  {
300  return ER_FAILED;
301  }
302 
303  if (heap_attrinfo_clear_dbvalues (attr_info) != NO_ERROR)
304  {
305  return ER_FAILED;
306  }
307 
308  if (heap_attrinfo_read_dbvalues (thread_p, oid, recdes, NULL, attr_info) != NO_ERROR)
309  {
310  return ER_FAILED;
311  }
312 
313  return NO_ERROR;
314 }
315 
316 /*
317  * process_class - process a class
318  * HEAP_CACHE_ATTRINFO structure
319  * return: error status
320  * class_oid(in): the class OID
321  * hfid(in): the class HFID
322  * max_space_to_process(in): maximum space to process
323  * instance_lock_timeout(in): the lock timeout for instances
324  * space_to_process(in, out): space to process
325  * last_processed_oid(in, out): last processed oid
326  * total_objects(in, out): count the processed class objects
327  * failed_objects(in, out): count the failed class objects
328  * modified_objects(in, out): count the modified class objects
329  * big_objects(in, out): count the big class objects
330  */
331 static int
332 process_class (THREAD_ENTRY * thread_p, OID * class_oid, HFID * hfid, int max_space_to_process,
333  int *instance_lock_timeout, int *space_to_process, OID * last_processed_oid, int *total_objects,
334  int *failed_objects, int *modified_objects, int *big_objects)
335 {
336  int nobjects, nfetched, i, j;
337  OID last_oid, prev_oid;
338  LOCK null_lock = NULL_LOCK;
339  LOCK oid_lock = X_LOCK;
340  LC_COPYAREA *fetch_area = NULL; /* Area where objects are received */
341  struct lc_copyarea_manyobjs *mobjs; /* Describe multiple objects in area */
342  struct lc_copyarea_oneobj *obj; /* Describe on object in area */
343  RECDES recdes;
344  HEAP_CACHE_ATTRINFO attr_info;
345  HEAP_SCANCACHE upd_scancache;
346  int ret = NO_ERROR, object_processed;
348 
349  int nfailed_instances = 0;
350 
351  if (class_oid == NULL || hfid == NULL || space_to_process == NULL || *space_to_process <= 0
352  || *space_to_process > max_space_to_process || last_processed_oid == NULL || total_objects == NULL
353  || failed_objects == NULL || modified_objects == NULL || big_objects == NULL || *total_objects < 0
354  || *failed_objects < 0)
355  {
356  return ER_FAILED;
357  }
358 
359  if (!OID_IS_ROOTOID (class_oid))
360  {
361  mvcc_snapshot = logtb_get_mvcc_snapshot (thread_p);
362  if (mvcc_snapshot == NULL)
363  {
364  return ER_FAILED;
365  }
366  }
367 
368  nobjects = 0;
369  nfetched = -1;
370 
371  ret = heap_scancache_start_modify (thread_p, &upd_scancache, hfid, class_oid, SINGLE_ROW_UPDATE, NULL);
372  if (ret != NO_ERROR)
373  {
374  return ER_FAILED;
375  }
376 
377  ret = heap_attrinfo_start (thread_p, class_oid, -1, NULL, &attr_info);
378  if (ret != NO_ERROR)
379  {
380  heap_scancache_end_modify (thread_p, &upd_scancache);
381  return ER_FAILED;
382  }
383 
384  COPY_OID (&last_oid, last_processed_oid);
385  COPY_OID (&prev_oid, last_processed_oid);
386 
387  while (nobjects != nfetched)
388  {
389  ret =
390  xlocator_lock_and_fetch_all (thread_p, hfid, &oid_lock, instance_lock_timeout, class_oid, &null_lock, &nobjects,
391  &nfetched, &nfailed_instances, &last_oid, &fetch_area, mvcc_snapshot);
392 
393  if (ret == NO_ERROR)
394  {
395  (*total_objects) += nfailed_instances;
396  (*failed_objects) += nfailed_instances;
397 
398  if (fetch_area != NULL)
399  {
400  mobjs = LC_MANYOBJS_PTR_IN_COPYAREA (fetch_area);
401  obj = LC_START_ONEOBJ_PTR_IN_COPYAREA (mobjs);
402 
403  for (i = 0; i < mobjs->num_objs; i++)
404  {
405  if (obj->length > *space_to_process)
406  {
407  if (*space_to_process == max_space_to_process)
408  {
409  (*total_objects)++;
410  (*big_objects)++;
411  lock_unlock_object (thread_p, &obj->oid, class_oid, oid_lock, true);
412  }
413  else
414  {
415  *space_to_process = 0;
416  COPY_OID (last_processed_oid, &prev_oid);
417 
418  for (j = i; j < mobjs->num_objs; j++)
419  {
420  lock_unlock_object (thread_p, &obj->oid, class_oid, oid_lock, true);
421  obj = LC_NEXT_ONEOBJ_PTR_IN_COPYAREA (obj);
422  }
423 
424  if (fetch_area)
425  {
426  locator_free_copy_area (fetch_area);
427  }
428  goto end;
429  }
430  }
431  else
432  {
433  *space_to_process -= obj->length;
434 
435  (*total_objects)++;
436  LC_RECDES_TO_GET_ONEOBJ (fetch_area, obj, &recdes);
437 
438  if (desc_disk_to_attr_info (thread_p, &obj->oid, &recdes, &attr_info) == NO_ERROR)
439  {
440  object_processed = process_object (thread_p, &upd_scancache, &attr_info, &obj->oid);
441 
442  if (object_processed != 1)
443  {
444  lock_unlock_object (thread_p, &obj->oid, class_oid, oid_lock, true);
445 
446  if (object_processed == -1)
447  {
448  (*failed_objects)++;
449  }
450  }
451  else
452  {
453  (*modified_objects)++;
454  }
455  }
456  else
457  {
458  (*failed_objects)++;
459  }
460  }
461 
462  COPY_OID (&prev_oid, &obj->oid);
463  obj = LC_NEXT_ONEOBJ_PTR_IN_COPYAREA (obj);
464  }
465 
466  if (fetch_area)
467  {
468  locator_free_copy_area (fetch_area);
469  }
470  }
471  else
472  {
473  /* No more objects */
474  break;
475  }
476  }
477  else
478  {
479  ret = ER_FAILED;
480  break;
481  }
482  }
483 
484  COPY_OID (last_processed_oid, &last_oid);
485 
486 end:
487 
488  heap_attrinfo_end (thread_p, &attr_info);
489  heap_scancache_end_modify (thread_p, &upd_scancache);
490 
491  return ret;
492 }
493 
494 
495  /*
496  * boot_compact_db - compact specified classes
497  * HEAP_CACHE_ATTRINFO structure
498  * return: error status
499  * class_oids(in): the classes list
500  * n_classes(in): the class_oids length
501  * hfids(in): the hfid list
502  * space_to_process(in): the space to process
503  * instance_lock_timeout(in): the lock timeout for instances
504  * class_lock_timeout(in): the lock timeout for instances
505  * delete_old_repr(in): whether to delete the old class representation
506  * last_processed_class_oid(in,out): last processed class oid
507  * last_processed_oid(in,out): last processed oid
508  * total_objects(out): count processed objects for each class
509  * failed_objects(out): count failed objects for each class
510  * modified_objects(out): count modified objects for each class
511  * big_objects(out): count big objects for each class
512  * initial_last_repr_id(in, out): the list of initial last class
513  * representation
514  */
515 int
516 boot_compact_db (THREAD_ENTRY * thread_p, OID * class_oids, int n_classes, int space_to_process,
517  int instance_lock_timeout, int class_lock_timeout, bool delete_old_repr,
518  OID * last_processed_class_oid, OID * last_processed_oid, int *total_objects, int *failed_objects,
519  int *modified_objects, int *big_objects, int *initial_last_repr_id)
520 {
521  int result = NO_ERROR;
522  int i, j, start_index = -1;
523  int max_space_to_process;
524  int lock_ret;
525  HFID hfid;
526 
527  if (boot_can_compact (thread_p) == false)
528  {
530  }
531 
532  if (class_oids == NULL || n_classes <= 0 || space_to_process <= 0 || last_processed_class_oid == NULL
533  || last_processed_oid == NULL || total_objects == NULL || failed_objects == NULL || modified_objects == NULL
534  || big_objects == NULL || initial_last_repr_id == NULL)
535  {
537  }
538 
539  for (start_index = 0; start_index < n_classes; start_index++)
540  {
541  if (OID_EQ (class_oids + start_index, last_processed_class_oid))
542  {
543  break;
544  }
545  }
546 
547  if (start_index == n_classes)
548  {
550  }
551 
552  for (i = 0; i < n_classes; i++)
553  {
554  total_objects[i] = 0;
555  failed_objects[i] = 0;
556  modified_objects[i] = 0;
557  big_objects[i] = 0;
558  }
559 
560  max_space_to_process = space_to_process;
561  for (i = start_index; i < n_classes; i++)
562  {
563  lock_ret =
565  class_lock_timeout);
566 
567  if (lock_ret != LK_GRANTED)
568  {
569  total_objects[i] = COMPACTDB_LOCKED_CLASS;
570  OID_SET_NULL (last_processed_oid);
571  continue;
572  }
573 
574  if (heap_get_class_info (thread_p, class_oids + i, &hfid, NULL, NULL) != NO_ERROR)
575  {
576  lock_unlock_object (thread_p, class_oids + i, oid_Root_class_oid, IX_LOCK, true);
577  OID_SET_NULL (last_processed_oid);
578  total_objects[i] = COMPACTDB_INVALID_CLASS;
579  continue;
580  }
581 
582  if (HFID_IS_NULL (&hfid))
583  {
584  lock_unlock_object (thread_p, class_oids + i, oid_Root_class_oid, IX_LOCK, true);
585  OID_SET_NULL (last_processed_oid);
586  total_objects[i] = COMPACTDB_INVALID_CLASS;
587  continue;
588  }
589 
590  if (OID_ISNULL (last_processed_oid))
591  {
592  initial_last_repr_id[i] = heap_get_class_repr_id (thread_p, class_oids + i);
593  if (initial_last_repr_id[i] <= 0)
594  {
595  lock_unlock_object (thread_p, class_oids + i, oid_Root_class_oid, IX_LOCK, true);
596  total_objects[i] = COMPACTDB_INVALID_CLASS;
597  continue;
598  }
599  }
600 
601  if (process_class
602  (thread_p, class_oids + i, &hfid, max_space_to_process, &instance_lock_timeout, &space_to_process,
603  last_processed_oid, total_objects + i, failed_objects + i, modified_objects + i,
604  big_objects + i) != NO_ERROR)
605  {
606  OID_SET_NULL (last_processed_oid);
607  for (j = start_index; j <= i; j++)
608  {
609  total_objects[j] = COMPACTDB_UNPROCESSED_CLASS;
610  failed_objects[j] = 0;
611  modified_objects[j] = 0;
612  big_objects[j] = 0;
613  }
614 
615  result = ER_FAILED;
616  break;
617  }
618 
619  if (delete_old_repr && OID_ISNULL (last_processed_oid) && failed_objects[i] == 0
620  && heap_get_class_repr_id (thread_p, class_oids + i) == initial_last_repr_id[i])
621  {
622  lock_ret =
623  lock_object_wait_msecs (thread_p, class_oids + i, oid_Root_class_oid, X_LOCK, LK_UNCOND_LOCK,
624  class_lock_timeout);
625  if (lock_ret == LK_GRANTED)
626  {
627  if (catalog_drop_old_representations (thread_p, class_oids + i) != NO_ERROR)
628  {
629  for (j = start_index; j <= i; j++)
630  {
631  total_objects[j] = COMPACTDB_UNPROCESSED_CLASS;
632  failed_objects[j] = 0;
633  modified_objects[j] = 0;
634  big_objects[j] = 0;
635  }
636 
637  result = ER_FAILED;
638  }
639  else
640  {
641  initial_last_repr_id[i] = COMPACTDB_REPR_DELETED;
642  }
643 
644  break;
645  }
646  }
647 
648  if (space_to_process == 0)
649  {
650  break;
651  }
652  }
653 
654  if (OID_ISNULL (last_processed_oid))
655  {
656  if (i < n_classes - 1)
657  {
658  COPY_OID (last_processed_class_oid, class_oids + i + 1);
659  }
660  else
661  {
662  OID_SET_NULL (last_processed_class_oid);
663  }
664  }
665  else
666  {
667  COPY_OID (last_processed_class_oid, class_oids + i);
668  }
669 
670  return result;
671 }
672 
673 /*
674  * heap_compact_pages () - compact all pages from hfid of specified class OID
675  * return: error_code
676  * class_oid(out): the class oid
677  */
678 int
680 {
681  if (boot_can_compact (thread_p) == false)
682  {
684  }
685 
686  return heap_compact_pages (thread_p, class_oid);
687 }
688 
689 /*
690  * boot_compact_start () - start database compaction
691  * return: error_code
692  */
693 int
695 {
696  int current_tran_index = -1;
697 
699  {
700  return ER_FAILED;
701  }
702 
703  current_tran_index = LOG_FIND_THREAD_TRAN_INDEX (thread_p);
704  if (current_tran_index != last_tran_index && compact_started == true)
705  {
708  }
709 
710  last_tran_index = current_tran_index;
711  compact_started = true;
712 
714 
715  return NO_ERROR;
716 }
717 
718 
719 /*
720  * boot_compact_stop () - stop database compaction
721  * return: error_code
722  */
723 int
725 {
726  int current_tran_index = -1;
727 
729  {
730  return ER_FAILED;
731  }
732 
733  current_tran_index = LOG_FIND_THREAD_TRAN_INDEX (thread_p);
734  if (current_tran_index != last_tran_index && compact_started == true)
735  {
737  return ER_FAILED;
738  }
739 
740  last_tran_index = -1;
741  compact_started = false;
742 
744 
745  return NO_ERROR;
746 }
747 
748 /*
749  * boot_can_compact () - check if the current transaction can compact the database
750  * return: bool
751  */
752 bool
754 {
755  int current_tran_index = -1;
757  {
758  return false;
759  }
760 
761  current_tran_index = LOG_FIND_THREAD_TRAN_INDEX (thread_p);
762  if (current_tran_index != last_tran_index && compact_started == true)
763  {
765  return false;
766  }
767 
769 
770  return true;
771 }
static int process_value(THREAD_ENTRY *thread_p, DB_VALUE *value)
Definition: compactdb_sr.c:84
void heap_scancache_end_modify(THREAD_ENTRY *thread_p, HEAP_SCANCACHE *scan_cache)
Definition: heap_file.c:7230
OID * oid_Root_class_oid
Definition: oid.c:73
#define NO_ERROR
Definition: error_code.h:46
int boot_heap_compact_pages(THREAD_ENTRY *thread_p, OID *class_oid)
Definition: compactdb_sr.c:679
#define COMPACTDB_INVALID_CLASS
DB_COLLECTION * db_get_set(const DB_VALUE *value)
MVCC_SNAPSHOT * logtb_get_mvcc_snapshot(THREAD_ENTRY *thread_p)
SCAN_CODE
int boot_compact_stop(THREAD_ENTRY *thread_p)
Definition: compactdb_sr.c:724
int heap_scancache_start_modify(THREAD_ENTRY *thread_p, HEAP_SCANCACHE *scan_cache, const HFID *hfid, const OID *class_oid, int op_type, MVCC_SNAPSHOT *mvcc_snapshot)
Definition: heap_file.c:6867
SCAN_CODE heap_get_visible_version(THREAD_ENTRY *thread_p, const OID *oid, OID *class_oid, RECDES *recdes, HEAP_SCANCACHE *scan_cache, int ispeeking, int old_chn)
Definition: heap_file.c:24272
void locator_free_copy_area(LC_COPYAREA *copyarea)
Definition: locator.c:534
#define ER_FAILED
Definition: error_code.h:47
#define LC_START_ONEOBJ_PTR_IN_COPYAREA(manyobjs_ptr)
Definition: locator.h:44
void set_iterator_free(SET_ITERATOR *it)
Definition: set_object.c:4188
#define csect_enter(a, b, c)
Definition: cnv.c:138
REPR_ID heap_get_class_repr_id(THREAD_ENTRY *thread_p, OID *class_oid)
Definition: heap_file.c:16476
#define ASSERT_ERROR_AND_SET(error_code)
#define OID_SET_NULL(oidp)
Definition: oid.h:85
int set_iterator_next(SET_ITERATOR *it)
Definition: set_object.c:4236
char * data
int er_errid(void)
#define COMPACTDB_LOCKED_CLASS
int heap_scancache_end(THREAD_ENTRY *thread_p, HEAP_SCANCACHE *scan_cache)
Definition: heap_file.c:7195
static int desc_disk_to_attr_info(THREAD_ENTRY *thread_p, OID *oid, RECDES *recdes, HEAP_CACHE_ATTRINFO *attr_info)
Definition: compactdb_sr.c:296
#define COPY_OID(dest_oid_ptr, src_oid_ptr)
Definition: oid.h:63
void THREAD_ENTRY
HEAP_SCANCACHE_NODE node
Definition: heap_file.h:144
static bool compact_started
Definition: compactdb_sr.c:44
LOCK
SCAN_CODE locator_lock_and_get_object(THREAD_ENTRY *thread_p, const OID *oid, OID *class_oid, RECDES *recdes, HEAP_SCANCACHE *scan_cache, LOCK lock, int ispeeking, int old_chn, NON_EXISTENT_HANDLING non_ex_handling_type)
Definition: locator_sr.c:13286
#define LC_RECDES_TO_GET_ONEOBJ(copy_area_ptr, oneobj_ptr, recdes_ptr)
Definition: locator.h:54
int heap_attrinfo_start(THREAD_ENTRY *thread_p, const OID *class_oid, int requested_num_attrs, const ATTR_ID *attrids, HEAP_CACHE_ATTRINFO *attr_info)
Definition: heap_file.c:9427
Definition: db_set.h:35
#define ER_QPROC_INVALID_PARAMETER
Definition: error_code.h:963
#define assert(x)
bool boot_can_compact(THREAD_ENTRY *thread_p)
Definition: compactdb_sr.c:753
#define OID_IS_ROOTOID(oidp)
Definition: oid.h:82
int xlocator_lock_and_fetch_all(THREAD_ENTRY *thread_p, const HFID *hfid, LOCK *instance_lock, int *instance_lock_timeout, OID *class_oid, LOCK *class_lock, int *nobjects, int *nfetched, int *nfailed_instance_locks, OID *last_oid, LC_COPYAREA **fetch_area, MVCC_SNAPSHOT *mvcc_snapshot)
Definition: locator_sr.c:11790
#define SINGLE_ROW_UPDATE
Definition: btree.h:54
void lock_unlock_object(THREAD_ENTRY *thread_p, const OID *oid, const OID *class_oid, LOCK lock, bool force)
static int process_set(THREAD_ENTRY *thread_p, DB_SET *set)
Definition: compactdb_sr.c:156
#define OID_EQ(oidp1, oidp2)
Definition: oid.h:92
int heap_attrinfo_read_dbvalues(THREAD_ENTRY *thread_p, const OID *inst_oid, RECDES *recdes, HEAP_SCANCACHE *scan_cache, HEAP_CACHE_ATTRINFO *attr_info)
Definition: heap_file.c:10337
int locator_attribute_info_force(THREAD_ENTRY *thread_p, const HFID *hfid, OID *oid, HEAP_CACHE_ATTRINFO *attr_info, ATTR_ID *att_id, int n_att_id, LC_COPYAREA_OPERATION operation, int op_type, HEAP_SCANCACHE *scan_cache, int *force_count, bool not_check_fk, REPL_INFO_TYPE repl_info, int pruning_type, PRUNING_CONTEXT *pcontext, FUNC_PRED_UNPACK_INFO *func_preds, MVCC_REEV_DATA *mvcc_reev_data, UPDATE_INPLACE_STYLE force_update_inplace, RECDES *rec_descriptor, bool need_locking)
Definition: locator_sr.c:7311
#define NULL
Definition: freelistheap.h:34
static int total_objects
Definition: compactdb.c:56
int heap_attrinfo_clear_dbvalues(HEAP_CACHE_ATTRINFO *attr_info)
Definition: heap_file.c:10022
#define LC_NEXT_ONEOBJ_PTR_IN_COPYAREA(oneobj_ptr)
Definition: locator.h:48
int catalog_drop_old_representations(THREAD_ENTRY *thread_p, OID *class_id_p)
static int failed_objects
Definition: compactdb.c:57
#define csect_exit(a, b)
Definition: cnv.c:139
#define db_private_free(thrd, ptr)
Definition: memory_alloc.h:229
#define COMPACTDB_UNPROCESSED_CLASS
static int process_class(THREAD_ENTRY *thread_p, OID *class_oid, HFID *hfid, int max_space_to_process, int *instance_lock_timeout, int *space_to_process, OID *last_processed_oid, int *total_objects, int *failed_objects, int *modified_objects, int *big_objects)
Definition: compactdb_sr.c:332
#define db_private_alloc(thrd, size)
Definition: memory_alloc.h:227
static bool is_class(OID *obj_oid, OID *class_oid)
Definition: compactdb_sr.c:67
#define LOG_FIND_THREAD_TRAN_INDEX(thrd)
Definition: perf_monitor.h:158
#define HFID_IS_NULL(hfid)
static const bool COPY
OID * db_get_oid(const DB_VALUE *value)
static int process_object(THREAD_ENTRY *thread_p, HEAP_SCANCACHE *upd_scancache, HEAP_CACHE_ATTRINFO *attr_info, OID *oid)
Definition: compactdb_sr.c:193
static int last_tran_index
Definition: compactdb_sr.c:45
MVCC_SNAPSHOT * mvcc_snapshot
Definition: heap_file.h:154
int lock_object_wait_msecs(THREAD_ENTRY *thread_p, const OID *oid, const OID *class_oid, LOCK lock, int cond_flag, int wait_msecs)
#define ER_HEAP_UNKNOWN_OBJECT
Definition: error_code.h:102
#define LC_MANYOBJS_PTR_IN_COPYAREA(copy_areaptr)
Definition: locator.h:39
int boot_compact_start(THREAD_ENTRY *thread_p)
Definition: compactdb_sr.c:694
void er_clear(void)
DB_VALUE * set_iterator_value(SET_ITERATOR *it)
Definition: set_object.c:4201
#define DB_VALUE_TYPE(value)
Definition: dbtype.h:72
int i
Definition: dynamic_load.c:954
char * msgcat_message(int cat_id, int set_id, int msg_id)
void heap_attrinfo_end(THREAD_ENTRY *thread_p, HEAP_CACHE_ATTRINFO *attr_info)
Definition: heap_file.c:9979
int heap_scancache_quick_start(HEAP_SCANCACHE *scan_cache)
Definition: heap_file.c:7040
#define ER_COMPACTDB_ALREADY_STARTED
Definition: error_code.h:1261
#define OID_ISNULL(oidp)
Definition: oid.h:81
int heap_get_class_info(THREAD_ENTRY *thread_p, const OID *class_oid, HFID *hfid_out, FILE_TYPE *ftype_out, char **classname_out)
Definition: heap_file.c:16733
#define COMPACTDB_REPR_DELETED
#define PEEK
Definition: file_io.h:74
int heap_compact_pages(THREAD_ENTRY *thread_p, OID *class_oid)
Definition: heap_file.c:16754
int boot_compact_db(THREAD_ENTRY *thread_p, OID *class_oids, int n_classes, int space_to_process, int instance_lock_timeout, int class_lock_timeout, bool delete_old_repr, OID *last_processed_class_oid, OID *last_processed_oid, int *total_objects, int *failed_objects, int *modified_objects, int *big_objects, int *initial_last_repr_id)
Definition: compactdb_sr.c:516
SET_ITERATOR * set_iterate(DB_COLLECTION *set)
Definition: set_object.c:4146
#define ER_MVCC_NOT_SATISFIED_REEVALUATION
Definition: error_code.h:1480
#define MSGCAT_CATALOG_UTILS