empiredan commented on code in PR #2387:
URL: 
https://github.com/apache/incubator-pegasus/pull/2387#discussion_r3032010190


##########
src/replica/replica_2pc.cpp:
##########
@@ -183,7 +183,18 @@ void replica::on_client_write(dsn::message_ex *request, 
bool ignore_throttling)
 
     if (FLAGS_reject_write_when_disk_insufficient &&
         (_dir_node->status != disk_status::NORMAL || 
_primary_states.secondary_disk_abnormal())) {

Review Comment:
   ```suggestion
       if (FLAGS_reject_write_when_disk_insufficient) {
   ```



##########
src/replica/replica_2pc.cpp:
##########
@@ -183,7 +183,18 @@ void replica::on_client_write(dsn::message_ex *request, 
bool ignore_throttling)
 
     if (FLAGS_reject_write_when_disk_insufficient &&
         (_dir_node->status != disk_status::NORMAL || 
_primary_states.secondary_disk_abnormal())) {
-        response_client_write(request, 
disk_status_to_error_code(_dir_node->status));
+        if (_dir_node->status != disk_status::NORMAL) {
+            // Primary replica disk is abnormal, return the corresponding 
error code
+            response_client_write(request, 
disk_status_to_error_code(_dir_node->status));
+        } else {
+            // Secondary replica disk is abnormal but primary is OK
+            for (const auto &kv : _primary_states.secondary_disk_status) {
+                if (kv.second != disk_status::NORMAL) {
+                    response_client_write(request, 
disk_status_to_error_code(kv.second));
+                    break;
+                }
+            }
+        }
         return;

Review Comment:
   ```suggestion
   ```



##########
src/replica/replica_2pc.cpp:
##########
@@ -183,7 +183,18 @@ void replica::on_client_write(dsn::message_ex *request, 
bool ignore_throttling)
 
     if (FLAGS_reject_write_when_disk_insufficient &&
         (_dir_node->status != disk_status::NORMAL || 
_primary_states.secondary_disk_abnormal())) {
-        response_client_write(request, 
disk_status_to_error_code(_dir_node->status));
+        if (_dir_node->status != disk_status::NORMAL) {
+            // Primary replica disk is abnormal, return the corresponding 
error code
+            response_client_write(request, 
disk_status_to_error_code(_dir_node->status));
+        } else {
+            // Secondary replica disk is abnormal but primary is OK
+            for (const auto &kv : _primary_states.secondary_disk_status) {
+                if (kv.second != disk_status::NORMAL) {
+                    response_client_write(request, 
disk_status_to_error_code(kv.second));
+                    break;
+                }
+            }

Review Comment:
   ```suggestion
               for (const auto &[addr, secondary_status] : 
_primary_states.secondary_disk_status) {
                   if (secondary_status != disk_status::NORMAL) {
                       LOG_INFO("partition[{}] secondary[{}] disk space is {}",
                                           _primary_states.pc.pid,
                                           addr,
                                           enum_to_string(secondary_status));   
                 
                       response_client_write(request, 
disk_status_to_error_code(secondary_status));
                       return;
                   }
               }
   ```



##########
src/replica/replica_2pc.cpp:
##########
@@ -183,7 +183,18 @@ void replica::on_client_write(dsn::message_ex *request, 
bool ignore_throttling)
 
     if (FLAGS_reject_write_when_disk_insufficient &&
         (_dir_node->status != disk_status::NORMAL || 
_primary_states.secondary_disk_abnormal())) {
-        response_client_write(request, 
disk_status_to_error_code(_dir_node->status));
+        if (_dir_node->status != disk_status::NORMAL) {
+            // Primary replica disk is abnormal, return the corresponding 
error code
+            response_client_write(request, 
disk_status_to_error_code(_dir_node->status));

Review Comment:
   ```suggestion
               response_client_write(request, 
disk_status_to_error_code(_dir_node->status));
               return;
   ```



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to