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-23850] coredump occurs when heap_get_visible_version_from_log() function is called after executing backupdb with -r option. (#2575) #2603

Merged
merged 1 commit into from
Mar 12, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions src/transaction/log_page_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -7038,12 +7038,10 @@ logpb_remove_archive_logs_exceed_limit (THREAD_ENTRY * thread_p, int max_count)
*
* info_reason(in):
*
* NOTE: Archive that are not needed for system crashes are removed.
* NOTE: Archive that are not needed for system crashes and vacuum are removed.
* That these archives may be needed for media crash recovery.
* Therefore, it is important that the user copy these archives
* to tape. Check the log information file.
*
* TODO: Make sure the removed logs have been processed by vacuum.
*/
void
logpb_remove_archive_logs (THREAD_ENTRY * thread_p, const char *info_reason)
Expand All @@ -7054,6 +7052,15 @@ logpb_remove_archive_logs (THREAD_ENTRY * thread_p, const char *info_reason)
LOG_LSA newflush_upto_lsa; /* Next to be flush */
int first_deleted_arv_num;
int last_deleted_arv_num;
int min_arv_required_for_vacuum;
LOG_PAGEID vacuum_first_pageid;

if (!vacuum_is_safe_to_remove_archives ())
{
/* we don't know yet what is the first log page required by vacuum if vacuum_disable is set to true.
* this will block any log archive removal until it is set to false. */
return;
}

assert (LOG_CS_OWN_WRITE_MODE (thread_p));

Expand Down Expand Up @@ -7101,6 +7108,14 @@ logpb_remove_archive_logs (THREAD_ENTRY * thread_p, const char *info_reason)

last_deleted_arv_num--;

vacuum_first_pageid = vacuum_min_log_pageid_to_keep (thread_p);
if (vacuum_first_pageid != NULL_PAGEID && logpb_is_page_in_archive (vacuum_first_pageid))
{
min_arv_required_for_vacuum = logpb_get_archive_number (thread_p, vacuum_first_pageid);
min_arv_required_for_vacuum--;
last_deleted_arv_num = MIN (last_deleted_arv_num, min_arv_required_for_vacuum);
}

if (log_Gl.hdr.last_deleted_arv_num + 1 > last_deleted_arv_num)
{
/* Nothing to remove */
Expand All @@ -7114,6 +7129,9 @@ logpb_remove_archive_logs (THREAD_ENTRY * thread_p, const char *info_reason)

log_Gl.hdr.last_deleted_arv_num = last_deleted_arv_num;
logpb_flush_header (thread_p); /* to get rid of archives */

_er_log_debug (ARG_FILE_LINE, "first_deleted_arv_num = %d, last_deleted_arv_num = %d", first_deleted_arv_num,
last_deleted_arv_num);
}
}

Expand Down