Fix infinite loop in IntraLineLoader
If edits due to rebase are present, IntraLineLoader#combineLineEdits will enter an infinite loop. As we query the intraline diff cache with a timeout check and use a fall-back behavior in case of a timeout, none of our threads got completely stuck due to that bug. On the one hand, this meant that the Gerrit server could still serve requests. On the other hand, it concealed that bug and resulted in high CPU load, which could very negatively impact the whole Gerrit server. The fix of the issue is quite simple: We increase the index counter appropriately. As this issue shows, the implementation in IntraLineLoader#combineLineEdits is quite fragile. There are better ways to achieve the same computation. Adjusting that will be left for the future. None of our tests caught that issue as the result of the fall-back mechanism was the same as the result of the real computation for all tests which were affected. For that reason, we add a test whose results differ between the regular and the fall-back mechanism. In addition, we add some tests which cover intraline edits directly. Up to now, we didn't have any tests for them. We could and should certainly add more in the future. Ideally, we would also use a timeout for all tests within RevisionDiffIT. Normally, this would be simply achieved by using the Timeout rule of JUnit. However, adding that rule breaks all tests within that class as our implementation of ConfigSuite doesn't seem to nicely interact with arbitrary JUnit rules. As the result of timed out intraline computations are cached, we need to invalidate the intraline diff cache. The high CPU load also caused a lot of PatchList cache computations to time out, for which also the fall-back result was cached. Hence, we invalidate that cache as well. Bug: Issue 8742 Change-Id: I0abf392d398320964a021099d72a4f876a73b6a6
This commit is contained in:
		
				
					committed by
					
						
						Dave Borowitz
					
				
			
			
				
	
			
			
			
						parent
						
							5738641811
						
					
				
				
					commit
					54dfdec960
				
			@@ -17,6 +17,7 @@ package com.google.gerrit.extensions.common;
 | 
			
		||||
import static com.google.common.truth.Truth.assertAbout;
 | 
			
		||||
 | 
			
		||||
import com.google.common.truth.FailureStrategy;
 | 
			
		||||
import com.google.common.truth.IterableSubject;
 | 
			
		||||
import com.google.common.truth.StringSubject;
 | 
			
		||||
import com.google.common.truth.Subject;
 | 
			
		||||
import com.google.common.truth.SubjectFactory;
 | 
			
		||||
@@ -78,4 +79,16 @@ public class ContentEntrySubject extends Subject<ContentEntrySubject, ContentEnt
 | 
			
		||||
    ContentEntry contentEntry = actual();
 | 
			
		||||
    return ListSubject.assertThat(contentEntry.b, Truth::assertThat).named("lines of 'b'");
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public IterableSubject intralineEditsOfA() {
 | 
			
		||||
    isNotNull();
 | 
			
		||||
    ContentEntry contentEntry = actual();
 | 
			
		||||
    return Truth.assertThat(contentEntry.editA).named("intraline edits of 'a'");
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public IterableSubject intralineEditsOfB() {
 | 
			
		||||
    isNotNull();
 | 
			
		||||
    ContentEntry contentEntry = actual();
 | 
			
		||||
    return Truth.assertThat(contentEntry.editB).named("intraline edits of 'b'");
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user