diff --git a/be/src/common/config.cpp b/be/src/common/config.cpp index c836bd3fb33c47..3cbbd033e0d26e 100644 --- a/be/src/common/config.cpp +++ b/be/src/common/config.cpp @@ -484,6 +484,8 @@ DEFINE_mInt32(migration_remaining_size_threshold_mb, "10"); // If the task runs longer than this time, the task will be terminated, in seconds. // timeout = std::max(migration_task_timeout_secs, tablet size / 1MB/s) DEFINE_mInt32(migration_task_timeout_secs, "300"); +// timeout for try_lock migration lock +DEFINE_Int64(migration_lock_timeout_ms, "1000"); // Port to start debug webserver on DEFINE_Int32(webserver_port, "8040"); diff --git a/be/src/common/config.h b/be/src/common/config.h index 8860e40b7ef874..a6a35447bb5c5a 100644 --- a/be/src/common/config.h +++ b/be/src/common/config.h @@ -534,6 +534,8 @@ DECLARE_mInt32(migration_remaining_size_threshold_mb); // If the task runs longer than this time, the task will be terminated, in seconds. // timeout = std::max(migration_task_timeout_secs, tablet size / 1MB/s) DECLARE_mInt32(migration_task_timeout_secs); +// timeout for try_lock migration lock +DECLARE_Int64(migration_lock_timeout_ms); // Port to start debug webserver on DECLARE_Int32(webserver_port); diff --git a/be/src/olap/rowset_builder.cpp b/be/src/olap/rowset_builder.cpp index 2fc3d58b49141c..93058c05be332f 100644 --- a/be/src/olap/rowset_builder.cpp +++ b/be/src/olap/rowset_builder.cpp @@ -170,8 +170,10 @@ Status RowsetBuilder::check_tablet_version_count() { Status RowsetBuilder::prepare_txn() { std::shared_lock base_migration_lock(tablet()->get_migration_lock(), std::defer_lock); - if (!base_migration_lock.try_lock_for(std::chrono::milliseconds(30))) { - return Status::Error("try migration lock failed"); + if (!base_migration_lock.try_lock_for( + std::chrono::milliseconds(config::migration_lock_timeout_ms))) { + return Status::Error("try_lock migration lock failed after {}ms", + config::migration_lock_timeout_ms); } std::lock_guard push_lock(tablet()->get_push_lock()); return _engine.txn_manager()->prepare_txn(_req.partition_id, *tablet(), _req.txn_id,