ConcurrentModificationException: Schema is currently being altered, please wait until that is complete.
Environment information
> npx ampx info
System:
OS: Windows 11 10.0.22631
CPU: (16) x64 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz
Memory: 33.05 GB / 63.77 GB
Binaries:
Node: 20.18.2 - C:\Program Files\nodejs\node.EXE
Yarn: undefined - undefined
npm: 10.8.2 - C:\Program Files\nodejs\npm.CMD
pnpm: undefined - undefined
NPM Packages:
@aws-amplify/auth-construct: 1.6.0
@aws-amplify/backend: 1.14.0
@aws-amplify/backend-auth: 1.5.0
@aws-amplify/backend-cli: 1.4.8
@aws-amplify/backend-data: 1.4.0
@aws-amplify/backend-deployer: 1.1.15
@aws-amplify/backend-function: 1.12.1
@aws-amplify/backend-output-schemas: 1.4.0
@aws-amplify/backend-output-storage: 1.1.4
@aws-amplify/backend-secret: 1.1.5
@aws-amplify/backend-storage: 1.2.4
@aws-amplify/cli-core: 1.2.3
@aws-amplify/client-config: 1.5.5
@aws-amplify/deployed-backend-client: 1.5.0
@aws-amplify/form-generator: 1.0.3
@aws-amplify/model-generator: 1.0.12
@aws-amplify/platform-core: 1.6.0
@aws-amplify/plugin-types: 1.8.0
@aws-amplify/sandbox: 1.2.11
@aws-amplify/schema-generator: 1.2.7
aws-amplify: 6.11.0
aws-cdk: 2.173.2
aws-cdk-lib: 2.173.2
typescript: 5.7.2
No AWS environment variables
No CDK environment variables
Describe the bug
This error keeps coming up in sandbox (from windows) when making minor changes, like adding a field to a data model... ...failed: ConcurrentModificationException: Schema is currently being altered, please wait until that is complete.
The CloudFormation stack in console indicates "UPDATE_COMPLETE"
The only workaround that I've found is to run the sandbox with the changes from Ubuntu, then once complete, start the sandbox again in Windows
I did notice that when I save resource.ts, There is a double trigger on the file...
[Sandbox] Watching for file changes...
File written: amplify_outputs.json
[Sandbox] Triggered due to a file update event:
Caused By: ❌
Reproduction steps
Adding a field to a data model.
Hey,👋 thanks for raising this! I'm going to transfer this over to our data repository for better assistance 🙂
Hey @TimmyAA, Can you check your open terminals to see if you are running multiple sandbox instances?
Hey @TimmyAA, Can you check your open terminals to see if you are running multiple sandbox instances?
Hi @AnilMaktala, 2 terminals open, one running 'npx ampx sandbox' and other running 'quasar dev'
@TimmyAA Thanks for checking. Do you have multiple stacks in your app? Also, what change in the resource.ts file triggered this issue?
@TimmyAA Thanks for checking. Do you have multiple stacks in your app? Also, what change in the
resource.tsfile triggered this issue?
Single stack. I added the 'signature' field to the model...
SCResponses: a
.model({
id: a.id().required(),
...
signature: a.string().required(),
...
deletedAt: a.string(),
deleted: a.boolean().default(false),
})
The only thing that looked suspicious was this double trigger on a single save...
[Sandbox] Watching for file changes...
File written: amplify_outputs.json
[Sandbox] Triggered due to a file update event:
I may try not letting npx ampx sandbox watch for file changes and just run it after I change something in the stack Or is there a local state file that gets out of sync, maybe caused by this double trigger
Didn't work... added a new fields to a model while 'npx ampx sandbox' wasn't running. Then started it, same error.
...failed: ConcurrentModificationException: Schema is currently being altered, please wait until that is complete.
Hey @TimmyAA, Interesting! Are you on Discord by any chance?
Experiencing the same issue. Is there an update on this?
No progress, but more information... authorization changes on data resource work fine storage resource changes work too
Just data model additions are a problem.
hi @TimmyAA, Thanks for additional detials. I am unable to reproduce the issue on my end. To rule out any sandbox-specific problems, could you please try running the sandbox with a new identifier and share the results?
`npx ampx sandbox --identifier somename'
hi @AnilMaktala, I tried with a new sandbox identifier. Initial deployment worked fine, but subsequent field add to a model failed with the same error.
... failed: ConcurrentModificationException: Schema is currently being altered, please wait until that is complete. ...
Also tried with a fresh clone of my project. I'll see if I can replicate problem in a generic project that I can share.
note that adding a new model/table works fine too. Just adding a field to an existing model continues to be the problem.
Solved, I think, but don't know why
Delete .amplify directory Rename amplify directory to amplify.org Run npm create amplify@latest Remove the newly created amplify directory Rename amplify.org back to amplify Run npx ampx sandbox
Test original problem, by adding a new field to an existing model... working as it should.
@TimmyAA, Glad to hear it's working now! Thanks for sharing the details—I’ll investigate further and see if I can reproduce the issue.
@nat-jones are you are still experiencing this issue?
@AnilMaktala Yes. I am still experiencing this.
Deleting .amplify directory is not an option for me as many of my functions import environments from .amplify/generated, so deleting would lead to widespread dependency failures that prevent it from being regenerated.
@nat-jones When you make the schema update and save the file, does the deployment try to hotswap the resources or fallback to full stack update? You should be able to find more information about this in the logs after the below line.
[Sandbox] Triggered due to a file update event: \amplify\data\resource.ts
I just ran into the same issue again. Ran into it 2-3 times on sandbox. My sandboxes are all new so it doesn't matter if I delete it. The first time I deleted the sandbox and recreated it, so obviously it worked. The most recent was removing the updated model first, and once CDK finished updating, placed the model back with the updated changes and reran cdk. Really helps to not have much data in your sandbox. Not sure what I'll do if I had lots of data tho
I'm thinking there's a conflict in AppSync layer for creating the tables since the tables had values before and me removing some fields in the model and adding fields broke it. Just a guess.
@dragonee2000 are you also experiencing this only on Windows? Or do you see this in a different OS?
I'm currently working on a Mac
Hey @dragonee200, sorry for the delay. Are you still experiencing this issue?
Yes. Still happening often for me. Always happens when i make changes to the model when there's data attached to the model.
I'm having the same issue. It happens when I try to create a pipeline handler with backend.apiId added into the sourcefile. Usually this would show an error saying that there's a circular dependency but now it's just failing with this error message.
I was getting this same error a few minutes ago as I was making changes to my schema. To git the error to stop I had to comment out most of my entities them put them back. I suspect that a more informative error message was being hidden.
I ran into the same problem. it happened to me when the only change was the addition of .authorization on a field. it did a hotswap deployment, which failed.
the workaround for me was to add another table called tmp, with only one column, to force a "full" deployment. the full deployment worked (including my .authorization addition to the field). after that, i removed the tmp table again.
Current vs Expected Behavior
Current Behavior (Problematic)
// User adds field to existing model in resource.ts
SCResponses: a
.model({
id: a.id().required(),
// ... existing fields
signature: a.string().required(), // NEW FIELD ADDED
// ... other fields
})
// File watcher triggers twice on save
[Sandbox] Triggered due to a file update event: amplify\data\resource.ts
[Sandbox] Triggered due to a file update event: amplify\data\resource.ts
[Sandbox] Previous deployment is still in progress. Will queue for another deployment after this one finishes
// Hotswap deployment fails
Error: ❌ failed: ConcurrentModificationException: Schema is currently being altered, please wait until that is complete.
Expected Behavior (Desired)
// User adds field to existing model in resource.ts
SCResponses: a
.model({
id: a.id().required(),
// ... existing fields
signature: a.string().required(), // NEW FIELD ADDED
// ... other fields
})
// File watcher triggers once on save
[Sandbox] Triggered due to a file update event: amplify\data\resource.ts
// Deployment succeeds (either hotswap or full deployment)
[Sandbox] Deployment successful
Hi @TimmyAA,
Thank you for reporting this issue and providing detailed reproduction steps. This is a significant developer experience problem affecting Amplify Gen 2 sandbox workflows, particularly when adding fields to existing data models.
Based on our investigation, this issue stems from a combination of factors:
- File watching double-triggers on Windows/macOS causing race conditions
- Hotswap deployment limitations when modifying existing schemas with data
- AWS AppSync concurrent modification detection during rapid deployment attempts
The community has identified several effective workarounds:
Immediate Workarounds:
- Project reinitialization (as discovered by @TimmyAA): Delete
.amplifydirectory and reinitialize - Force full deployment (as suggested by @homes2001): Add temporary table to force full deployment instead of hotswap
- Manual deployment timing: Stop file watching, make changes, then restart sandbox
Root Cause Fix Needed: This requires improvements to the FileWatchingSandbox implementation to:
- Enhance file watcher debouncing to prevent double-trigger race conditions
- Improve deployment strategy selection for schema modifications
- Add retry logic for ConcurrentModificationException scenarios
We encourage community contributions to address this issue! The fix would likely involve modifications to:
- FileWatchingSandbox for improved file watching
- Deployment strategy logic in the backend-deployer package
- Schema change detection mechanisms
Would you be interested in contributing a pull request to help resolve this issue? The Amplify team would be happy to provide guidance and review.