Skip to content

Commit 9efa595

Browse files
committed
fix(replica): fix incorrect error code when secondary replica disk status is abnormal
1 parent db756dc commit 9efa595

4 files changed

Lines changed: 18 additions & 1 deletion

File tree

java-client/src/main/java/org/apache/pegasus/base/error_code.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ public enum error_types {
124124
ERR_PARENT_PARTITION_MISUSED,
125125
ERR_CHILD_NOT_READY,
126126
ERR_DISK_INSUFFICIENT,
127+
ERR_DISK_IO_ERROR,
128+
ERR_SECONDARY_DISK_ABNORMAL,
127129

128130
// ERROR_CODE defined by client
129131
ERR_SESSION_RESET,

java-client/src/main/java/org/apache/pegasus/client/PegasusTable.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2258,6 +2258,13 @@ public void handleReplicaException(
22582258
case ERR_DISK_INSUFFICIENT:
22592259
message = " The replica server disk space is insufficient";
22602260
break;
2261+
case ERR_DISK_IO_ERROR:
2262+
message = " The replica server disk I/O error";
2263+
break;
2264+
case ERR_SECONDARY_DISK_ABNORMAL:
2265+
message =
2266+
" Write rejected: secondary replica disk is abnormal (insufficient space or I/O error)";
2267+
break;
22612268
default:
22622269
message = " Unknown error!";
22632270
break;

src/replica/replica_2pc.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,13 @@ void replica::on_client_write(dsn::message_ex *request, bool ignore_throttling)
183183

184184
if (FLAGS_reject_write_when_disk_insufficient &&
185185
(_dir_node->status != disk_status::NORMAL || _primary_states.secondary_disk_abnormal())) {
186-
response_client_write(request, disk_status_to_error_code(_dir_node->status));
186+
if (_dir_node->status != disk_status::NORMAL) {
187+
// Primary replica disk is abnormal, return the corresponding error code
188+
response_client_write(request, disk_status_to_error_code(_dir_node->status));
189+
} else {
190+
// Secondary replica disk is abnormal but primary is OK
191+
response_client_write(request, ERR_SECONDARY_DISK_ABNORMAL);
192+
}
187193
return;
188194
}
189195

src/utils/error_code.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ DEFINE_ERR_CODE(ERR_HTTP_ERROR)
189189

190190
DEFINE_ERR_CODE(ERR_NOT_MATCHED)
191191

192+
DEFINE_ERR_CODE(ERR_SECONDARY_DISK_ABNORMAL)
193+
192194
} // namespace dsn
193195

194196
USER_DEFINED_STRUCTURE_FORMATTER(::dsn::error_code);

0 commit comments

Comments
 (0)