Skip to content

Commit a24a53f

Browse files
authored
Fix PDisk log flush completion action use after free (#1359)
Fixes #1382
1 parent f5290a7 commit a24a53f

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

ydb/core/blobstorage/pdisk/blobstorage_pdisk_impl_log.cpp

+10-9
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,28 @@ class TLogFlushCompletionAction : public TCompletionAction {
1313
const ui32 EndChunkIdx;
1414
const ui32 EndSectorIdx;
1515
THolder<TLogWriter> &CommonLogger;
16+
TCompletionAction* CompletionLogWrite;
1617
public:
1718
TLogFlushCompletionAction(ui32 endChunkIdx, ui32 endSectorIdx, THolder<TLogWriter> &commonLogger, TCompletionAction* completionLogWrite)
1819
: EndChunkIdx(endChunkIdx)
1920
, EndSectorIdx(endSectorIdx)
20-
, CommonLogger(commonLogger) {
21-
this->FlushAction = completionLogWrite;
22-
}
21+
, CommonLogger(commonLogger)
22+
, CompletionLogWrite(completionLogWrite) { }
2323

2424
void Exec(TActorSystem *actorSystem) override {
2525
CommonLogger->FirstUncommitted = TFirstUncommitted(EndChunkIdx, EndSectorIdx);
26-
27-
Y_DEBUG_ABORT_UNLESS(FlushAction);
28-
29-
// FlushAction here is a TCompletionLogWrite which will decrease owner's inflight count.
30-
FlushAction->Exec(actorSystem);
26+
27+
CompletionLogWrite->SetResult(Result);
28+
CompletionLogWrite->SetErrorReason(ErrorReason);
29+
CompletionLogWrite->Exec(actorSystem);
3130

3231
delete this;
3332
}
3433

3534
void Release(TActorSystem *actorSystem) override {
36-
FlushAction->Release(actorSystem);
35+
CompletionLogWrite->SetResult(Result);
36+
CompletionLogWrite->SetErrorReason(ErrorReason);
37+
CompletionLogWrite->Release(actorSystem);
3738

3839
delete this;
3940
}

ydb/core/blobstorage/pdisk/blobstorage_pdisk_state.h

+1
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ struct TOwnerData {
196196
CurrentFirstLsnToKeep = 0;
197197
LastWrittenCommitLsn = 0;
198198
CutLogId = TActorId();
199+
LogEndPosition = TLogEndPosition(0, 0);
199200
WhiteboardProxyId = TActorId();
200201
LogRecordsInitiallyRead = 0;
201202
LogRecordsConsequentlyRead = 0;

0 commit comments

Comments
 (0)