[ 
https://issues.apache.org/jira/browse/MBUILDCACHE-67?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17756339#comment-17756339
 ] 

ASF GitHub Bot commented on MBUILDCACHE-67:
-------------------------------------------

kbuntrock commented on code in PR #92:
URL: 
https://github.com/apache/maven-build-cache-extension/pull/92#discussion_r1299226304


##########
src/main/java/org/apache/maven/buildcache/CacheControllerImpl.java:
##########
@@ -401,6 +399,26 @@ private Future<File> createDownloadTask(
         });
         if (!cacheConfig.isLazyRestore()) {
             downloadTask.run();
+            try {
+                downloadTask.get();

Review Comment:
   As I apprehend the "lazy restore" functionality, there are two approach, 
each one with their pros and cons.
   
   **Non lazy restore** (the default) : immediate restoration of artefact and 
other build outputs.
   Build stability is the main concern. If the restoration fails, the build is 
executed normally. (I'm interrogative about the part where you say it can fail 
the build. For me it's the exact opposite intend). **Con**: we might restore 
stuff not used further in another module build.
   
   **Lazy restore** : restoration of artefacts is done only when used. It can 
save some bandwidth and speedup the build when used with a remote cache. (Pros 
with a local cache are not so clear to me.) **Con**: If the cache is 
corrupted/not accessible and an artefact must be used as a dependency in 
another module : the build is doomed and will fail.
   
   Actually, the non lazy restore does not really work as expected since the 
restore is done (download is immediately launched when using a remote cache), 
but we don't check the result straight away. It might be far too late when 
we'll discover the artefact did not restored well.
   
   Am I missing something in the picture?
   
   





> Any error in restoring from the cache should resume the non cache build
> -----------------------------------------------------------------------
>
>                 Key: MBUILDCACHE-67
>                 URL: https://issues.apache.org/jira/browse/MBUILDCACHE-67
>             Project: Maven Build Cache Extension
>          Issue Type: Bug
>    Affects Versions: 1.0.1
>            Reporter: Kevin Buntrock
>            Priority: Major
>              Labels: pull-request-available
>
> If any error arise during the restoration of artefacts from the cache, the 
> build should continue as it would usually do without the cache. In fact, it's 
> even what the extension says "Cannot restore cache, continuing with normal 
> build."
> But it's a lie, the build goes straight to the phase where it saves the 
> generated artefact in cache. ;)
> {code:java}
> [DEBUG] Hash calculated, item: dependency, hash: 14eab0591a006938
> [INFO] Project inputs calculated in 97 ms. XX checksum [a0d7876d9bceb494] 
> calculated in 50 ms.
> [INFO] Attempting to restore project 
> io.github.kbuntrock.sample:openapi-plugin-sample-backend from build cache
> [DEBUG] Checking local build info: 
> C:\Users\kbuntrock\.m2\build-cache\v1\io.github.kbuntrock.sample\openapi-plugin-sample-backend\a0d7876d9bceb494\local\buildinfo.xml
> [INFO] Local build found by checksum a0d7876d9bceb494
> [INFO] Found cached build, restoring 
> io.github.kbuntrock.sample:openapi-plugin-sample-backend from cache by 
> checksum a0d7876d9bceb494
> [DEBUG] Cached build details: 
> Build{dto=org.apache.maven.buildcache.xml.build.Build@63cf9de0}
> [DEBUG] Cannot restore cache, continuing with normal build.
> java.lang.RuntimeException: Made-up error : restoring artefact is impossible.
>     at 
> org.apache.maven.buildcache.CacheControllerImpl.restoreProjectArtifacts 
> (CacheControllerImpl.java:312)
>     at 
> org.apache.maven.buildcache.BuildCacheMojosExecutionStrategy.restoreProject 
> (BuildCacheMojosExecutionStrategy.java:171)
>     at org.apache.maven.buildcache.BuildCacheMojosExecutionStrategy.execute 
> (BuildCacheMojosExecutionStrategy.java:124)
>     at org.apache.maven.lifecycle.internal.MojoExecutor.execute 
> (MojoExecutor.java:159)
>     at 
> org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject 
> (LifecycleModuleBuilder.java:105)
>     at 
> org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject 
> (LifecycleModuleBuilder.java:73)
>     at 
> org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build
>  (SingleThreadedBuilder.java:53)
>     at org.apache.maven.lifecycle.internal.LifecycleStarter.execute 
> (LifecycleStarter.java:118)
>     at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261)
>     at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173)
>     at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101)
>     at org.apache.maven.cli.MavenCli.execute (MavenCli.java:906)
>     at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:283)
>     at org.apache.maven.cli.MavenCli.main (MavenCli.java:206)
>     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
>     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke 
> (NativeMethodAccessorImpl.java:77)
>     at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke 
> (DelegatingMethodAccessorImpl.java:43)
>     at java.lang.reflect.Method.invoke (Method.java:568)
>     at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced 
> (Launcher.java:283)
>     at org.codehaus.plexus.classworlds.launcher.Launcher.launch 
> (Launcher.java:226)
>     at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode 
> (Launcher.java:407)
>     at org.codehaus.plexus.classworlds.launcher.Launcher.main 
> (Launcher.java:348)
> [INFO] Cannot restore project artifacts, continuing with non cached build
> [INFO] Saved Build to local file: 
> C:\Users\kbuntrock\.m2\build-cache\v1\io.github.kbuntrock.sample\openapi-plugin-sample-backend\a0d7876d9bceb494\local\buildinfo.xml
> [INFO] 
> ------------------------------------------------------------------------
> [INFO] BUILD SUCCESS
> [INFO] 
> ------------------------------------------------------------------------
> [INFO] Total time:  0.629 s
> [INFO] Finished at: 2023-08-02T23:21:36+02:00
> [INFO] 
> ------------------------------------------------------------------------
> [DEBUG] Save cache-report to local file: 
> C:\Users\kbuntrock\Developpement\sample\target\maven-incremental\cache-report.662d75e1-1a0e-407a-85aa-21da4d207498.xml
>  {code}
> While trying to reproduce the error with a more convenient use case, it seems 
> that erasing the artefact from the repository (local in my case) does not 
> throw any restoration error (the build is set by default to "lazyRestore = 
> false").
> Here is a screenshot of a normal execution where the artefact is correctly 
> loaded :
> {code:java}
> [INFO] Found cached build, restoring 
> io.github.kbuntrock.sample:openapi-plugin-sample-backend from cache by 
> checksum a0d7876d9bceb494
> [DEBUG] Cached build details: 
> Build{dto=org.apache.maven.buildcache.xml.build.Build@5befbac1}
> [DEBUG] Downloading artifact openapi-plugin-sample-backend
> [DEBUG] Downloaded artifact openapi-plugin-sample-backend to: 
> C:\Users\kbuntrock\.m2\build-cache\v1\io.github.kbuntrock.sample\openapi-plugin-sample-backend\a0d7876d9bceb494\local\openapi-plugin-sample-backend.jar
> [INFO] Skipping plugin execution (cached): resources:resources
> [INFO] Skipping plugin execution (cached): compiler:compile {code}
> And the log of an execution where the file is missing on the filesystem. We 
> can see a missing line but no further effect on the cached build.
> {code:java}
> [INFO] Found cached build, restoring 
> io.github.kbuntrock.sample:openapi-plugin-sample-backend from cache by 
> checksum a0d7876d9bceb494
> [DEBUG] Cached build details: 
> Build{dto=org.apache.maven.buildcache.xml.build.Build@5befbac1}
> [DEBUG] Downloading artifact openapi-plugin-sample-backend
> [INFO] Skipping plugin execution (cached): resources:resources
> [INFO] Skipping plugin execution (cached): compiler:compile{code}
> If the artefact is used in a dependant module build, the expected error arise 
> : " Error retrieving artifact file: Missing file for cached build, cannot 
> restore.". But since we are not in lazy restore, we exept it earlier.
>  
> I would suggest to correct / test the two bugs in the MR since it will be far 
> easier to do so (it is why I created only one issue).
>  
> NB : The bugfix MR will follow.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to