Skip to content

Commit b0bbfe9

Browse files
authored
refactor(slog): refactor logging for slog gc (#1992)
1 parent 94b21f9 commit b0bbfe9

1 file changed

Lines changed: 30 additions & 26 deletions

File tree

src/replica/mutation_log.cpp

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1445,47 +1445,51 @@ bool can_gc_replica_slog(const dsn::replication::replica_log_info_map &slog_max_
14451445
// `ERR_INCOMPLETE_DATA`, thus it's possible that `valid_start_offset == 0`.
14461446
CHECK(valid_start_offset == 0 || file->end_offset() <= valid_start_offset,
14471447
"valid start offset must be 0 or greater than the end of this log file");
1448-
LOG_DEBUG("gc @ {}: max_decree for {} is missing vs {} as garbage max decree, it's "
1449-
"safe to delete this and all older logs for this replica",
1450-
pid,
1451-
file->path(),
1452-
garbage_max_decree);
1448+
LOG_INFO("gc @ {}: max_decree for {} is missing vs {} as garbage max decree, it's "
1449+
"safe to delete this and all older logs for this replica",
1450+
pid,
1451+
file->path(),
1452+
garbage_max_decree);
14531453
return true;
1454-
} else if (file->end_offset() <= valid_start_offset) {
1454+
}
1455+
1456+
if (file->end_offset() <= valid_start_offset) {
14551457
// This file has been invalid for this replica, since `valid_start_offset` was reset
14561458
// to a file with larger index than this file. Thus all decrees of this replica in
14571459
// this file could be deleted.
1458-
LOG_DEBUG("gc @ {}: log is invalid for {}, as valid start offset vs log end offset = "
1459-
"{} vs {}, it is therefore safe to delete this and all older logs for this "
1460-
"replica",
1461-
pid,
1462-
file->path(),
1463-
valid_start_offset,
1464-
file->end_offset());
1460+
LOG_INFO("gc @ {}: log is invalid for {}, as valid start offset vs log end offset = "
1461+
"{} vs {}, it is therefore safe to delete this and all older logs for this "
1462+
"replica",
1463+
pid,
1464+
file->path(),
1465+
valid_start_offset,
1466+
file->end_offset());
14651467
return true;
1466-
} else if (it->second.max_decree <= garbage_max_decree) {
1468+
}
1469+
1470+
if (it->second.max_decree <= garbage_max_decree) {
14671471
// All decrees are no more than the garbage max decree. Since all decrees less than
14681472
// garbage max decree would be deleted, all decrees of this replica in this file
14691473
// could be deleted.
1470-
LOG_DEBUG("gc @ {}: max_decree for {} is {} vs {} as garbage max decree, it is "
1471-
"therefore safe to delete this and all older logs for this replica",
1472-
pid,
1473-
file->path(),
1474-
it->second.max_decree,
1475-
garbage_max_decree);
1474+
LOG_INFO("gc @ {}: max_decree for {} is {} vs {} as garbage max decree, it is "
1475+
"therefore safe to delete this and all older logs for this replica",
1476+
pid,
1477+
file->path(),
1478+
it->second.max_decree,
1479+
garbage_max_decree);
14761480
return true;
14771481
}
14781482

14791483
// it->second.max_decree > garbage_max_decree
14801484
//
14811485
// Some decrees are more than garbage max decree, thus this file should not be deleted
14821486
// for now.
1483-
LOG_DEBUG("gc @ {}: max_decree for {} is {} vs {} as garbage max decree, it "
1484-
"is therefore not allowed to delete this and all older logs",
1485-
pid,
1486-
file->path(),
1487-
it->second.max_decree,
1488-
garbage_max_decree);
1487+
LOG_INFO("gc @ {}: max_decree for {} is {} vs {} as garbage max decree, it "
1488+
"is therefore not allowed to delete this and all older logs",
1489+
pid,
1490+
file->path(),
1491+
it->second.max_decree,
1492+
garbage_max_decree);
14891493

14901494
auto gap = it->second.max_decree - garbage_max_decree;
14911495
if (file->index() < gc_summary.min_file_index || gap > gc_summary.max_decree_gap) {

0 commit comments

Comments
 (0)