Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[CBRD-25312] Modify diagdb utility to accept a class-name parameter #5141

Merged
merged 12 commits into from
Apr 25, 2024

Conversation

YeunjunLee
Copy link
Contributor

@YeunjunLee YeunjunLee commented Apr 23, 2024

http://jira.cubrid.org/browse/CBRD-25312

Modify heap dump of diagdb utility to accept class-name parameter.

  • Add -c and --class-name flag at diagdb option table and option map.
  • Modify usage message of diagdb to provide information of class-name parameter.
  • Modify diagdb main function to fetch class-name parameter
  • Create file_class_dump_specific_heap_file() function, which dumps a specific heap file with class name.

@YeunjunLee YeunjunLee self-assigned this Apr 23, 2024
@YeunjunLee YeunjunLee marked this pull request as ready for review April 23, 2024 08:56
@YeunjunLee YeunjunLee requested a review from hornetmj as a code owner April 23, 2024 08:56
@YeunjunLee YeunjunLee requested review from Rudeus and joohok April 23, 2024 08:56
class_name = utility_get_option_string_value (arg_map, DIAG_CLASS_NAME_S, 0);
if (class_name == NULL)
{
/* this dumps the contents of all heaps */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/* this dumps the contents of all heaps */

The DUMP OF ALL HEAPS in the next line has enough information.

}
else
{
/* this dumps the contents of a specific heap for given class name */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/* this dumps the contents of a specific heap for given class name */

/* this dumps the contents of a specific heap for given class name */
if (!sm_check_system_class_by_name (class_name))
{
/* check if the format of class name is valid */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/* check if the format of class name is valid */

You don't always need to leave a comment about what it does. This should be fully explained, mainly through the function name.

@@ -215,6 +215,8 @@ extern DISK_ISVALID file_tracker_check (THREAD_ENTRY * thread_p);
extern int file_tracker_dump (THREAD_ENTRY * thread_p, FILE * fp);
extern int file_tracker_dump_all_capacities (THREAD_ENTRY * thread_p, FILE * fp);
extern int file_tracker_dump_all_heap (THREAD_ENTRY * thread_p, FILE * fp, bool dump_records);
extern void file_class_dump_specific_heap_file (THREAD_ENTRY * thread_p, FILE * fp, bool dump_records,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the determined processing method, this function should be defined in heap_file.c/h. And this function might call the following functions to convert class name into hfid.

  • xlocator_find_class_oid()
  • heap_hfid_cache_get()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved the function to heap_file.c and change its name to heap_dump_specific_file.

@@ -834,7 +834,11 @@ valid options:\n\
6 dump disk bitmaps\n\
7 dump catalog\n\
8 dump log\n\
9 dump heap\n
9 dump heap / class\n\
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This revision is not a final edition and should remain a hidden option until the final version is released. There is even a possibility of changing the specifications as follows to compatible with other utilies.

cubrid diagdb [OPTION] database-name [class_name1 class_name2 ...]

One option is to separate the issue of usage output.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rollback usage message to original diagdb usage message.

goto error_exit;
}
}
fprintf (outfp, "\n*** DUMP OF SPECIFIC HEAP(S) ***\n");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be kinder, it would be better to include the class name entered with the --class-name option in the heading.

*** DUMP HEAP OF user_name.class_name ***

src/executables/util_sa.c Outdated Show resolved Hide resolved
src/executables/util_sa.c Outdated Show resolved Hide resolved
src/storage/heap_file.c Outdated Show resolved Hide resolved
msg/en_US/utils.msg Outdated Show resolved Hide resolved
YeunjunLee and others added 2 commits April 25, 2024 12:38
Comment on lines +1576 to +1579
if (diag == DIAGDUMP_ALL && class_name != NULL)
{
goto print_diag_usage;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (diag == DIAGDUMP_ALL && class_name != NULL)
{
goto print_diag_usage;
}
if (diag == DIAGDUMP_ALL && class_name != NULL)
{
goto print_diag_usage;
}

}
else
{
assert (diag != DIAGDUMP_ALL);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is already checked.

Suggested change
assert (diag != DIAGDUMP_ALL);

@@ -554,6 +554,7 @@ extern int heap_set_autoincrement_value (THREAD_ENTRY * thread_p, HEAP_CACHE_ATT
HEAP_SCANCACHE * scan_cache, int *is_set);

extern void heap_dump (THREAD_ENTRY * thread_p, FILE * fp, HFID * hfid, bool dump_records);
extern void heap_dump_specific_file (THREAD_ENTRY * thread_p, FILE * fp, bool dump_records, const char *class_name);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
extern void heap_dump_specific_file (THREAD_ENTRY * thread_p, FILE * fp, bool dump_records, const char *class_name);
#if defined (SA_MODE)
extern void heap_dump_specific_file (THREAD_ENTRY * thread_p, FILE * fp, bool dump_records, const char *class_name);
#endif

Comment on lines 14510 to 14525
/*
* heap_dump_specific_file () - dump a specific heap file with class name
*
* return :
* thread_p (in) : thread entry
* fp (in) : output file
* dump_records (in) : true to dump records
* class_name (in) : name of class to dump
*/
void
heap_dump_specific_file (THREAD_ENTRY * thread_p, FILE * fp, bool dump_records, const char *class_name)
{
/* TODO: Fetch HFID of class which corresponds to class_name, and dump heap file by HFID. Will be handled at CBRD-25313 and CBRD-25314. */
fprintf (fp, "\n\n*** DUMP A CLASS NAMED %s ***\n\n", class_name);
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/*
* heap_dump_specific_file () - dump a specific heap file with class name
*
* return :
* thread_p (in) : thread entry
* fp (in) : output file
* dump_records (in) : true to dump records
* class_name (in) : name of class to dump
*/
void
heap_dump_specific_file (THREAD_ENTRY * thread_p, FILE * fp, bool dump_records, const char *class_name)
{
/* TODO: Fetch HFID of class which corresponds to class_name, and dump heap file by HFID. Will be handled at CBRD-25313 and CBRD-25314. */
fprintf (fp, "\n\n*** DUMP A CLASS NAMED %s ***\n\n", class_name);
}
#if defined (SA_MODE)
/*
* heap_dump_specific_file () - dump a specific heap file with class name
*
* return :
* thread_p (in) : thread entry
* fp (in) : output file
* dump_records (in) : true to dump records
* class_name (in) : name of class to dump
*/
void
heap_dump_specific_file (THREAD_ENTRY * thread_p, FILE * fp, bool dump_records, const char *class_name)
{
/* TODO: Fetch HFID of class which corresponds to class_name, and dump heap file by HFID. Will be handled at CBRD-25313 and CBRD-25314. */
fprintf (fp, "\n\n*** DUMP A CLASS NAMED %s ***\n\n", class_name);
}
#endif

* class_name (in) : name of class to dump
*/
void
heap_dump_specific_file (THREAD_ENTRY * thread_p, FILE * fp, bool dump_records, const char *class_name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
heap_dump_specific_file (THREAD_ENTRY * thread_p, FILE * fp, bool dump_records, const char *class_name)
heap_dump_heap_file (THREAD_ENTRY * thread_p, FILE * fp, bool dump_records, const char *class_name)

heap_dump_specific_file (THREAD_ENTRY * thread_p, FILE * fp, bool dump_records, const char *class_name)
{
/* TODO: Fetch HFID of class which corresponds to class_name, and dump heap file by HFID. Will be handled at CBRD-25313 and CBRD-25314. */
fprintf (fp, "\n\n*** DUMP A CLASS NAMED %s ***\n\n", class_name);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to print out this message? This information is already included in the heading.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's duplicated information. It's been deleted.

@YeunjunLee YeunjunLee requested a review from hornetmj April 25, 2024 06:10
@YeunjunLee YeunjunLee merged commit 78f96e0 into CUBRID:feature/heap_dump Apr 25, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants