When running terraform plan and apply terraform prints strange log trace

When terraform plan or apply is run terraform prints a weird error trace like below in the console and exit.

terraform13 plan
Acquiring state lock. This may take a few moments…
2022/02/10 12:08:17 [INFO] Terraform version: 0.13.7
2022/02/10 12:08:17 [INFO] Go runtime version: go1.14.7
2022/02/10 12:08:17 [INFO] CLI args: string{“terraform13”, “plan”}
2022/02/10 12:08:17 [DEBUG] Attempting to open CLI config file: /root/.terraformrc
2022/02/10 12:08:17 [DEBUG] File doesn’t exist, but doesn’t need to. Ignoring.
2022/02/10 12:08:18 [DEBUG] ignoring non-existing provider search directory terraform.d/plugins
2022/02/10 12:08:18 [DEBUG] ignoring non-existing provider search directory /root/.terraform.d/plugins
2022/02/10 12:08:18 [DEBUG] ignoring non-existing provider search directory /root/.local/share/terraform/plugins
2022/02/10 12:08:18 [DEBUG] ignoring non-existing provider search directory /usr/local/share/terraform/plugins
2022/02/10 12:08:18 [DEBUG] ignoring non-existing provider search directory /usr/share/terraform/plugins
2022/02/10 12:08:18 [INFO] CLI command args: string{“plan”}
2022/02/10 12:08:19 [TRACE] Meta.Backend: built configuration for “s3” backend with hash value 2493291232
2022/02/10 12:08:19 [TRACE] Preserving existing state lineage “3aa7d4a4-6bda-1d4f-e4ce-0245fae39113”
2022/02/10 12:08:19 [TRACE] Preserving existing state lineage “3aa7d4a4-6bda-1d4f-e4ce-0245fae39113”
2022/02/10 12:08:19 [TRACE] Meta.Backend: working directory was previously initialized for “s3” backend
2022/02/10 12:08:19 [TRACE] Meta.Backend: using already-initialized, unchanged “s3” backend configuration
2022/02/10 12:08:19 [INFO] AWS Auth provider used: “SharedCredentialsProvider”
2022/02/10 12:08:19 [DEBUG] Trying to get account information via sts:GetCallerIdentity
2022/02/10 12:08:23 [TRACE] Meta.Backend: instantiated backend of type *s3.Backend
2022/02/10 12:08:23 [TRACE] providercache.fillMetaCache: scanning directory .terraform/plugins
2022/02/10 12:08:23 [TRACE] getproviders.SearchLocalDirectory: .terraform/plugins is a symlink to .terraform/plugins
2022/02/10 12:08:23 [TRACE] getproviders.SearchLocalDirectory: found registry.terraform.io/hashicorp/aws v3.74.1 for linux_amd64 at .terraform/plugins/registry.terraform.io/hashicorp/aws/3.74.1/linux_amd64
2022/02/10 12:08:23 [TRACE] providercache.fillMetaCache: including .terraform/plugins/registry.terraform.io/hashicorp/aws/3.74.1/linux_amd64 as a candidate package for registry.terraform.io/hashicorp/aws 3.74.1
2022/02/10 12:08:33 [DEBUG] checking for provisioner in “.”
2022/02/10 12:08:33 [DEBUG] checking for provisioner in “/usr/local/bin”
2022/02/10 12:08:33 [INFO] Failed to read plugin lock file .terraform/plugins/linux_amd64/lock.json: open .terraform/plugins/linux_amd64/lock.json: no such file or directory
2022/02/10 12:08:33 [TRACE] Meta.Backend: backend *s3.Backend does not support operations, so wrapping it in a local backend
2022/02/10 12:08:33 [INFO] backend/local: starting Plan operation
2022/02/10 12:08:33 [TRACE] backend/local: requesting state manager for workspace “default”
2022/02/10 12:08:35 [TRACE] backend/local: requesting state lock for workspace “default”
o:Acquiring state lock. This may take a few moments…
e:
Error: Error locking state: Error acquiring the state lock: ConditionalCheckFailedException: The conditional request failed
Lock Info:
ID: 1be2e173-190f-583a-d87b-578d843ea9d4
Path: OUR_S3_BUCKET_NAME/DIRECTORY/terraform.tfstate
Operation: OperationTypePlan
Who: root@a64041ca1642
Version: 0.13.7
Created: 2022-02-10 01:06:04.0009849 +0000 UTC
Info:

Terraform acquires a state lock to protect the state from being written
by multiple users at the same time. Please resolve the issue above and try
again. For most commands, you can disable locking with the “-lock=false”
flag, but this is not recommended.

The issue was Terraform binary didn’t have enough memory. I was running terraform from inside a docker container and once I increased the memory available for docker this issue went away.
It might be good if terraform can out put an error message that is more understandable.