From 2980e8a8d9c78b393ca4bd94ec545b4caa386a4c Mon Sep 17 00:00:00 2001 From: Stephen Sun Date: Wed, 16 Jun 2021 08:52:24 +0000 Subject: [PATCH 1/2] Don't call SAI API for BUFFER_POOL/PROFILE handling in case the op is DEL and the SAI OID is NULL There is an optimization on orch: the SET event will be replaced by a DEL event if it is still pending in m_toSync when the DEL event is coming. This is reasonable but can cause the SAI OID be NULL in rare case: - The application creates an object and then destroy it after a very short period - The create notification is eliminated and replaced by destroy notification - The SAI object hasn't been created and is NULL when it is removed This causes SAI error which eventually makes orchagent exit. We need to avoid it in 202106 and above (In 202012, the orchagent won't exit so it's ok to ignore the error) The solution is not to call SAI removing interface in case SAI OID is NULL It can happen if a user configures something which causes the accumulative headroom exceeds the limit. In this case, the buffer profile was created and then removed in a short time. Signed-off-by: Stephen Sun --- orchagent/bufferorch.cpp | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/orchagent/bufferorch.cpp b/orchagent/bufferorch.cpp index f44b90f96c..c52eb9e3d6 100644 --- a/orchagent/bufferorch.cpp +++ b/orchagent/bufferorch.cpp @@ -416,14 +416,17 @@ task_process_status BufferOrch::processBufferPool(KeyOpFieldsValuesTuple &tuple) return task_process_status::task_need_retry; } - sai_status = sai_buffer_api->remove_buffer_pool(sai_object); - if (SAI_STATUS_SUCCESS != sai_status) + if (SAI_NULL_OBJECT_ID == sai_object) { - SWSS_LOG_ERROR("Failed to remove buffer pool %s with type %s, rv:%d", object_name.c_str(), map_type_name.c_str(), sai_status); - task_process_status handle_status = handleSaiRemoveStatus(SAI_API_BUFFER, sai_status); - if (handle_status != task_process_status::task_success) + sai_status = sai_buffer_api->remove_buffer_pool(sai_object); + if (SAI_STATUS_SUCCESS != sai_status) { - return handle_status; + SWSS_LOG_ERROR("Failed to remove buffer pool %s with type %s, rv:%d", object_name.c_str(), map_type_name.c_str(), sai_status); + task_process_status handle_status = handleSaiRemoveStatus(SAI_API_BUFFER, sai_status); + if (handle_status != task_process_status::task_success) + { + return handle_status; + } } } SWSS_LOG_NOTICE("Removed buffer pool %s with type %s", object_name.c_str(), map_type_name.c_str()); @@ -615,14 +618,17 @@ task_process_status BufferOrch::processBufferProfile(KeyOpFieldsValuesTuple &tup return task_process_status::task_need_retry; } - sai_status = sai_buffer_api->remove_buffer_profile(sai_object); - if (SAI_STATUS_SUCCESS != sai_status) + if (SAI_NULL_OBJECT_ID != sai_object) { - SWSS_LOG_ERROR("Failed to remove buffer profile %s with type %s, rv:%d", object_name.c_str(), map_type_name.c_str(), sai_status); - task_process_status handle_status = handleSaiRemoveStatus(SAI_API_BUFFER, sai_status); - if (handle_status != task_process_status::task_success) + sai_status = sai_buffer_api->remove_buffer_profile(sai_object); + if (SAI_STATUS_SUCCESS != sai_status) { - return handle_status; + SWSS_LOG_ERROR("Failed to remove buffer profile %s with type %s, rv:%d", object_name.c_str(), map_type_name.c_str(), sai_status); + task_process_status handle_status = handleSaiRemoveStatus(SAI_API_BUFFER, sai_status); + if (handle_status != task_process_status::task_success) + { + return handle_status; + } } } From 2c3086397575e5efc0b2d4ba46871fd1876b6102 Mon Sep 17 00:00:00 2001 From: Stephen Sun Date: Fri, 18 Jun 2021 00:03:21 +0000 Subject: [PATCH 2/2] Fix typo Signed-off-by: Stephen Sun --- orchagent/bufferorch.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/orchagent/bufferorch.cpp b/orchagent/bufferorch.cpp index c52eb9e3d6..e7037ad665 100644 --- a/orchagent/bufferorch.cpp +++ b/orchagent/bufferorch.cpp @@ -416,7 +416,7 @@ task_process_status BufferOrch::processBufferPool(KeyOpFieldsValuesTuple &tuple) return task_process_status::task_need_retry; } - if (SAI_NULL_OBJECT_ID == sai_object) + if (SAI_NULL_OBJECT_ID != sai_object) { sai_status = sai_buffer_api->remove_buffer_pool(sai_object); if (SAI_STATUS_SUCCESS != sai_status)