ArafatKhan2198 commented on code in PR #7149:
URL: https://github.com/apache/ozone/pull/7149#discussion_r1753513700
##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/fsck/ContainerHealthTask.java:
##########
@@ -273,34 +279,41 @@ private long processExistingDBRecords(long currentTime,
recordCount++;
UnhealthyContainersRecord rec = cursor.fetchNext();
try {
+ // Set the current container if it's not already set
if (currentContainer == null) {
currentContainer = setCurrentContainer(rec.getContainerId());
}
+ // If the container ID has changed, finish processing the previous
one
if (currentContainer.getContainerID() != rec.getContainerId()) {
completeProcessingContainer(
currentContainer, existingRecords, currentTime,
unhealthyContainerStateCountMap);
existingRecords.clear();
currentContainer = setCurrentContainer(rec.getContainerId());
}
- if (ContainerHealthRecords
- .retainOrUpdateRecord(currentContainer, rec
- )) {
- // Check if the missing container is deleted in SCM
- if (currentContainer.isMissing() &&
- containerDeletedInSCM(currentContainer.getContainer())) {
- rec.delete();
- }
- existingRecords.add(rec.getContainerState());
- if (rec.changed()) {
- rec.update();
- }
- } else {
+
+ // Unhealthy Containers such as MISSING, UNDER_REPLICATED,
+ // OVER_REPLICATED, MIS_REPLICATED can have their unhealthy states
changed or retained.
+ if (!ContainerHealthRecords.retainOrUpdateRecord(currentContainer,
rec)) {
+ rec.delete();
LOG.info("DELETED existing unhealthy container record...for
Container: {}",
currentContainer.getContainerID());
+ }
+
+ // If the container is marked as MISSING and it's deleted in SCM,
remove the record
+ if (currentContainer.isMissing() &&
containerDeletedInSCM(currentContainer.getContainer())) {
rec.delete();
+ LOG.info("DELETED existing unhealthy container record...for
Container: {}",
+ currentContainer.getContainerID());
+ }
+
+ existingRecords.add(rec.getContainerState());
+ // If the record was changed, update it
+ if (rec.changed()) {
Review Comment:
This is what I understand :-
`rec.delete()`: This method directly deletes the record from the database by
issuing a SQL DELETE statement. It doesn’t modify the record's fields or mark
them as "changed." Instead, it removes the corresponding row from the database.
Once deleted, the record is no longer considered part of the database, and
calling rec.changed() afterward would not make sense because there is no row
left to update.
`rec.changed()`: This method is used to detect whether any fields in the
record have been modified since it was fetched or created. Jooq internally
tracks changes to the record fields (e.g., setReplicaDelta(),
setContainerState()), and if any field has been modified, rec.changed() will
return true. This helps Jooq decide whether an UPDATE query needs to be sent to
the database when rec.update() is called.
In jOOQ, when you call rec.delete(), it removes the record from the
database, and this operation is executed independently of the rec.changed()
flag. The changed() method in jOOQ is generally used to determine if any fields
in the record have been modified, and it's primarily for UPDATE operations.
When a record is deleted using delete(), jOOQ executes a DELETE statement, and
this does not affect the record's changed() state.
But I will verify this once by testing.
cc: @devmadhuu
--
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]