You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "frankliee (via GitHub)" <gi...@apache.org> on 2024/05/05 14:13:59 UTC

[PR] Hive catalog: Add retry logic for hive locking [iceberg-python]

frankliee opened a new pull request, #701:
URL: https://github.com/apache/iceberg-python/pull/701

   In the current hive catalog implementation, locking will only be executed once.
   If another task has already locked the target table, the locking will fail inevitably.
   
   This PR adds retry and wait logic for hive catalog with the following modifications.
   
   1.  add `_wait_for_lock` on hive catalog
   2. add `WaitingForLockException`
   3. add a new UT that two tasks are locking the same table.


-- 
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


Re: [PR] Hive catalog: Add retry logic for hive locking [iceberg-python]

Posted by "HonahX (via GitHub)" <gi...@apache.org>.
HonahX merged PR #701:
URL: https://github.com/apache/iceberg-python/pull/701


-- 
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


Re: [PR] Hive catalog: Add retry logic for hive locking [iceberg-python]

Posted by "HonahX (via GitHub)" <gi...@apache.org>.
HonahX commented on PR #701:
URL: https://github.com/apache/iceberg-python/pull/701#issuecomment-2111753317

   Looks like all the review comments are addressed. I'll merge this. Thanks everyone!


-- 
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


Re: [PR] Hive catalog: Add retry logic for hive locking [iceberg-python]

Posted by "frankliee (via GitHub)" <gi...@apache.org>.
frankliee commented on code in PR #701:
URL: https://github.com/apache/iceberg-python/pull/701#discussion_r1594885592


##########
pyiceberg/catalog/hive.py:
##########
@@ -111,6 +122,15 @@
 HIVE2_COMPATIBLE = "hive.hive2-compatible"
 HIVE2_COMPATIBLE_DEFAULT = False
 
+LOCK_CHECK_MIN_WAIT_TIME = "lock_check_min_wait_time"
+LOCK_CHECK_MAX_WAIT_TIME = "lock_check_max_wait_time"
+LOCK_CHECK_RETRIES = "lock_check_retries"
+DEFAULT_LOCK_CHECK_MIN_WAIT_TIME = 2
+DEFAULT_LOCK_CHECK_MAX_WAIT_TIME = 30
+DEFAULT_LOCK_CHECK_RETRIES = 10

Review Comment:
   A good idea, I have updated these default values.



-- 
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


Re: [PR] Hive catalog: Add retry logic for hive locking [iceberg-python]

Posted by "frankliee (via GitHub)" <gi...@apache.org>.
frankliee commented on code in PR #701:
URL: https://github.com/apache/iceberg-python/pull/701#discussion_r1591970151


##########
pyiceberg/catalog/hive.py:
##########
@@ -356,6 +378,28 @@ def _create_lock_request(self, database_name: str, table_name: str) -> LockReque
 
         return lock_request
 
+    def _wait_for_lock(self, database_name: str, table_name: str, lockid: int, open_client: Client) -> LockResponse:
+        @retry(
+            retry=retry_if_exception_type(WaitingForLockException),
+            wait=wait_exponential(
+                multiplier=self._lock_check_multiplier, min=self._lock_check_min_wait_time, max=self._lock_check_max_wait_time
+            ),
+            stop=stop_after_attempt(self._lock_check_retries),
+            reraise=True,
+        )
+        def _do_wait_for_lock() -> LockResponse:
+            response: LockResponse = open_client.check_lock(CheckLockRequest(lockid=lockid))
+            if response.state == LockState.ACQUIRED:
+                return response
+            elif response.state == LockState.WAITING:
+                msg = f"Wait on lock for {database_name}:{table_name}"

Review Comment:
   updated



-- 
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


Re: [PR] Hive catalog: Add retry logic for hive locking [iceberg-python]

Posted by "HonahX (via GitHub)" <gi...@apache.org>.
HonahX commented on code in PR #701:
URL: https://github.com/apache/iceberg-python/pull/701#discussion_r1591764194


##########
pyiceberg/catalog/hive.py:
##########
@@ -111,6 +122,13 @@
 HIVE2_COMPATIBLE = "hive.hive2-compatible"
 HIVE2_COMPATIBLE_DEFAULT = False
 
+DEFAULT_LOCK_CHECK_MIN_WAIT_TIME = 2
+DEFAULT_LOCK_CHECK_MAX_WAIT_TIME = 30
+DEFAULT_LOCK_CHECK_RETRIES = 5
+DEFAULT_LOCK_CHECK_MULTIPLIER = 2

Review Comment:
   Hi @kevinjqliu. I don't think these should be grouped in `TableProperties`. [TableProperties](https://iceberg.apache.org/docs/nightly/configuration/#reserved-table-properties) controls the behavior of a specifc table while `CatalogProperties` controls the behavior of the catalog instance. In this case, these properties controls the behavior of HiveCatalog's Lock and thus should be classified as CatalogProperties.
   
   Currently, the convention is to put each catalog's properties in their own files. In this case, they can be in `hive.py`.
   Does this sound good to you? :)



-- 
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


Re: [PR] Hive catalog: Add retry logic for hive locking [iceberg-python]

Posted by "frankliee (via GitHub)" <gi...@apache.org>.
frankliee commented on code in PR #701:
URL: https://github.com/apache/iceberg-python/pull/701#discussion_r1591903957


##########
pyiceberg/catalog/hive.py:
##########
@@ -111,6 +122,13 @@
 HIVE2_COMPATIBLE = "hive.hive2-compatible"
 HIVE2_COMPATIBLE_DEFAULT = False
 
+DEFAULT_LOCK_CHECK_MIN_WAIT_TIME = 2
+DEFAULT_LOCK_CHECK_MAX_WAIT_TIME = 30
+DEFAULT_LOCK_CHECK_RETRIES = 5
+DEFAULT_LOCK_CHECK_MULTIPLIER = 2

Review Comment:
   You are right, I have see this setting comes from  HadoopConfiguration,  "CatalogProperties" seems more suitable.
   
   https://github.com/apache/hive/blob/1b0e9d9758a0f28c4baf7b1895bf96bf11252f73/iceberg/iceberg-catalog/src/main/java/org/apache/iceberg/hive/MetastoreLock.java#L62



-- 
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


Re: [PR] Hive catalog: Add retry logic for hive locking [iceberg-python]

Posted by "frankliee (via GitHub)" <gi...@apache.org>.
frankliee commented on code in PR #701:
URL: https://github.com/apache/iceberg-python/pull/701#discussion_r1591985541


##########
tests/integration/test_reads.py:
##########
@@ -506,3 +508,40 @@ def test_hive_locking(session_catalog_hive: HiveCatalog) -> None:
                 table.transaction().set_properties(lock="fail").commit_transaction()
         finally:
             open_client.unlock(UnlockRequest(lock.lockid))
+
+
+@pytest.mark.integration
+def test_hive_locking_with_retry(session_catalog_hive: HiveCatalog) -> None:
+    table = create_table(session_catalog_hive)
+    database_name: str
+    table_name: str
+    _, database_name, table_name = table.identifier
+
+    hive_client: _HiveClient = _HiveClient(session_catalog_hive.properties["uri"])
+
+    executor = ExecutorFactory.get_or_create()
+
+    with hive_client as open_client:
+
+        def another_task() -> None:
+            lock1: LockResponse = open_client.lock(session_catalog_hive._create_lock_request(database_name, table_name))
+            time.sleep(5)

Review Comment:
   I have added a new unit test  `test_hive_wait_for_lock` in test_hive.py that uses mocked  `lock` and `check_lock`.
   
   But I still keep an integration test based on the real hive metastore to simulate real-world cases.
   In order to reduce the test latency, I use fine-grained sleep time instead.
   
   WDYT?



-- 
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


Re: [PR] Hive catalog: Add retry logic for hive locking [iceberg-python]

Posted by "kevinjqliu (via GitHub)" <gi...@apache.org>.
kevinjqliu commented on code in PR #701:
URL: https://github.com/apache/iceberg-python/pull/701#discussion_r1590382950


##########
pyiceberg/catalog/hive.py:
##########
@@ -111,6 +122,13 @@
 HIVE2_COMPATIBLE = "hive.hive2-compatible"
 HIVE2_COMPATIBLE_DEFAULT = False
 
+DEFAULT_LOCK_CHECK_MIN_WAIT_TIME = 2
+DEFAULT_LOCK_CHECK_MAX_WAIT_TIME = 30
+DEFAULT_LOCK_CHECK_RETRIES = 5
+DEFAULT_LOCK_CHECK_MULTIPLIER = 2

Review Comment:
   wdyt about grouping these configs into TableProperties, along with their default value
   
   https://github.com/apache/iceberg-python/blob/7bd5d9e6c32bcc5b46993d6bfaeed50471e972ae/pyiceberg/table/__init__.py#L200
   



##########
tests/integration/test_reads.py:
##########
@@ -506,3 +508,40 @@ def test_hive_locking(session_catalog_hive: HiveCatalog) -> None:
                 table.transaction().set_properties(lock="fail").commit_transaction()
         finally:
             open_client.unlock(UnlockRequest(lock.lockid))
+
+
+@pytest.mark.integration
+def test_hive_locking_with_retry(session_catalog_hive: HiveCatalog) -> None:
+    table = create_table(session_catalog_hive)
+    database_name: str
+    table_name: str
+    _, database_name, table_name = table.identifier
+
+    hive_client: _HiveClient = _HiveClient(session_catalog_hive.properties["uri"])
+
+    executor = ExecutorFactory.get_or_create()
+
+    with hive_client as open_client:
+
+        def another_task() -> None:
+            lock1: LockResponse = open_client.lock(session_catalog_hive._create_lock_request(database_name, table_name))
+            time.sleep(5)

Review Comment:
   It might be easier to mock `lock` and `check_lock` functions instead of relying on the timing of the function calls



##########
tests/integration/test_reads.py:
##########
@@ -506,3 +508,40 @@ def test_hive_locking(session_catalog_hive: HiveCatalog) -> None:
                 table.transaction().set_properties(lock="fail").commit_transaction()
         finally:
             open_client.unlock(UnlockRequest(lock.lockid))
+
+
+@pytest.mark.integration
+def test_hive_locking_with_retry(session_catalog_hive: HiveCatalog) -> None:
+    table = create_table(session_catalog_hive)
+    database_name: str
+    table_name: str
+    _, database_name, table_name = table.identifier
+
+    hive_client: _HiveClient = _HiveClient(session_catalog_hive.properties["uri"])
+
+    executor = ExecutorFactory.get_or_create()
+
+    with hive_client as open_client:
+
+        def another_task() -> None:
+            lock1: LockResponse = open_client.lock(session_catalog_hive._create_lock_request(database_name, table_name))
+            time.sleep(5)

Review Comment:
   https://stackoverflow.com/questions/47906671/python-retry-with-tenacity-disable-wait-for-unittest
   
   This might be helpful to override the waiting behavior in retry



##########
tests/integration/test_reads.py:
##########
@@ -506,3 +508,40 @@ def test_hive_locking(session_catalog_hive: HiveCatalog) -> None:
                 table.transaction().set_properties(lock="fail").commit_transaction()
         finally:
             open_client.unlock(UnlockRequest(lock.lockid))
+
+
+@pytest.mark.integration
+def test_hive_locking_with_retry(session_catalog_hive: HiveCatalog) -> None:
+    table = create_table(session_catalog_hive)
+    database_name: str
+    table_name: str
+    _, database_name, table_name = table.identifier
+
+    hive_client: _HiveClient = _HiveClient(session_catalog_hive.properties["uri"])
+
+    executor = ExecutorFactory.get_or_create()
+
+    with hive_client as open_client:
+
+        def another_task() -> None:
+            lock1: LockResponse = open_client.lock(session_catalog_hive._create_lock_request(database_name, table_name))
+            time.sleep(5)

Review Comment:
   Also maybe add a test case for when `_wait_for_lock` failed to acquire locks after retry



##########
tests/integration/test_reads.py:
##########
@@ -506,3 +508,40 @@ def test_hive_locking(session_catalog_hive: HiveCatalog) -> None:
                 table.transaction().set_properties(lock="fail").commit_transaction()
         finally:
             open_client.unlock(UnlockRequest(lock.lockid))
+
+
+@pytest.mark.integration
+def test_hive_locking_with_retry(session_catalog_hive: HiveCatalog) -> None:
+    table = create_table(session_catalog_hive)
+    database_name: str
+    table_name: str
+    _, database_name, table_name = table.identifier
+
+    hive_client: _HiveClient = _HiveClient(session_catalog_hive.properties["uri"])
+
+    executor = ExecutorFactory.get_or_create()
+
+    with hive_client as open_client:
+
+        def another_task() -> None:
+            lock1: LockResponse = open_client.lock(session_catalog_hive._create_lock_request(database_name, table_name))
+            time.sleep(5)

Review Comment:
   nit: `time.sleep` in test is typically an anti-pattern, this will add at least 5 seconds to the test suite in the future. 
   
   



##########
pyiceberg/catalog/hive.py:
##########
@@ -356,6 +378,28 @@ def _create_lock_request(self, database_name: str, table_name: str) -> LockReque
 
         return lock_request
 
+    def _wait_for_lock(self, database_name: str, table_name: str, lockid: int, open_client: Client) -> LockResponse:
+        @retry(
+            retry=retry_if_exception_type(WaitingForLockException),
+            wait=wait_exponential(
+                multiplier=self._lock_check_multiplier, min=self._lock_check_min_wait_time, max=self._lock_check_max_wait_time
+            ),
+            stop=stop_after_attempt(self._lock_check_retries),
+            reraise=True,
+        )
+        def _do_wait_for_lock() -> LockResponse:
+            response: LockResponse = open_client.check_lock(CheckLockRequest(lockid=lockid))
+            if response.state == LockState.ACQUIRED:
+                return response
+            elif response.state == LockState.WAITING:
+                msg = f"Wait on lock for {database_name}:{table_name}"

Review Comment:
   nit: database_name.table_name 



-- 
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


Re: [PR] Hive catalog: Add retry logic for hive locking [iceberg-python]

Posted by "HonahX (via GitHub)" <gi...@apache.org>.
HonahX commented on code in PR #701:
URL: https://github.com/apache/iceberg-python/pull/701#discussion_r1591768312


##########
pyiceberg/catalog/hive.py:
##########
@@ -356,11 +371,46 @@ def _create_lock_request(self, database_name: str, table_name: str) -> LockReque
 
         return lock_request
 
-    def _commit_table(self, table_request: CommitTableRequest) -> CommitTableResponse:
+    def _wait_for_lock(
+        self, database_name: str, table_name: str, lockid: int, open_client: Client, properties: Properties
+    ) -> LockResponse:
+        acquire_lock_timeout = (
+            properties.get(TableProperties.HIVE_ACQUIRE_LOCK_TIMEOUT_MS, TableProperties.HIVE_ACQUIRE_LOCK_TIMEOUT_MS_DEFAULT)
+        ) / 1000.0
+        lock_check_min_wait_time = (
+            properties.get(TableProperties.HIVE_LOCK_CHECK_MIN_WAIT_MS, TableProperties.HIVE_LOCK_CHECK_MIN_WAIT_MS_DEFAULT)
+        ) / 1000.0
+        lock_check_max_wait_time = (
+            properties.get(TableProperties.HIVE_LOCK_CHECK_MAX_WAIT_MS, TableProperties.HIVE_LOCK_CHECK_MAX_WAIT_MS_DEFAULT)
+        ) / 1000.0

Review Comment:
   We could use [`PropertyUtil.property_as_int`](https://github.com/apache/iceberg-python/blob/d872245f143b919b25fda90a7b7c7fb0729a402a/pyiceberg/table/__init__.py#L243-L258) to get the values. This utl methods throws error message when failing to parse the property.
   
   BTW: You would properly need `#type: ignore` at the end of each `PropertyUti.property_as_int` to pass the linter.



##########
pyiceberg/catalog/hive.py:
##########
@@ -111,6 +122,13 @@
 HIVE2_COMPATIBLE = "hive.hive2-compatible"
 HIVE2_COMPATIBLE_DEFAULT = False
 
+DEFAULT_LOCK_CHECK_MIN_WAIT_TIME = 2
+DEFAULT_LOCK_CHECK_MAX_WAIT_TIME = 30
+DEFAULT_LOCK_CHECK_RETRIES = 5
+DEFAULT_LOCK_CHECK_MULTIPLIER = 2

Review Comment:
   In java, they are in the [`HadoopConfiguration`](https://iceberg.apache.org/docs/nightly/configuration/#hadoop-configuration). The hadoop configuration for a hive catalog is set at the catalog-level:
   https://github.com/apache/iceberg/blob/817a5e1be1616af77329965ac3742c14ca3ae116/hive-metastore/src/main/java/org/apache/iceberg/hive/HiveCatalog.java#L630
   
   [Metastore parse these properties from the hadoop configuration](https://github.com/apache/iceberg/blob/e10453a10d3f9237032ba7e649808347c699f6a2/hive-metastore/src/main/java/org/apache/iceberg/hive/MetastoreLock.java#L110-L125)
   
   I call them "CatalogProperties" since pyiceberg does not have hadoop configuration. Sorry if that creates any confusion.
   
   The only hive-lock-related config in `TableProperties` is [`engine.hive.lock-enabled`](https://github.com/apache/iceberg/blob/e7999a194dc0f32fba8fb515c9108764ed6ba6b5/core/src/main/java/org/apache/iceberg/TableProperties.java#L319) which can enable/disable lock for a single table. But that is for https://issues.apache.org/jira/browse/HIVE-26882, see the "warn" section in the end of https://iceberg.apache.org/docs/nightly/configuration/#hadoop-configuration. I don't think we need that in pyiceberg now.
   
   WDYT?



-- 
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


Re: [PR] Hive catalog: Add retry logic for hive locking [iceberg-python]

Posted by "Fokko (via GitHub)" <gi...@apache.org>.
Fokko commented on code in PR #701:
URL: https://github.com/apache/iceberg-python/pull/701#discussion_r1594699293


##########
pyiceberg/catalog/hive.py:
##########
@@ -111,6 +122,15 @@
 HIVE2_COMPATIBLE = "hive.hive2-compatible"
 HIVE2_COMPATIBLE_DEFAULT = False
 
+LOCK_CHECK_MIN_WAIT_TIME = "lock_check_min_wait_time"
+LOCK_CHECK_MAX_WAIT_TIME = "lock_check_max_wait_time"
+LOCK_CHECK_RETRIES = "lock_check_retries"
+DEFAULT_LOCK_CHECK_MIN_WAIT_TIME = 2
+DEFAULT_LOCK_CHECK_MAX_WAIT_TIME = 30
+DEFAULT_LOCK_CHECK_RETRIES = 10

Review Comment:
   Should we align these properties with Java:
   
   <img width="718" alt="image" src="https://github.com/apache/iceberg-python/assets/1134248/700d7689-4b70-4848-960d-6bd0fe1d8810">
   https://iceberg.apache.org/docs/nightly/configuration/#write-properties



-- 
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


Re: [PR] Hive catalog: Add retry logic for hive locking [iceberg-python]

Posted by "HonahX (via GitHub)" <gi...@apache.org>.
HonahX commented on code in PR #701:
URL: https://github.com/apache/iceberg-python/pull/701#discussion_r1591782640


##########
pyiceberg/catalog/hive.py:
##########
@@ -111,6 +122,13 @@
 HIVE2_COMPATIBLE = "hive.hive2-compatible"
 HIVE2_COMPATIBLE_DEFAULT = False
 
+DEFAULT_LOCK_CHECK_MIN_WAIT_TIME = 2
+DEFAULT_LOCK_CHECK_MAX_WAIT_TIME = 30
+DEFAULT_LOCK_CHECK_RETRIES = 5
+DEFAULT_LOCK_CHECK_MULTIPLIER = 2

Review Comment:
   In java, they are in the [`HadoopConfiguration`](https://iceberg.apache.org/docs/nightly/configuration/#hadoop-configuration). The hadoop configuration for a hive catalog is set at the catalog-level:
   https://github.com/apache/iceberg/blob/817a5e1be1616af77329965ac3742c14ca3ae116/hive-metastore/src/main/java/org/apache/iceberg/hive/HiveCatalog.java#L630
   
   [Metastore parse these properties from the hadoop configuration](https://github.com/apache/iceberg/blob/e10453a10d3f9237032ba7e649808347c699f6a2/hive-metastore/src/main/java/org/apache/iceberg/hive/MetastoreLock.java#L110-L125)
   
   I call them "CatalogProperties" since pyiceberg does not have hadoop configuration. Sorry if that creates any confusion. 
   
   The only hive-lock-related config in `TableProperties` is [`engine.hive.lock-enabled`](https://github.com/apache/iceberg/blob/e7999a194dc0f32fba8fb515c9108764ed6ba6b5/core/src/main/java/org/apache/iceberg/TableProperties.java#L319) which can enable/disable lock for a single table. But that is for https://issues.apache.org/jira/browse/HIVE-26882, see the "warn" section in the end of https://iceberg.apache.org/docs/nightly/configuration/#hadoop-configuration. I don't think we need that in pyiceberg now.
   
   WDYT?



-- 
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


Re: [PR] Hive catalog: Add retry logic for hive locking [iceberg-python]

Posted by "frankliee (via GitHub)" <gi...@apache.org>.
frankliee commented on code in PR #701:
URL: https://github.com/apache/iceberg-python/pull/701#discussion_r1591771902


##########
pyiceberg/catalog/hive.py:
##########
@@ -111,6 +122,13 @@
 HIVE2_COMPATIBLE = "hive.hive2-compatible"
 HIVE2_COMPATIBLE_DEFAULT = False
 
+DEFAULT_LOCK_CHECK_MIN_WAIT_TIME = 2
+DEFAULT_LOCK_CHECK_MAX_WAIT_TIME = 30
+DEFAULT_LOCK_CHECK_RETRIES = 5
+DEFAULT_LOCK_CHECK_MULTIPLIER = 2

Review Comment:
   In Iceberg-Java, these props are in TableProperties like that.
   
   ```
   iceberg.hive.lock-check-min-wait-ms=xxx
   iceberg.hive.lock-check-max-wait-ms=xxx
   iceberg.hive.lock-timeout-ms=xxx
   ```
   
   So, it is better to unify this setting?
   
   
   
   



-- 
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


Re: [PR] Hive catalog: Add retry logic for hive locking [iceberg-python]

Posted by "frankliee (via GitHub)" <gi...@apache.org>.
frankliee commented on code in PR #701:
URL: https://github.com/apache/iceberg-python/pull/701#discussion_r1592047115


##########
pyiceberg/catalog/hive.py:
##########
@@ -356,11 +371,46 @@ def _create_lock_request(self, database_name: str, table_name: str) -> LockReque
 
         return lock_request
 
-    def _commit_table(self, table_request: CommitTableRequest) -> CommitTableResponse:
+    def _wait_for_lock(
+        self, database_name: str, table_name: str, lockid: int, open_client: Client, properties: Properties
+    ) -> LockResponse:
+        acquire_lock_timeout = (
+            properties.get(TableProperties.HIVE_ACQUIRE_LOCK_TIMEOUT_MS, TableProperties.HIVE_ACQUIRE_LOCK_TIMEOUT_MS_DEFAULT)
+        ) / 1000.0
+        lock_check_min_wait_time = (
+            properties.get(TableProperties.HIVE_LOCK_CHECK_MIN_WAIT_MS, TableProperties.HIVE_LOCK_CHECK_MIN_WAIT_MS_DEFAULT)
+        ) / 1000.0
+        lock_check_max_wait_time = (
+            properties.get(TableProperties.HIVE_LOCK_CHECK_MAX_WAIT_MS, TableProperties.HIVE_LOCK_CHECK_MAX_WAIT_MS_DEFAULT)
+        ) / 1000.0

Review Comment:
   I have added `property_as_float` to allow fine-grained control.



-- 
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


Re: [PR] Hive catalog: Add retry logic for hive locking [iceberg-python]

Posted by "frankliee (via GitHub)" <gi...@apache.org>.
frankliee commented on code in PR #701:
URL: https://github.com/apache/iceberg-python/pull/701#discussion_r1592047115


##########
pyiceberg/catalog/hive.py:
##########
@@ -356,11 +371,46 @@ def _create_lock_request(self, database_name: str, table_name: str) -> LockReque
 
         return lock_request
 
-    def _commit_table(self, table_request: CommitTableRequest) -> CommitTableResponse:
+    def _wait_for_lock(
+        self, database_name: str, table_name: str, lockid: int, open_client: Client, properties: Properties
+    ) -> LockResponse:
+        acquire_lock_timeout = (
+            properties.get(TableProperties.HIVE_ACQUIRE_LOCK_TIMEOUT_MS, TableProperties.HIVE_ACQUIRE_LOCK_TIMEOUT_MS_DEFAULT)
+        ) / 1000.0
+        lock_check_min_wait_time = (
+            properties.get(TableProperties.HIVE_LOCK_CHECK_MIN_WAIT_MS, TableProperties.HIVE_LOCK_CHECK_MIN_WAIT_MS_DEFAULT)
+        ) / 1000.0
+        lock_check_max_wait_time = (
+            properties.get(TableProperties.HIVE_LOCK_CHECK_MAX_WAIT_MS, TableProperties.HIVE_LOCK_CHECK_MAX_WAIT_MS_DEFAULT)
+        ) / 1000.0

Review Comment:
   I have added `property_as_float` to allow fine-grained setting.



-- 
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