You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-dev@jackrabbit.apache.org by "lweitzendorf (via GitHub)" <gi...@apache.org> on 2024/12/10 09:17:38 UTC

[PR] OAK-11299: Missing Segments With Oak Run Segment Copy [jackrabbit-oak]

lweitzendorf opened a new pull request, #1892:
URL: https://github.com/apache/jackrabbit-oak/pull/1892

   (no comment)


-- 
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: oak-dev-unsubscribe@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] OAK-11299: Missing Segments With Oak Run Segment Copy [jackrabbit-oak]

Posted by "mreutegg (via GitHub)" <gi...@apache.org>.
mreutegg merged PR #1892:
URL: https://github.com/apache/jackrabbit-oak/pull/1892


-- 
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: oak-dev-unsubscribe@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] OAK-11299: Missing Segments With Oak Run Segment Copy [jackrabbit-oak]

Posted by "mreutegg (via GitHub)" <gi...@apache.org>.
mreutegg commented on code in PR #1892:
URL: https://github.com/apache/jackrabbit-oak/pull/1892#discussion_r2212878500


##########
oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/tool/SegmentStoreMigrator.java:
##########
@@ -162,9 +162,13 @@ private void migrateArchives() throws IOException, ExecutionException, Interrupt
         List<String> targetArchives = targetManager.listArchives();
 
         if (appendMode && !targetArchives.isEmpty()) {
-            //last archive can be updated since last copy and needs to be recopied
-            String lastArchive = targetArchives.get(targetArchives.size() - 1);
-            targetArchives.remove(lastArchive);
+            // last archive could have been updated since last copy and needs to be recopied
+            try {
+                targetArchives.sort(String::compareTo);
+                targetArchives.remove(targetArchives.size() - 1);
+            } catch (UnsupportedOperationException e) {

Review Comment:
   > But more generally, yes the list may be fully immutable or some other type that doesn't allow resizing. Why copy it into an ArrayList instead of just always using subList for example?
   
   Getting a sub list from an immutable list should work, but SegmentStoreMigrator also sorts the list and that is not possible when the list is immutable.



-- 
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: oak-dev-unsubscribe@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] OAK-11299: Missing Segments With Oak Run Segment Copy [jackrabbit-oak]

Posted by "mreutegg (via GitHub)" <gi...@apache.org>.
mreutegg commented on code in PR #1892:
URL: https://github.com/apache/jackrabbit-oak/pull/1892#discussion_r2209451113


##########
oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/tool/SegmentStoreMigrator.java:
##########
@@ -162,9 +162,13 @@ private void migrateArchives() throws IOException, ExecutionException, Interrupt
         List<String> targetArchives = targetManager.listArchives();
 
         if (appendMode && !targetArchives.isEmpty()) {
-            //last archive can be updated since last copy and needs to be recopied
-            String lastArchive = targetArchives.get(targetArchives.size() - 1);
-            targetArchives.remove(lastArchive);
+            // last archive could have been updated since last copy and needs to be recopied
+            try {
+                targetArchives.sort(String::compareTo);
+                targetArchives.remove(targetArchives.size() - 1);
+            } catch (UnsupportedOperationException e) {

Review Comment:
   I assume UnsupportedOperationException is caught here because the List returned by targetManager.listArchives() may be immutable. I would rather copy the returned archive names in a new ArrayList.



-- 
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: oak-dev-unsubscribe@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] OAK-11299: Missing Segments With Oak Run Segment Copy [jackrabbit-oak]

Posted by "mreutegg (via GitHub)" <gi...@apache.org>.
mreutegg commented on code in PR #1892:
URL: https://github.com/apache/jackrabbit-oak/pull/1892#discussion_r2213124405


##########
oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/tool/SegmentStoreMigrator.java:
##########
@@ -162,9 +162,13 @@ private void migrateArchives() throws IOException, ExecutionException, Interrupt
         List<String> targetArchives = targetManager.listArchives();
 
         if (appendMode && !targetArchives.isEmpty()) {
-            //last archive can be updated since last copy and needs to be recopied
-            String lastArchive = targetArchives.get(targetArchives.size() - 1);
-            targetArchives.remove(lastArchive);
+            // last archive could have been updated since last copy and needs to be recopied
+            try {
+                targetArchives.sort(String::compareTo);
+                targetArchives.remove(targetArchives.size() - 1);
+            } catch (UnsupportedOperationException e) {

Review Comment:
   There is also similar code in `AwsSegmentStoreMigrator` that needs the same fix: https://github.com/apache/jackrabbit-oak/blob/69ee5b5034275b981943b8eec871c27def94cb24/oak-segment-aws/src/main/java/org/apache/jackrabbit/oak/segment/aws/tool/AwsSegmentStoreMigrator.java#L157-L161



-- 
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: oak-dev-unsubscribe@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] OAK-11299: Missing Segments With Oak Run Segment Copy [jackrabbit-oak]

Posted by "mreutegg (via GitHub)" <gi...@apache.org>.
mreutegg commented on code in PR #1892:
URL: https://github.com/apache/jackrabbit-oak/pull/1892#discussion_r2209451113


##########
oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/tool/SegmentStoreMigrator.java:
##########
@@ -162,9 +162,13 @@ private void migrateArchives() throws IOException, ExecutionException, Interrupt
         List<String> targetArchives = targetManager.listArchives();
 
         if (appendMode && !targetArchives.isEmpty()) {
-            //last archive can be updated since last copy and needs to be recopied
-            String lastArchive = targetArchives.get(targetArchives.size() - 1);
-            targetArchives.remove(lastArchive);
+            // last archive could have been updated since last copy and needs to be recopied
+            try {
+                targetArchives.sort(String::compareTo);
+                targetArchives.remove(targetArchives.size() - 1);
+            } catch (UnsupportedOperationException e) {

Review Comment:
   I assume `UnsupportedOperationException` is caught here because the `List` returned by `targetManager.listArchives()` may be immutable. I would rather copy the returned archive names in a new `ArrayList`.



-- 
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: oak-dev-unsubscribe@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] OAK-11299: Missing Segments With Oak Run Segment Copy [jackrabbit-oak]

Posted by "lweitzendorf (via GitHub)" <gi...@apache.org>.
lweitzendorf commented on code in PR #1892:
URL: https://github.com/apache/jackrabbit-oak/pull/1892#discussion_r2213457407


##########
oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/tool/SegmentStoreMigrator.java:
##########
@@ -162,9 +162,13 @@ private void migrateArchives() throws IOException, ExecutionException, Interrupt
         List<String> targetArchives = targetManager.listArchives();
 
         if (appendMode && !targetArchives.isEmpty()) {
-            //last archive can be updated since last copy and needs to be recopied
-            String lastArchive = targetArchives.get(targetArchives.size() - 1);
-            targetArchives.remove(lastArchive);
+            // last archive could have been updated since last copy and needs to be recopied
+            try {
+                targetArchives.sort(String::compareTo);
+                targetArchives.remove(targetArchives.size() - 1);
+            } catch (UnsupportedOperationException e) {

Review Comment:
   They share a lot of code in general. Pulling the common logic out into a base class for both might be a good option.



-- 
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: oak-dev-unsubscribe@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] OAK-11299: Missing Segments With Oak Run Segment Copy [jackrabbit-oak]

Posted by "mreutegg (via GitHub)" <gi...@apache.org>.
mreutegg commented on code in PR #1892:
URL: https://github.com/apache/jackrabbit-oak/pull/1892#discussion_r2235760943


##########
oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/tool/SegmentStoreMigrator.java:
##########
@@ -162,9 +162,13 @@ private void migrateArchives() throws IOException, ExecutionException, Interrupt
         List<String> targetArchives = targetManager.listArchives();
 
         if (appendMode && !targetArchives.isEmpty()) {
-            //last archive can be updated since last copy and needs to be recopied
-            String lastArchive = targetArchives.get(targetArchives.size() - 1);
-            targetArchives.remove(lastArchive);
+            // last archive could have been updated since last copy and needs to be recopied
+            try {
+                targetArchives.sort(String::compareTo);
+                targetArchives.remove(targetArchives.size() - 1);
+            } catch (UnsupportedOperationException e) {

Review Comment:
   This PR is now pretty big and includes quite some refactoring. Can you please split the changes into what is necessary to fix OAK-11299 and a new issue that covers the refactoring that is not essential for OAK-11299?



-- 
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: oak-dev-unsubscribe@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] OAK-11299: Missing Segments With Oak Run Segment Copy [jackrabbit-oak]

Posted by "mreutegg (via GitHub)" <gi...@apache.org>.
mreutegg commented on code in PR #1892:
URL: https://github.com/apache/jackrabbit-oak/pull/1892#discussion_r2236672616


##########
oak-segment-remote/src/main/java/org/apache/jackrabbit/oak/segment/remote/RemoteUtilities.java:
##########
@@ -50,4 +51,17 @@ public static UUID getSegmentUUID(@NotNull String segmentFileName) {
         }
         return UUID.fromString(m.group(2));
     }
+
+    public static class ArchiveIndexComparator implements Comparator<String> {

Review Comment:
   Looks good. Though, I would not expose the inner class. You could make it private and available as a public static field of type `Comparator<String>`.
   ```
       public static final Comparator<String> ARCHIVE_INDEX_COMPARATOR = new ArchiveIndexComparator();
   ```



-- 
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: oak-dev-unsubscribe@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] OAK-11299: Missing Segments With Oak Run Segment Copy [jackrabbit-oak]

Posted by "mreutegg (via GitHub)" <gi...@apache.org>.
mreutegg commented on code in PR #1892:
URL: https://github.com/apache/jackrabbit-oak/pull/1892#discussion_r2213139588


##########
oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/tool/SegmentStoreMigrator.java:
##########
@@ -162,9 +162,13 @@ private void migrateArchives() throws IOException, ExecutionException, Interrupt
         List<String> targetArchives = targetManager.listArchives();
 
         if (appendMode && !targetArchives.isEmpty()) {
-            //last archive can be updated since last copy and needs to be recopied
-            String lastArchive = targetArchives.get(targetArchives.size() - 1);
-            targetArchives.remove(lastArchive);
+            // last archive could have been updated since last copy and needs to be recopied
+            try {
+                targetArchives.sort(String::compareTo);
+                targetArchives.remove(targetArchives.size() - 1);
+            } catch (UnsupportedOperationException e) {

Review Comment:
   So, probably makes sense to move this logic into a utility method. At least sorting the archive names.



-- 
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: oak-dev-unsubscribe@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] OAK-11299: Missing Segments With Oak Run Segment Copy [jackrabbit-oak]

Posted by "lweitzendorf (via GitHub)" <gi...@apache.org>.
lweitzendorf commented on code in PR #1892:
URL: https://github.com/apache/jackrabbit-oak/pull/1892#discussion_r2209722703


##########
oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/tool/SegmentStoreMigrator.java:
##########
@@ -162,9 +162,13 @@ private void migrateArchives() throws IOException, ExecutionException, Interrupt
         List<String> targetArchives = targetManager.listArchives();
 
         if (appendMode && !targetArchives.isEmpty()) {
-            //last archive can be updated since last copy and needs to be recopied
-            String lastArchive = targetArchives.get(targetArchives.size() - 1);
-            targetArchives.remove(lastArchive);
+            // last archive could have been updated since last copy and needs to be recopied
+            try {
+                targetArchives.sort(String::compareTo);
+                targetArchives.remove(targetArchives.size() - 1);
+            } catch (UnsupportedOperationException e) {

Review Comment:
   It's a bit odd. It returns an ArrayList, but `java.util.Arrays.ArrayList` instead of `java.util.ArrayList` and the former doesn't support any resizing operation.



-- 
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: oak-dev-unsubscribe@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] OAK-11299: Missing Segments With Oak Run Segment Copy [jackrabbit-oak]

Posted by "lweitzendorf (via GitHub)" <gi...@apache.org>.
lweitzendorf commented on code in PR #1892:
URL: https://github.com/apache/jackrabbit-oak/pull/1892#discussion_r2209736590


##########
oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/tool/SegmentStoreMigrator.java:
##########
@@ -162,9 +162,13 @@ private void migrateArchives() throws IOException, ExecutionException, Interrupt
         List<String> targetArchives = targetManager.listArchives();
 
         if (appendMode && !targetArchives.isEmpty()) {
-            //last archive can be updated since last copy and needs to be recopied
-            String lastArchive = targetArchives.get(targetArchives.size() - 1);
-            targetArchives.remove(lastArchive);
+            // last archive could have been updated since last copy and needs to be recopied
+            try {
+                targetArchives.sort(String::compareTo);
+                targetArchives.remove(targetArchives.size() - 1);
+            } catch (UnsupportedOperationException e) {

Review Comment:
   But more generally, yes the list may be fully immutable or some other type that doesn't allow resizing. Why copy it into an ArrayList instead of just always using subList for example?



-- 
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: oak-dev-unsubscribe@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] OAK-11299: Missing Segments With Oak Run Segment Copy [jackrabbit-oak]

Posted by "mreutegg (via GitHub)" <gi...@apache.org>.
mreutegg commented on code in PR #1892:
URL: https://github.com/apache/jackrabbit-oak/pull/1892#discussion_r2213139588


##########
oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/tool/SegmentStoreMigrator.java:
##########
@@ -162,9 +162,13 @@ private void migrateArchives() throws IOException, ExecutionException, Interrupt
         List<String> targetArchives = targetManager.listArchives();
 
         if (appendMode && !targetArchives.isEmpty()) {
-            //last archive can be updated since last copy and needs to be recopied
-            String lastArchive = targetArchives.get(targetArchives.size() - 1);
-            targetArchives.remove(lastArchive);
+            // last archive could have been updated since last copy and needs to be recopied
+            try {
+                targetArchives.sort(String::compareTo);
+                targetArchives.remove(targetArchives.size() - 1);
+            } catch (UnsupportedOperationException e) {

Review Comment:
   So, probably makes sense to move this logic into a utility method.



-- 
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: oak-dev-unsubscribe@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] OAK-11299: Missing Segments With Oak Run Segment Copy [jackrabbit-oak]

Posted by "mreutegg (via GitHub)" <gi...@apache.org>.
mreutegg commented on code in PR #1892:
URL: https://github.com/apache/jackrabbit-oak/pull/1892#discussion_r2209428991


##########
oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/tool/SegmentStoreMigrator.java:
##########
@@ -162,9 +162,13 @@ private void migrateArchives() throws IOException, ExecutionException, Interrupt
         List<String> targetArchives = targetManager.listArchives();
 
         if (appendMode && !targetArchives.isEmpty()) {
-            //last archive can be updated since last copy and needs to be recopied
-            String lastArchive = targetArchives.get(targetArchives.size() - 1);
-            targetArchives.remove(lastArchive);
+            // last archive could have been updated since last copy and needs to be recopied
+            try {
+                targetArchives.sort(String::compareTo);

Review Comment:
   Sorting lexicographically only work with up to 5 digits in the archive name.
   ```
   data00001a.tar
   data33985b.tar
   data99999a.tar
   ```
   But the archive name permits more digits up to an archive number of Integer.MAX_Value.
   
   https://github.com/apache/jackrabbit-oak/blob/5b13b559dc9d31a20676353782abff7c96e59f13/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/tar/TarFiles.java#L261



-- 
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: oak-dev-unsubscribe@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] OAK-11299: Missing Segments With Oak Run Segment Copy [jackrabbit-oak]

Posted by "mreutegg (via GitHub)" <gi...@apache.org>.
mreutegg commented on code in PR #1892:
URL: https://github.com/apache/jackrabbit-oak/pull/1892#discussion_r2209428991


##########
oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/tool/SegmentStoreMigrator.java:
##########
@@ -162,9 +162,13 @@ private void migrateArchives() throws IOException, ExecutionException, Interrupt
         List<String> targetArchives = targetManager.listArchives();
 
         if (appendMode && !targetArchives.isEmpty()) {
-            //last archive can be updated since last copy and needs to be recopied
-            String lastArchive = targetArchives.get(targetArchives.size() - 1);
-            targetArchives.remove(lastArchive);
+            // last archive could have been updated since last copy and needs to be recopied
+            try {
+                targetArchives.sort(String::compareTo);

Review Comment:
   Sorting lexicographically only work with up to 5 digits in the archive name.
   ```
   data00001a.tar
   data33985b.tar
   data99999a.tar
   ```
   But the archive name permits more digits up to an archive number of `Integer.MAX_VALUE`.
   
   https://github.com/apache/jackrabbit-oak/blob/5b13b559dc9d31a20676353782abff7c96e59f13/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/tar/TarFiles.java#L261



-- 
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: oak-dev-unsubscribe@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org