File tree 6 files changed +27
-14
lines changed
6 files changed +27
-14
lines changed Original file line number Diff line number Diff line change @@ -194,6 +194,7 @@ namespace NKikimr::NBlobDepot {
194
194
TActorId PipeId;
195
195
TActorId PipeServerId;
196
196
bool IsConnected = false ;
197
+ ui64 ConnectionInstance = 0 ;
197
198
198
199
NMonitoring::TDynamicCounterPtr AgentCounters;
199
200
Original file line number Diff line number Diff line change @@ -155,6 +155,8 @@ namespace NKikimr::NBlobDepot {
155
155
}
156
156
157
157
void TBlobDepotAgent::OnDisconnect () {
158
+ ++ConnectionInstance;
159
+
158
160
while (!TabletRequestInFlight.empty ()) {
159
161
auto node = TabletRequestInFlight.extract (TabletRequestInFlight.begin ());
160
162
auto & requestInFlight = node.value ();
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ namespace NKikimr::NBlobDepot {
18
18
TBlobSeqId BlobSeqId;
19
19
std::optional<TS3Locator> LocatorInFlight;
20
20
TActorId WriterActorId;
21
+ ui64 ConnectionInstanceOnStart;
21
22
22
23
struct TLifetimeToken {};
23
24
std::shared_ptr<TLifetimeToken> LifetimeToken;
@@ -410,6 +411,8 @@ namespace NKikimr::NBlobDepot {
410
411
.AddMetadata(" key" , Request.Id.ToString()),
411
412
Request.Buffer.ExtractUnderlyingContainerOrCopy<TString>()),
412
413
IEventHandle::FlagTrackDelivery));
414
+
415
+ ConnectionInstanceOnStart = Agent.ConnectionInstance;
413
416
}
414
417
415
418
void OnPutS3ObjectResponse (std::optional<TString>&& error) {
@@ -418,6 +421,11 @@ namespace NKikimr::NBlobDepot {
418
421
419
422
WriterActorId = {};
420
423
424
+ if (ConnectionInstanceOnStart != Agent.ConnectionInstance ) {
425
+ error = " BlobDepot tablet disconnected" ;
426
+ LocatorInFlight.reset (); // prevent discarding this locator
427
+ }
428
+
421
429
if (error) {
422
430
++*Agent.S3PutsError ;
423
431
Original file line number Diff line number Diff line change @@ -75,13 +75,8 @@ namespace NKikimr::NBlobDepot {
75
75
if (item.HasS3Locator ()) {
76
76
const auto & locator = TS3Locator::FromProto (item.GetS3Locator ());
77
77
const size_t numErased = agent.S3WritesInFlight .erase (locator);
78
- if (locator.Generation < generation) {
79
- Y_ABORT_UNLESS (!numErased);
80
- Self->Data ->AddToS3Trash (locator, txc, this );
81
- } else {
82
- Y_ABORT_UNLESS (numErased == 1 );
83
- Self->S3Manager ->AddTrashToCollect (locator);
84
- }
78
+ Y_ABORT_UNLESS (numErased);
79
+ Self->S3Manager ->AddTrashToCollect (locator);
85
80
}
86
81
};
87
82
@@ -244,11 +239,10 @@ namespace NKikimr::NBlobDepot {
244
239
}
245
240
246
241
for (const auto & item : record.GetS3Locators ()) {
247
- if (const auto & locator = TS3Locator::FromProto (item); locator.Generation == generation) {
248
- const size_t numErased = agent.S3WritesInFlight .erase (locator);
249
- Y_ABORT_UNLESS (numErased == 1 );
250
- S3Manager->AddTrashToCollect (locator);
251
- }
242
+ const auto & locator = TS3Locator::FromProto (item);
243
+ const size_t numErased = agent.S3WritesInFlight .erase (locator);
244
+ Y_ABORT_UNLESS (numErased == 1 );
245
+ S3Manager->AddTrashToCollect (locator);
252
246
}
253
247
}
254
248
Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ namespace NKikimr::NBlobDepot {
53
53
locator.ToProto (responseItem->MutableS3Locator ());
54
54
55
55
// we put it here until operation is completed; if tablet restarts and operation fails, then this
56
- // key will be deleted
56
+ // key will be deleted; we also rewrite spoiled locator because Len is different
57
57
db.Table <Schema::TrashS3>().Key (locator.Generation , locator.KeyId ).Update <Schema::TrashS3::Len>(locator.Len );
58
58
59
59
const bool inserted = agent.S3WritesInFlight .insert (locator).second ;
@@ -98,6 +98,14 @@ namespace NKikimr::NBlobDepot {
98
98
};
99
99
100
100
TS3Locator TS3Manager::AllocateS3Locator (ui32 len) {
101
+ if (!DeleteQueue.empty ()) {
102
+ TS3Locator res = DeleteQueue.front ();
103
+ DeleteQueue.pop_front ();
104
+ Self->TabletCounters ->Simple ()[NKikimrBlobDepot::COUNTER_TOTAL_S3_TRASH_OBJECTS] = --TotalS3TrashObjects;
105
+ Self->TabletCounters ->Simple ()[NKikimrBlobDepot::COUNTER_TOTAL_S3_TRASH_SIZE] = TotalS3TrashSize -= res.Len ;
106
+ res.Len = len;
107
+ return res;
108
+ }
101
109
return {
102
110
.Len = len,
103
111
.Generation = Self->Executor ()->Generation (),
Original file line number Diff line number Diff line change @@ -153,7 +153,7 @@ namespace NKikimr::NBlobDepot {
153
153
}
154
154
155
155
TString MakeObjectName (const TString& basePath) const {
156
- const size_t hash = THash ()(* this );
156
+ const size_t hash = MultiHash (Generation, KeyId );
157
157
const size_t a = hash % 36 ;
158
158
const size_t b = hash / 36 % 36 ;
159
159
static const char vec[] = " 0123456789abcdefghijklmnopqrstuvwxyz" ;
You can’t perform that action at this time.
0 commit comments