Skip to content

Commit 8fb2ef1

Browse files
committed
Add logging for errors in external file ingestion path
1 parent a805c9b commit 8fb2ef1

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed

db/external_sst_file_ingestion_job.cc

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ Status ExternalSstFileIngestionJob::Prepare(
4242
status =
4343
GetIngestedFileInfo(file_path, next_file_number++, &file_to_ingest, sv);
4444
if (!status.ok()) {
45+
ROCKS_LOG_WARN(db_options_.info_log,
46+
"Failed to get ingested file info: %s: %s",
47+
file_path.c_str(), status.ToString().c_str());
4548
return status;
4649
}
4750

@@ -189,6 +192,10 @@ Status ExternalSstFileIngestionJob::Prepare(
189192
ROCKS_LOG_INFO(db_options_.info_log,
190193
"Tried to link file %s but it's not supported : %s",
191194
path_outside_db.c_str(), status.ToString().c_str());
195+
} else {
196+
ROCKS_LOG_WARN(db_options_.info_log, "Failed to link file %s to %s: %s",
197+
path_outside_db.c_str(), path_inside_db.c_str(),
198+
status.ToString().c_str());
192199
}
193200
} else {
194201
f.copy_file = true;
@@ -213,6 +220,12 @@ Status ExternalSstFileIngestionJob::Prepare(
213220
io_tracer_);
214221
// The destination of the copy will be ingested
215222
f.file_temperature = dst_temp;
223+
224+
if (!status.ok()) {
225+
ROCKS_LOG_WARN(db_options_.info_log, "Failed to copy file %s to %s: %s",
226+
path_outside_db.c_str(), path_inside_db.c_str(),
227+
status.ToString().c_str());
228+
}
216229
} else {
217230
// Note: we currently assume that linking files does not cross
218231
// temperatures, so no need to change f.file_temperature
@@ -438,6 +451,11 @@ Status ExternalSstFileIngestionJob::NeedsFlush(bool* flush_needed,
438451
}
439452
status = cfd_->RangesOverlapWithMemtables(
440453
ranges, super_version, db_options_.allow_data_in_errors, flush_needed);
454+
if (!status.ok()) {
455+
ROCKS_LOG_WARN(db_options_.info_log,
456+
"Failed to check ranges overlap with memtables: %s",
457+
status.ToString().c_str());
458+
}
441459
}
442460
if (status.ok() && *flush_needed) {
443461
if (!ingestion_options_.allow_blocking_flush) {
@@ -472,6 +490,9 @@ Status ExternalSstFileIngestionJob::Run() {
472490
bool need_flush = false;
473491
status = NeedsFlush(&need_flush, super_version);
474492
if (!status.ok()) {
493+
ROCKS_LOG_WARN(db_options_.info_log,
494+
"Failed to check if flush is needed: %s",
495+
status.ToString().c_str());
475496
return status;
476497
}
477498
if (need_flush) {
@@ -543,6 +564,9 @@ Status ExternalSstFileIngestionJob::Run() {
543564
&last_seqno, &batch_uppermost_level,
544565
prev_batch_uppermost_level);
545566
if (!status.ok()) {
567+
ROCKS_LOG_WARN(db_options_.info_log,
568+
"Failed to assign levels for one batch: %s",
569+
status.ToString().c_str());
546570
return status;
547571
}
548572

@@ -585,6 +609,8 @@ Status ExternalSstFileIngestionJob::AssignLevelsForOneBatch(
585609
&largest_parsed, false /* log_err_key */);
586610
}
587611
if (!status.ok()) {
612+
ROCKS_LOG_WARN(db_options_.info_log, "Failed to parse internal key: %s",
613+
status.ToString().c_str());
588614
return status;
589615
}
590616

@@ -607,6 +633,10 @@ Status ExternalSstFileIngestionJob::AssignLevelsForOneBatch(
607633

608634
status = AssignGlobalSeqnoForIngestedFile(file, assigned_seqno);
609635
if (!status.ok()) {
636+
ROCKS_LOG_WARN(
637+
db_options_.info_log,
638+
"Failed to assign global sequence number for ingested file: %s",
639+
status.ToString().c_str());
610640
return status;
611641
}
612642
TEST_SYNC_POINT_CALLBACK("ExternalSstFileIngestionJob::Run",
@@ -619,6 +649,9 @@ Status ExternalSstFileIngestionJob::AssignLevelsForOneBatch(
619649

620650
status = GenerateChecksumForIngestedFile(file);
621651
if (!status.ok()) {
652+
ROCKS_LOG_WARN(db_options_.info_log,
653+
"Failed to generate checksum for ingested file: %s",
654+
status.ToString().c_str());
622655
return status;
623656
}
624657

@@ -844,6 +877,10 @@ Status ExternalSstFileIngestionJob::ResetTableReader(
844877
Status status =
845878
fs_->NewRandomAccessFile(external_file, fo, &sst_file, nullptr);
846879
if (!status.ok()) {
880+
ROCKS_LOG_WARN(
881+
db_options_.info_log,
882+
"Failed to create random access file for external file %s: %s",
883+
external_file.c_str(), status.ToString().c_str());
847884
return status;
848885
}
849886
Temperature updated_temp = sst_file->GetTemperature();
@@ -966,6 +1003,10 @@ Status ExternalSstFileIngestionJob::SanityCheckTableProperties(
9661003
// user_defined_timestamps_persisted flag for the file.
9671004
file_to_ingest->user_defined_timestamps_persisted = false;
9681005
} else if (!s.ok()) {
1006+
ROCKS_LOG_WARN(
1007+
db_options_.info_log,
1008+
"ValidateUserDefinedTimestampsOptions failed for external file %s: %s",
1009+
external_file.c_str(), s.ToString().c_str());
9691010
return s;
9701011
}
9711012

@@ -990,6 +1031,9 @@ Status ExternalSstFileIngestionJob::GetIngestedFileInfo(
9901031
Status status = fs_->GetFileSize(external_file, IOOptions(),
9911032
&file_to_ingest->file_size, nullptr);
9921033
if (!status.ok()) {
1034+
ROCKS_LOG_WARN(db_options_.info_log,
1035+
"Failed to get file size for external file %s: %s",
1036+
external_file.c_str(), status.ToString().c_str());
9931037
return status;
9941038
}
9951039

@@ -1006,12 +1050,19 @@ Status ExternalSstFileIngestionJob::GetIngestedFileInfo(
10061050
/*user_defined_timestamps_persisted=*/true, sv,
10071051
file_to_ingest, &table_reader);
10081052
if (!status.ok()) {
1053+
ROCKS_LOG_WARN(db_options_.info_log,
1054+
"Failed to reset table reader for external file %s: %s",
1055+
external_file.c_str(), status.ToString().c_str());
10091056
return status;
10101057
}
10111058

10121059
status = SanityCheckTableProperties(external_file, new_file_number, sv,
10131060
file_to_ingest, &table_reader);
10141061
if (!status.ok()) {
1062+
ROCKS_LOG_WARN(
1063+
db_options_.info_log,
1064+
"Failed to sanity check table properties for external file %s: %s",
1065+
external_file.c_str(), status.ToString().c_str());
10151066
return status;
10161067
}
10171068

@@ -1025,6 +1076,10 @@ Status ExternalSstFileIngestionJob::GetIngestedFileInfo(
10251076
table_reader.get(), sv, file_to_ingest, allow_data_in_errors);
10261077

10271078
if (!seqno_status.ok()) {
1079+
ROCKS_LOG_WARN(
1080+
db_options_.info_log,
1081+
"Failed to get sequence number boundary for external file %s: %s",
1082+
external_file.c_str(), seqno_status.ToString().c_str());
10281083
return seqno_status;
10291084
}
10301085
assert(file_to_ingest->smallest_seqno <= file_to_ingest->largest_seqno);
@@ -1052,6 +1107,9 @@ Status ExternalSstFileIngestionJob::GetIngestedFileInfo(
10521107
status = table_reader->VerifyChecksum(
10531108
ro, TableReaderCaller::kExternalSSTIngestion);
10541109
if (!status.ok()) {
1110+
ROCKS_LOG_WARN(db_options_.info_log,
1111+
"Failed to verify checksum for table reader: %s",
1112+
status.ToString().c_str());
10551113
return status;
10561114
}
10571115
}
@@ -1243,6 +1301,9 @@ Status ExternalSstFileIngestionJob::AssignLevelAndSeqnoForIngestedFile(
12431301
ro, env_options_, file_to_ingest->start_ukey,
12441302
file_to_ingest->limit_ukey, lvl, &overlap_with_level);
12451303
if (!status.ok()) {
1304+
ROCKS_LOG_WARN(db_options_.info_log,
1305+
"Failed to check overlap with level iterator: %s",
1306+
status.ToString().c_str());
12461307
return status;
12471308
}
12481309
if (overlap_with_level) {
@@ -1355,6 +1416,14 @@ Status ExternalSstFileIngestionJob::AssignGlobalSeqnoForIngestedFile(
13551416
PutFixed64(&seqno_val, seqno);
13561417
status = fsptr->Write(file_to_ingest->global_seqno_offset, seqno_val,
13571418
IOOptions(), nullptr);
1419+
if (!status.ok()) {
1420+
ROCKS_LOG_WARN(db_options_.info_log,
1421+
"Failed to write global seqno to %s: %s",
1422+
file_to_ingest->internal_file_path.c_str(),
1423+
status.ToString().c_str());
1424+
return status;
1425+
}
1426+
13581427
if (status.ok()) {
13591428
TEST_SYNC_POINT("ExternalSstFileIngestionJob::BeforeSyncGlobalSeqno");
13601429
status = SyncIngestedFile(fsptr.get());
@@ -1371,6 +1440,11 @@ Status ExternalSstFileIngestionJob::AssignGlobalSeqnoForIngestedFile(
13711440
return status;
13721441
}
13731442
} else if (!status.IsNotSupported()) {
1443+
ROCKS_LOG_WARN(
1444+
db_options_.info_log,
1445+
"Failed to open ingested file %s for random read/write: %s",
1446+
file_to_ingest->internal_file_path.c_str(),
1447+
status.ToString().c_str());
13741448
return status;
13751449
}
13761450
}
@@ -1403,6 +1477,9 @@ IOStatus ExternalSstFileIngestionJob::GenerateChecksumForIngestedFile(
14031477
db_options_.allow_mmap_reads, io_tracer_, db_options_.rate_limiter.get(),
14041478
ro, db_options_.stats, db_options_.clock);
14051479
if (!io_s.ok()) {
1480+
ROCKS_LOG_WARN(
1481+
db_options_.info_log, "Failed to generate checksum for %s: %s",
1482+
file_to_ingest->internal_file_path.c_str(), io_s.ToString().c_str());
14061483
return io_s;
14071484
}
14081485
file_to_ingest->file_checksum = std::move(file_checksum);

0 commit comments

Comments
 (0)