Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean build fails in compileKotlin task when parallel execution enabled #1380

Closed
lfielke opened this issue Jun 19, 2019 · 13 comments · Fixed by #1415
Closed

Clean build fails in compileKotlin task when parallel execution enabled #1380

lfielke opened this issue Jun 19, 2019 · 13 comments · Fixed by #1415

Comments

@lfielke
Copy link
Contributor

lfielke commented Jun 19, 2019

I'm using SqlDelight in an Android library module as part of an Android application.
Development builds and IDE experience is working well, however clean builds consistently fail both on my Linux workstation and a MacOS machine used as a build server.

The build will fail in either the compileReleaseKotlin or compileDebugKotlin tasks in the gradle project that's using SqlDelight, with Unresolved reference errors for the generated classes/interfaces (see build scan below for full output).

Repeating the same build command (without cleaning) will succeed.

I suspect there is a timing problem or race, because disabling Gradle Parallel execution (--no-parallel) or reducing max-workers to 1 makes the build reliably succeed.
However this is not a great workaround, because this makes the builds a lot slower.

I cannot share our app project where the problem happens consistently. I've had trouble making a small, reliable repro project. The app that this is occurring in has multiple gradle modules and uses dagger via the kotlin-kapt plugin, so these are included in the repro. The only way I've been able to trigger the problem in a small project though, is adding a sleep to the SqlDelight generate interface tasks. Our actual app doesn't do this.

I've uploaded the small repro here:
https://github.com/lfielke/sqldelightbug

Checkout the project and run this a few times:
./gradlew clean && ./gradlew --max-workers=8 --parallel -x lint build assembleAndroidTest
On my computer this starts failing after the second run.

Build scan of failed build (command as above):
https://scans.gradle.com/s/jpbakohx64zee/activate/klvs6thkipury

Build scan of successful build (command changed --max-workers=1):
https://scans.gradle.com/s/v3ijkbfs6j7vy/activate/jaxujpzu5disq

Note that adding --scan to enable a build scan seems to alter timings and makes it suceed more often.
Also note that the first build where the jettify transforms run seems to always succeed (this is also true after changing the build scripts or environment).
Subsequent clean builds then fail most of the time for me.
Just running the second gradlew command will successfully build the project after a failure for me, so there doesn't appear to be anything wrong with the source code.

The repro project is using Android Gradle Plugin 3.5.0-beta04, which seems to trigger the problem more often in the repro project. The app with the problem is using AGP 3.4.1.

Removing --parallel from the above command also makes it succeed for me.
Note that adding or changing Gradle properties seems to cause more stuff to be reevaluated and then the first clean build will succeed. This has made it tricky to get a repro!

I don't know how to troubleshoot this any further. From what I can tell, the compileKotlin task depends on the generate interfaces task and is being executed after they've finished in the failed build.
I'm using the default kotlin compiler strategy, which uses a daemon if I understand correctly. Could the kotlin compiler daemon be mis-caching that there's no generated sources to add to the compilation?

@AlecKazakova
Copy link
Collaborator

thanks for the repro - parallelizing the gradle plugin is something im working on currently so I'll make sure to verify it works consistently for your sample project

@lfielke
Copy link
Contributor Author

lfielke commented Jun 20, 2019

Thanks for the reply, let me know if I can help in any way. I'm keen to be able to use gradle --parallel, as --no-parallel nearly doubles the time for a clean build for the whole app (from 5:40 to approx 11 minutes).

@lfielke
Copy link
Contributor Author

lfielke commented Jul 8, 2019

I think I've found the main cause of this problem, VerifyMigrationTask deletes the build/sqldelight directory when it runs:
https://github.com/square/sqldelight/blob/1.1.3/sqldelight-gradle-plugin/src/main/kotlin/com/squareup/sqldelight/gradle/VerifyMigrationTask.kt#L39

This means that if any of the verifyMigration tasks run before a compile task, then the sources generated by the generateXXXDatabaseInterface tasks are deleted and so the compile task fails.

The verifyMigration task runs as part of check (I think), so is run by default if you run the build task.

You can see in my builds scans above, on the build that failed, verifyDebugStoreDatabaseMigration is run before compileDebugKotlin. On the build scan that succeeded, verifyDebugStoreDatabaseMigration is run after compileDebugKotlin.

This also explains the trouble with reproducing this reliably, as it depends on the task execution ordering.

A reliable workaround for me is to exclude all the verifyMigration tasks for all variants using Gradle's -x command line option. Doing this, parallel builds seem to be working. I'm aware that you have other work in progress to make parallel builds work correctly, but this works around the immediate problem for me.

A quick way to demonstrate the deletion is to run:

  1. ./gradlew generateDebugStoreDatabaseInterface
    Note that build/sqldelight directory exists and has some source code in it.
  2. ./gradlew verifyReleaseStoreDatabaseMigration
    Note that build/sqldelight directory no longer exists. I'd expect this task not to delete the generated sources.

lfielke added a commit to lfielke/sqldelight that referenced this issue Jul 9, 2019
Avoids clobbering source code generated by SqlDelightTask, which
will cause compilation to fail if it runs after this task.
@jrodbx
Copy link
Contributor

jrodbx commented Jul 11, 2019

Seeing similar behavior in Cash App. Here's a stack trace:

ERROR: @NotNull method com/intellij/openapi/vfs/encoding/EncodingManager.getInstance must not return null
java.lang.IllegalStateException: @NotNull method com/intellij/openapi/vfs/encoding/EncodingManager.getInstance must not return null
        at com.intellij.openapi.vfs.encoding.EncodingManager.$$$reportNull$$$0(EncodingManager.java)
        at com.intellij.openapi.vfs.encoding.EncodingManager.getInstance(EncodingManager.java:25)
        at com.intellij.openapi.vfs.encoding.EncodingRegistry.getInstance(EncodingRegistry.java:43)
        at com.intellij.openapi.fileEditor.impl.LoadTextUtil.getDefaultCharsetFromEncodingManager(LoadTextUtil.java:223)
        at com.intellij.openapi.fileEditor.impl.LoadTextUtil.guessFromContent(LoadTextUtil.java:281)
        at com.intellij.openapi.fileEditor.impl.LoadTextUtil.detectHardCharset(LoadTextUtil.java:206)
        at com.intellij.openapi.fileEditor.impl.LoadTextUtil.detectInternalCharsetAndSetBOM(LoadTextUtil.java:233)
        at com.intellij.openapi.fileEditor.impl.LoadTextUtil.getTextByBinaryPresentation(LoadTextUtil.java:553)
        at com.intellij.openapi.fileEditor.impl.LoadTextUtil.getTextByBinaryPresentation(LoadTextUtil.java:545)
        at com.intellij.openapi.fileEditor.impl.LoadTextUtil.loadText(LoadTextUtil.java:531)
        at com.intellij.openapi.fileEditor.impl.LoadTextUtil.loadText(LoadTextUtil.java:503)
        at com.intellij.mock.MockFileDocumentManagerImpl.getDocument(MockFileDocumentManagerImpl.java:53)
        at com.intellij.psi.AbstractFileViewProvider.getDocument(AbstractFileViewProvider.java:192)
        at com.intellij.psi.AbstractFileViewProvider$VirtualFileContent.getText(AbstractFileViewProvider.java:474)
        at com.intellij.psi.AbstractFileViewProvider.getContents(AbstractFileViewProvider.java:172)
        at com.intellij.psi.impl.source.PsiFileImpl.loadTreeElement(PsiFileImpl.java:209)
        at com.intellij.psi.impl.source.PsiFileImpl.calcTreeElement(PsiFileImpl.java:714)
        at com.intellij.psi.impl.source.PsiFileImpl.getChildren(PsiFileImpl.java:720)
        at com.intellij.psi.impl.source.PsiFileImpl.findChildByClass(PsiFileImpl.java:530)
        at com.alecstrong.sqlite.psi.core.SqliteFileBase.getSqlStmtList(SqliteFileBase.kt:33)
        at com.alecstrong.sqlite.psi.core.SqliteFileBase.views(SqliteFileBase.kt:68)
        at com.alecstrong.sqlite.psi.core.SqliteFileBase.<init>(SqliteFileBase.kt:26)
        at com.squareup.sqldelight.core.lang.SqlDelightFile.<init>(SqlDelightFile.kt:39)
        at com.squareup.sqldelight.core.lang.SqlDelightParserDefinition.createFile(SqlDelightParserDefinition.kt:58)
        at com.squareup.sqldelight.core.lang.SqlDelightParserDefinition.createFile(SqlDelightParserDefinition.kt:29)
        at com.intellij.psi.AbstractFileViewProvider.createFile(AbstractFileViewProvider.java:158)
        at com.intellij.psi.AbstractFileViewProvider.createFile(AbstractFileViewProvider.java:142)
        at com.intellij.psi.SingleRootFileViewProvider.createFile(SingleRootFileViewProvider.java:166)
        at com.intellij.psi.SingleRootFileViewProvider.getPsiInner(SingleRootFileViewProvider.java:120)
        at com.intellij.psi.AbstractFileViewProvider.getPsi(AbstractFileViewProvider.java:208)
        at com.intellij.psi.impl.file.impl.FileManagerImpl.findFile(FileManagerImpl.java:366)
        at com.intellij.psi.impl.PsiManagerImpl.findFile(PsiManagerImpl.java:160)
        at com.alecstrong.sqlite.psi.core.SqliteCoreEnvironment$forSourceFiles$1.processFile(SqliteCoreEnvironment.kt:86)
        at com.alecstrong.sqlite.psi.core.CoreFileIndex.iterateContentUnderDirectory(SqliteCoreEnvironment.kt:117)
        at com.alecstrong.sqlite.psi.core.CoreFileIndex.iterateContentUnderDirectory(SqliteCoreEnvironment.kt:114)
        at com.alecstrong.sqlite.psi.core.CoreFileIndex.iterateContentUnderDirectory(SqliteCoreEnvironment.kt:114)
        at com.alecstrong.sqlite.psi.core.CoreFileIndex.iterateContentUnderDirectory(SqliteCoreEnvironment.kt:114)
        at com.alecstrong.sqlite.psi.core.CoreFileIndex.iterateContentUnderDirectory(SqliteCoreEnvironment.kt:114)
        at com.alecstrong.sqlite.psi.core.CoreFileIndex.iterateContentUnderDirectory(SqliteCoreEnvironment.kt:114)
        at com.alecstrong.sqlite.psi.core.CoreFileIndex.iterateContentUnderDirectory(SqliteCoreEnvironment.kt:114)
        at com.alecstrong.sqlite.psi.core.CoreFileIndex.iterateContent(SqliteCoreEnvironment.kt:108)
        at com.alecstrong.sqlite.psi.core.SqliteCoreEnvironment.forSourceFiles(SqliteCoreEnvironment.kt:84)
        at com.alecstrong.sqlite.psi.core.SqliteCoreEnvironment.annotate(SqliteCoreEnvironment.kt:72)
        at com.squareup.sqldelight.core.SqlDelightEnvironment.generateSqlDelightFiles(SqlDelightEnvironment.kt:93)
        at com.squareup.sqldelight.gradle.SqlDelightTask.generateSqlDelightFiles(SqlDelightTask.kt:62)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:103)
        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.doExecute(StandardTaskAction.java:48)
        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:41)
        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:28)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:702)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:669)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$5.run(ExecuteActionsTaskExecuter.java:401)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:402)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:394)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:92)
        at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:390)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:373)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.access$200(ExecuteActionsTaskExecuter.java:79)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$TaskExecution.execute(ExecuteActionsTaskExecuter.java:210)
        at org.gradle.internal.execution.steps.ExecuteStep.lambda$execute$1(ExecuteStep.java:33)
        at java.util.Optional.orElseGet(Optional.java:267)
        at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:33)
        at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:26)
        at org.gradle.internal.execution.steps.CleanupOutputsStep.execute(CleanupOutputsStep.java:58)
        at org.gradle.internal.execution.steps.CleanupOutputsStep.execute(CleanupOutputsStep.java:35)
        at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:48)
        at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:33)
        at org.gradle.internal.execution.steps.CancelExecutionStep.execute(CancelExecutionStep.java:39)
        at org.gradle.internal.execution.steps.TimeoutStep.executeWithoutTimeout(TimeoutStep.java:73)
        at org.gradle.internal.execution.steps.TimeoutStep.execute(TimeoutStep.java:54)
        at org.gradle.internal.execution.steps.CatchExceptionStep.execute(CatchExceptionStep.java:35)
        at org.gradle.internal.execution.steps.CreateOutputsStep.execute(CreateOutputsStep.java:51)
        at org.gradle.internal.execution.steps.SnapshotOutputsStep.execute(SnapshotOutputsStep.java:45)
        at org.gradle.internal.execution.steps.SnapshotOutputsStep.execute(SnapshotOutputsStep.java:31)
        at org.gradle.internal.execution.steps.CacheStep.executeWithoutCache(CacheStep.java:201)
        at org.gradle.internal.execution.steps.CacheStep.executeAndStoreInCache(CacheStep.java:183)
        at org.gradle.internal.execution.steps.CacheStep.lambda$executeWithCache$2(CacheStep.java:106)
        at java.util.Optional.orElseGet(Optional.java:267)
        at org.gradle.internal.execution.steps.CacheStep.lambda$executeWithCache$3(CacheStep.java:106)
        at org.gradle.internal.Try$1.apply(Try.java:59)
        at org.gradle.internal.Try$1.apply(Try.java:56)
        at org.gradle.internal.Try$Success.flatMap(Try.java:102)
        at org.gradle.internal.Try.map(Try.java:56)
        at org.gradle.internal.execution.steps.CacheStep.executeWithCache(CacheStep.java:79)
        at org.gradle.internal.execution.steps.CacheStep.execute(CacheStep.java:69)
        at org.gradle.internal.execution.steps.CacheStep.execute(CacheStep.java:45)
        at org.gradle.internal.execution.steps.BroadcastChangingOutputsStep.execute(BroadcastChangingOutputsStep.java:49)
        at org.gradle.internal.execution.steps.StoreSnapshotsStep.execute(StoreSnapshotsStep.java:43)
        at org.gradle.internal.execution.steps.StoreSnapshotsStep.execute(StoreSnapshotsStep.java:32)
        at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:38)
        at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:24)
        at org.gradle.internal.execution.steps.SkipUpToDateStep.executeBecause(SkipUpToDateStep.java:96)
        at org.gradle.internal.execution.steps.SkipUpToDateStep.lambda$execute$0(SkipUpToDateStep.java:89)
        at java.util.Optional.map(Optional.java:215)
        at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:54)
        at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:38)
        at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:77)
        at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:37)
        at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:36)
        at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:26)
        at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:90)
        at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:48)
        at org.gradle.internal.execution.impl.DefaultWorkExecutor.execute(DefaultWorkExecutor.java:33)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:117)
        at org.gradle.api.internal.tasks.execution.ResolveBeforeExecutionStateTaskExecuter.execute(ResolveBeforeExecutionStateTaskExecuter.java:75)
        at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:62)
        at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:108)
        at org.gradle.api.internal.tasks.execution.ResolveBeforeExecutionOutputsTaskExecuter.execute(ResolveBeforeExecutionOutputsTaskExecuter.java:67)
        at org.gradle.api.internal.tasks.execution.StartSnapshotTaskInputsBuildOperationTaskExecuter.execute(StartSnapshotTaskInputsBuildOperationTaskExecuter.java:62)
        at org.gradle.api.internal.tasks.execution.ResolveAfterPreviousExecutionStateTaskExecuter.execute(ResolveAfterPreviousExecutionStateTaskExecuter.java:46)
        at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:94)
        at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
        at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:95)
        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:56)
        at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:73)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:49)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:416)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:406)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:102)
        at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:49)
        at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:43)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:355)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:343)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:336)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:322)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker$1.execute(DefaultPlanExecutor.java:134)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker$1.execute(DefaultPlanExecutor.java:129)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:202)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:193)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:129)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
        at java.lang.Thread.run(Thread.java:748)

@lfielke
Copy link
Contributor Author

lfielke commented Jul 18, 2019

I'm not sure the changes in #1415 fix the problem, as the VerifyMigrationTask still deletes the build/sqldelight directory, which contains the generated sources needed for the compile task.

I started some work towards separating the directories in #1399 but haven't had time to finish it.

@AlecKazakova
Copy link
Collaborator

ah i see, i misclosed this one probably because it has parallel in the name, but seems unrelated to parallel execution?

@AlecKazakova AlecKazakova reopened this Jul 18, 2019
@AlecKazakova
Copy link
Collaborator

okay im up to speed now - they use the same output folder and both of them delete things in that folder which can race and have problems. Suggested what we need to move forward there in the PR, I think there's a pretty simple line of sight to getting a fix in

lfielke added a commit to lfielke/sqldelight that referenced this issue Aug 1, 2019
Working towards supporting parallel task execution cashapp#1380
lfielke added a commit to lfielke/sqldelight that referenced this issue Aug 1, 2019
So it is not shared with tasks that generate code.
For supporting parallel task execution cashapp#1380
AlecKazakova pushed a commit that referenced this issue Aug 7, 2019
* Write generated code to sqldelight/code/$dbname

Working towards supporting parallel task execution #1380

* Use unique subdirectory for VerifyMigrationTask

So it is not shared with tasks that generate code.
For supporting parallel task execution #1380
@AlecKazakova
Copy link
Collaborator

I think this is fixed now...there are a few moving parts and some PRs that went through to address it. If not do you mind opening a new separate issue with the remaining pieces missing?

@AlecKazakova
Copy link
Collaborator

ugh still seeing it so reopening

@dimsuz
Copy link

dimsuz commented Jan 19, 2020

It seems that our nightly build reproduces this at 90% rate. What it does is building of gradlew assembleDebug assembleRelease (and few custom build types) in one go with parallel build enabled for Gradle and kotlin plugin.

The project is private (and is big), but maybe I can do something to help diagnose the issue?

@gildor
Copy link
Contributor

gildor commented Jun 26, 2020

We have the same issue, FileDocumentManager.getInstance must not return null and some similar which cause clean builds on CI fail quite often (I would say 10-20% of all build), and probably many fails avoided just because of build cache (so tasks execution is skipped).

Now we add workaround, where every SQLDelight module with dependencies on other SQLDelight modules adds

tasks.named("generate${DbName}DatabaseInterface") {
  mustRunAfter(":dependency:generate${DbName}DatabaseInterface
}

So it doesn't allow generation tasks run in parallel. So far so good, we never experience this crash after this change

@Wrywulf
Copy link

Wrywulf commented Sep 30, 2020

Is this related to #1649

@AlecKazakova AlecKazakova added this to the 1.4.4 milestone Oct 2, 2020
@AlecKazakova
Copy link
Collaborator

Tracking here #1439

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants