{"record":{"id":"e4dffb1c7b19266d","repo":"apache/cassandra","slug":"materialized-view-failed-to-complete-sleeping-5-m","errorCode":null,"errorMessage":"Materialized View failed to complete, sleeping 5 minutes before restarting","messagePattern":"Materialized View failed to complete, sleeping 5 minutes before restarting","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/java/org/apache/cassandra/db/view/ViewBuilder.java","lineNumber":202,"sourceCode":"            {\n                keysBuilt += result.stream().mapToLong(x -> x).sum();\n                builtRanges.addAll(pendingRanges.keySet());\n                pendingRanges.clear();\n                build();\n            }\n\n            public void onFailure(Throwable t)\n            {\n                if (t instanceof CompactionInterruptedException)\n                {\n                    internalStop(true);\n                    keysBuilt = tasks.stream().mapToLong(ViewBuilderTask::keysBuilt).sum();\n                    logger.info(\"Interrupted build for view({}.{}) after covering {} keys\", ksName, view.name, keysBuilt);\n                }\n                else\n                {\n                    ScheduledExecutors.nonPeriodicTasks.schedule(() -> loadStatusAndBuild(), 5, TimeUnit.MINUTES);\n                    logger.warn(\"Materialized View failed to complete, sleeping 5 minutes before restarting\", t);\n                }\n            }\n        });\n        this.future = future;\n    }\n\n    private void finish()\n    {\n        logger.debug(\"Marking view({}.{}) as built after covering {} keys \", ksName, view.name, keysBuilt);\n        SystemKeyspace.finishViewBuildStatus(ksName, view.name);\n        updateDistributed();\n    }\n\n    private void updateDistributed()\n    {\n        try\n        {\n            SystemDistributedKeyspace.successfulViewBuild(ksName, view.name, localHostId);","sourceCodeStart":184,"sourceCodeEnd":220,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/view/ViewBuilder.java#L184-L220","documentation":"ViewBuilder's build future attaches an onFailure handler: if the build was stopped intentionally it logs an interruption, otherwise it logs this warning and schedules loadStatusAndBuild() to retry the materialized view build after a 5-minute delay. The MV build is therefore delayed, not permanently failed.","triggerScenarios":"The ViewBuilderTask future completes exceptionally for any reason other than intentional stop — e.g. exceptions during schema convergence wait, sstable scanning, or sending view mutations — triggering the retry scheduling.","commonSituations":"Schema not yet converged across the cluster when a node starts building; node under heavy load or frequent GC; range movements/bootstraps interrupting builds; failures delivering view mutations to replicas.","solutions":["Wait 5 minutes — the build automatically retries; monitor with system.batches / view_build status (nodetool viewbuildestimates)","Check logs for the underlying cause exception and address it (schema agreement, network, load)","If schema agreement is the issue, verify gossip/schema tables on all nodes and fix divergent nodes","Retry after reducing load or after topology changes settle"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// preconditions before creating MVs:\n// nodetool describecluster  -> schema agreement across all nodes\n// all nodes UP in nodetool status","typeGuard":null,"tryCatchPattern":"try {\n    createMaterializedView(...);\n} catch (Exception e) {\n    // build failure retries automatically after 5 min; monitor\n    // nodetool viewbuildestimates\n}","preventionTips":["Create MVs only when all nodes are up and schema is converged","Monitor view build progress with viewbuildestimates","Avoid topology changes while view builds are running","Read the root cause in logs rather than only the retry warning"],"tags":["materialized-view","background-build","retry"],"backgroundTag":"view-build-failed","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}