Browse Source

: Fix ForgetAlter method.

vlad-serikov 1 year ago
parent
commit
0e99ae0e0c

+ 4 - 2
ydb/core/tx/schemeshard/schemeshard_info_types.h

@@ -2339,7 +2339,10 @@ struct TFileStoreInfo : public TSimpleRefCount<TFileStoreInfo> {
 
 
     void ForgetAlter() {
     void ForgetAlter() {
         Y_VERIFY(AlterConfig);
         Y_VERIFY(AlterConfig);
+        Y_VERIFY(AlterVersion);
+
         AlterConfig.Reset();
         AlterConfig.Reset();
+        AlterVersion = 0;
     }
     }
 
 
     void FinishAlter() {
     void FinishAlter() {
@@ -2350,8 +2353,7 @@ struct TFileStoreInfo : public TSimpleRefCount<TFileStoreInfo> {
         ++Version;
         ++Version;
         Y_VERIFY(Version == AlterVersion);
         Y_VERIFY(Version == AlterVersion);
 
 
-        AlterConfig.Reset();
-        AlterVersion = 0;
+        ForgetAlter();
     }
     }
 
 
     TFileStoreSpace GetFileStoreSpace() const {
     TFileStoreSpace GetFileStoreSpace() const {

+ 65 - 0
ydb/core/tx/schemeshard/ut_filestore_reboots/ut_filestore_reboots.cpp

@@ -359,4 +359,69 @@ Y_UNIT_TEST_SUITE(TFileStoreWithReboots) {
         CheckLimits(3, 1);  // hdd, ssd
         CheckLimits(3, 1);  // hdd, ssd
         CheckLimits(2, 1);  // hybrid, ssd
         CheckLimits(2, 1);  // hybrid, ssd
     }
     }
+
+    Y_UNIT_TEST(CheckMultipleAlterWithStorageLimitsError) {
+        TTestBasicRuntime runtime;
+        TTestEnv env(runtime);
+        ui64 txId = 100;
+
+        TestUserAttrs(
+            runtime,
+            ++txId,
+            "",
+            "MyRoot",
+            AlterUserAttrs({
+                {"__filestore_space_limit_ssd", ToString(32 * 4_KB)}
+            })
+        );
+        env.TestWaitNotification(runtime, txId);
+
+        NKikimrSchemeOp::TFileStoreDescription vdescr;
+        auto& vc = *vdescr.MutableConfig();
+        vc.SetStorageMediaKind(1);
+        vc.SetBlockSize(4_KB);
+        vc.SetBlocksCount(32);
+        vc.AddExplicitChannelProfiles()->SetPoolKind("pool-kind-1");
+
+        vdescr.SetName("FS");
+        TestCreateFileStore(runtime, ++txId, "/MyRoot", vdescr.DebugString());
+        env.TestWaitNotification(runtime, txId);
+
+        vc.ClearBlockSize();
+        vc.SetBlocksCount(33);
+        vc.SetVersion(1);
+        TestAlterFileStore(
+            runtime,
+            ++txId,
+            "/MyRoot",
+            vdescr.DebugString(),
+            {NKikimrScheme::StatusPreconditionFailed}
+        );
+        env.TestWaitNotification(runtime, txId);
+
+        TestAlterFileStore(
+            runtime,
+            ++txId,
+            "/MyRoot",
+            vdescr.DebugString(),
+            {NKikimrScheme::StatusPreconditionFailed}
+        );
+        env.TestWaitNotification(runtime, txId);
+
+        // It's possible to modify quota size
+        TestUserAttrs(
+            runtime,
+            ++txId,
+            "",
+            "MyRoot",
+            AlterUserAttrs({
+                {"__filestore_space_limit_ssd", ToString(33 * 4_KB)}
+            })
+        );
+        env.TestWaitNotification(runtime, txId);
+
+        // Ok
+        TestAlterFileStore(runtime, ++txId, "/MyRoot", vdescr.DebugString());
+        env.TestWaitNotification(runtime, txId);
+    }
 }
 }