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

Provider produced inconsistent result after apply #2209

Closed
maxpowis-bp opened this issue Nov 23, 2023 · 7 comments
Closed

Provider produced inconsistent result after apply #2209

maxpowis-bp opened this issue Nov 23, 2023 · 7 comments
Labels
bug Used to mark issues with provider's incorrect behavior category:resource resource:schema Issue connected to the snowflake_schema resource

Comments

@maxpowis-bp
Copy link

Terraform CLI and Provider Versions

Terraform cli version: v1.6.4 (as configured on my workspace in terraform-cloud)
Snowflake provider version: v0.76.0

Terraform Configuration

terraform {
  required_version = ">= 1.5.7"

  required_providers {
    snowflake = {
      source  = "Snowflake-Labs/snowflake"
      version = "0.76.0"
    }
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "3.81.0"
    }
  }

  backend "remote" {}
}

Expected Behavior

My project is managed a bunch of databases, schema, roles etc. I expect terraform and the snowflake provider to deal properly with resource creation and sequencing of operations.

Actual Behavior

I quite often get an error at apply time for my schema objects. Here's the last one while adding new databases and schema's to my configuration.

Error: Provider produced inconsistent result after apply
│ 
│ When applying changes to
│ module.schema.snowflake_schema.schema["MYDATABASE.MYSCHEMA"],
│ provider
│ "provider[\"registry.terraform.io/snowflake-labs/snowflake\"].terraform"
│ produced an unexpected new value: Root object was present, but now absent.
│ 
│ This is a bug in the provider, which should be reported in the provider's
│ own issue tracker.

On second attempt I get this:

Error: error creating schema MYSCHEMA err = 002002 (42710): SQL compilation error:
│ Object 'MYDATABASE.MYSCHEMA' already exists.
│ 
│   with module.schema.snowflake_schema.schema["MYDATABASE.MYSCHEMA"],
│   on modules/schema/main.tf line 10, in resource "snowflake_schema" "schema":
│   10: resource "snowflake_schema" "schema" {

After I remove the schema's manually, the next run completes successfully.

Steps to Reproduce

It's quite a complex project, I have a module that creates the databases, and another module that creates the schema's (and has a dependency to the database module)

How much impact is this issue causing?

Medium

Logs

I can't share this...

Additional Information

It seems I didn't encounter any of those issues while I was using provider version v0.70.1.
Happens much more since I upgraded to 0.76.0

@maxpowis-bp maxpowis-bp added the bug Used to mark issues with provider's incorrect behavior label Nov 23, 2023
@patmaddox
Copy link
Contributor

I am seeing the same behavior, in a config that creates multiple databases with multiple schemas in each database. It fails with the same "Root object was present, but now absent." when attempting to create schemas, but it does create the schema so I also see the "object already exists" error on subsequent runs.

Rolling back to 0.73 fixes it for me.

@simonepm
Copy link

simonepm commented Dec 6, 2023

Exact same behavior happening for me on 0.77.0 - the last good release was 0.73, everything after is broken in some way.

@maxpowis-bp
Copy link
Author

I confirm I don't have issues on 0.73 either.
Haven't tried 0.77 and don't intend to until this bug report is taken into consideration.

@sfc-gh-asawicki
Copy link
Collaborator

Hey @maxpowis-bp. Thanks for reporting the issue.

This is a problem after #2082 released in v0.74.0.

It may be connected with the ShowByID implementation for Schemas. We could reproduce the error for a case when the schema has the same name in two different databases. It may be one of many problems, but let's try this fix first.

Also, it is constructive to provide a configuration (or a simplified configuration) that shows an error.

@sfc-gh-jcieslak
Copy link
Collaborator

Hey @maxpowis-bp Could confirm that 0.74.0 resolves your issue?

@maxpowis-bp
Copy link
Author

Hi @sfc-gh-jcieslak unfortunately I can't. The mission has reached an end and I've handed over the components to the client.

@sfc-gh-jcieslak
Copy link
Collaborator

Alright, closing the issue then. Thanks :)

@sfc-gh-jcieslak sfc-gh-jcieslak added category:resource resource:schema Issue connected to the snowflake_schema resource labels May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Used to mark issues with provider's incorrect behavior category:resource resource:schema Issue connected to the snowflake_schema resource
Projects
None yet
Development

No branches or pull requests

5 participants