tkalkirill commented on code in PR #1578:
URL: https://github.com/apache/ignite-3/pull/1578#discussion_r1088174975
##########
modules/storage-rocksdb/src/main/java/org/apache/ignite/internal/storage/rocksdb/RocksDbMvPartitionStorage.java:
##########
@@ -1543,4 +1550,29 @@ private void
saveRaftGroupConfigurationOnRebalance(WriteBatch writeBatch, RaftGr
this.lastGroupConfig = config;
}
+
+ /**
+ * Prepares the storage for cleanup.
+ *
+ * <p>After cleanup (successful or not), method {@link #finishCleanup()}
must be called.
+ */
+ void startCleanup(WriteBatch writeBatch) throws RocksDBException {
+ if (!state.compareAndSet(StorageState.RUNNABLE, StorageState.CLEANUP))
{
+ throwExceptionDependingOnStorageState(state.get(),
createStorageInfo());
+ }
+
+ // Changed storage states and expect all storage operations to stop
soon.
+ busyLock.block();
+
+ clearStorage(writeBatch, 0, 0);
+ }
+
+ /**
+ * Finishes cleanup up the storage.
+ */
+ void finishCleanup() {
+ if (state.compareAndSet(StorageState.CLEANUP, StorageState.RUNNABLE)) {
+ busyLock.unblock();
Review Comment:
Here we execute in same thread and in `AbstractPageMemoryMvPartitionStorage`
in different ones, so the implementation is slightly different.
##########
modules/storage-rocksdb/src/main/java/org/apache/ignite/internal/storage/rocksdb/RocksDbMvPartitionStorage.java:
##########
@@ -1543,4 +1550,29 @@ private void
saveRaftGroupConfigurationOnRebalance(WriteBatch writeBatch, RaftGr
this.lastGroupConfig = config;
}
+
+ /**
+ * Prepares the storage for cleanup.
+ *
+ * <p>After cleanup (successful or not), method {@link #finishCleanup()}
must be called.
+ */
+ void startCleanup(WriteBatch writeBatch) throws RocksDBException {
+ if (!state.compareAndSet(StorageState.RUNNABLE, StorageState.CLEANUP))
{
+ throwExceptionDependingOnStorageState(state.get(),
createStorageInfo());
+ }
+
+ // Changed storage states and expect all storage operations to stop
soon.
+ busyLock.block();
+
+ clearStorage(writeBatch, 0, 0);
+ }
+
+ /**
+ * Finishes cleanup up the storage.
+ */
+ void finishCleanup() {
+ if (state.compareAndSet(StorageState.CLEANUP, StorageState.RUNNABLE)) {
+ busyLock.unblock();
Review Comment:
Here we execute in same thread and in `AbstractPageMemoryMvPartitionStorage`
in different threads, so the implementation is slightly different.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]