You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "jackye1995 (via GitHub)" <gi...@apache.org> on 2023/06/27 16:25:10 UTC

[GitHub] [iceberg] jackye1995 commented on a diff in pull request #6948: Core: Add Catalog Transactions API

jackye1995 commented on code in PR #6948:
URL: https://github.com/apache/iceberg/pull/6948#discussion_r1244026460


##########
core/src/main/java/org/apache/iceberg/catalog/CatalogTransaction.java:
##########
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iceberg.catalog;
+
+public interface CatalogTransaction {
+
+  enum IsolationLevel {
+
+    /**
+     * All reads that are being made will see the last committed values that existed when the table

Review Comment:
   I have doubt about this definition:
   
   > All reads that are being made will see the last committed values that existed when the table was loaded first inside the catalog transaction.
   
   This is different from the definition in other places like [here](https://learn.microsoft.com/en-us/dotnet/framework/data/adonet/sql/snapshot-isolation-in-sql-server):
   
   > SNAPSHOT isolation specifies that data read within a transaction will never reflect changes made by other simultaneous transactions.
   
   The key difference is **when the table was loaded first inside the catalog transaction**, which means there will be a time difference between when 2 tables are loaded in the transaction.
   
   Consider the following case of 2 processes:
   
   process 1:
   
   ```
   t0: CatalogTransaction catalogTransaction = catalog().createTransaction(isolationLevel);
       Catalog txCatalog = catalogTransaction.asCatalog();
   
   t1: Table table1 = txCatalog.load(TableIdentifier.of("db", "table1"))
   t2: Table table2 = txCatalog.load(TableIdentifier.of("db", "table2"))
   ```
   
   process 2:
   
   ```
   t1.5: table2.newAppend().addFiles(...).commit()
   ```
   
   This means the state of tables in the same transaction in process1 is different.
   
   When translated to a real-life SQL use case, it means:
   
   process 1:
   
   ```
   SELECT * FROM table1 JOIN table2 ON ...
   ```
   
   process 2:
   
   ```
   INSERT INTO table2 ...
   ```
   
   has a chance to cause a phantom read in process 1, and that clearly violates the isolation guarantee
   



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org