-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
Failed to save state: invalid character 'R' looking for beginning of value #24394
Comments
Hi @aneroid13, Could you try and check the value of the consul key directly? Since terraform state is always expected to be json, I wonder if something else was somehow saved to that key, and terraform is attempting to decode it each time. If that doesn't provide any clues, would it be possible to post the state file you have? Be sure to check it first for sensitive values if you do. Thanks! |
Hello. First of all, I create new workspace for clean experiment. And error repeat again. I try investigate Consul, but can't find anything suspicious in logs. This strings Consul write when error happens:
But I find out one interesting clue: error triggers when I got more than 35 VMs inside workspace. Very strange. Is there some limit on lenght of tfstate file in Consul or something like that ? wc ./errored.tfstate
11330 20928 397220 ./errored.tfstate |
Hi @aneroid13 We had the same problem once we got to a state which had about 10k lines. We solved it by adding the gzip option to our backend consul settings: ### - Consul backend configuration - ###
backend "consul" {
address = "localhost:8500"
scheme = "http"
path = "dev/terraform/testzones/zone.tfstate"
datacenter = "terraform"
gzip = true
}
} |
Thank you @al-lac. I just thought about it. But that error message just drive me mad, until I find the reason. Unfortunately, gzip is not solution, because I need a lot VM in my test zone, more over 300. :( |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Terraform Version
Terraform Configuration Files
Debug Output
Crash Output
Expected Behavior
Terraform should deploy all virtual machines and save configuration to Consul.
Actual Behavior
Terraform create all vms, but failed to save updated state to Consul.
It create file errored.tfstate with current config instead and drop the error.
Steps to Reproduce
Additional Context
Issue happened not on every vm creation. It is not happened in test environment, while I create 2 or 3 virtual machines.
This happened when I create more than 60 VMs in workspace.
I destroy all VMs in the workspace and clear terraform configuration in Consul, when terraform fail.
And start again, create a lot of VMs and terraform failed to save .tfstate, but it stuck on different VM, than first time.
Make "terraform state push errored.tfstate" returns the same error: "Failed to save state: invalid character 'R' looking for beginning of value"
Reason of this issue not clear. I can't find any suspicious 'R' character inside errored.tfstate or anywhere else.
References
The text was updated successfully, but these errors were encountered: