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

when using postgres2 - and delete bucket from shell #1877

Closed
LazyDBA247-Anyvision opened this issue Mar 9, 2021 · 3 comments
Closed

when using postgres2 - and delete bucket from shell #1877

LazyDBA247-Anyvision opened this issue Mar 9, 2021 · 3 comments

Comments

@LazyDBA247-Anyvision
Copy link
Contributor

Hi,
SW have cache for the "tables/collections" created, but when deleting the bucket from the weed shell
the table doesn't exists and SW should identify the specific error and try to recreate the table.

error: q: relation "testPerformance" does not exist

I0309 07:32:36     1 abstract_sql_store.go:148] insert /buckets/testPerformance/001 falls back to update: pq: relation "testPerformance" does not exist
I0309 07:32:36     1 abstract_sql_store.go:148] insert /buckets/testPerformance/001/000000 falls back to update: pq: relation "testPerformance" does not exist
I0309 07:32:36     1 abstract_sql_store.go:148] insert /buckets/testPerformance/001/000000/7beb0f8b8692088bd2690579c1a3e74a falls back to update: pq: relation "testPerformance" does not exist
E0309 07:32:36     1 filer.go:156] insert entry /buckets/testPerformance/001/000000/7beb0f8b8692088bd2690579c1a3e74a: upsert /buckets/testPerformance/001/000000/7beb0f8b8692088bd2690579c1a3e74a: pq: relation "testPerformance" does not exist
I0309 07:32:36     1 filer_server_handlers_write_autochunk.go:227] failing to write /buckets/testPerformance/001/000000/7beb0f8b8692088bd2690579c1a3e74a to filer server : insert entry /buckets/testPerformance/001/000000/7beb0f8b8692088bd2690579c1a3e74a: upsert /buckets/testPerformance/001/000000/7beb0f8b8692088bd2690579c1a3e74a: pq: relation "testPerformance" does not exist
I0309 07:32:36     1 common.go:53] response method:PUT URL:/buckets/testPerformance/001/000000/7beb0f8b8692088bd2690579c1a3e74a with httpStatus:500 and JSON:{"error":"insert entry /buckets/testPerformance/001/000000/7beb0f8b8692088bd2690579c1a3e74a: upsert /buckets/testPerformance/001/000000/7beb0f8b8692088bd2690579c1a3e74a: pq: relation \"testPerformance\" does not exist"}
E0309 07:32:36     1 s3api_object_handlers.go:364] upload to filer error: insert entry /buckets/testPerformance/001/000000/7beb0f8b8692088bd2690579c1a3e74a: upsert /buckets/testPerformance/001/000000/7beb0f8b8692088bd2690579c1a3e74a: pq: relation "testPerformance" does not exist

Thanks!

@chrislusf
Copy link
Collaborator

I could not reproduce this.

The cache you mentioned is already clearing it when dropping a bucket. https://github.com/chrislusf/seaweedfs/blob/master/weed/filer/abstract_sql/abstract_sql_store.go#L248

@LazyDBA247-Anyvision
Copy link
Contributor Author

when you have multiple filers?
so the cache of 1 (in the weed shell) is updated, but the rest is not?

I had two filers...

@LazyDBA247-Anyvision
Copy link
Contributor Author

in : https://github.com/chrislusf/seaweedfs/blob/737bde5ab7bcd83002127ccc0adf07839602f714/weed/filer/abstract_sql/abstract_sql_store.go#L142

there are specific error codes for missing tables
maybe something like this?

	if !strings.Contains(strings.ToLower(err.Error()), "duplicate") {
	    if store.SupportBucketTable {
	        // postgres error (42p01) & mysql error (42s02) codes for missing relation (table)
		    if strings.Contains(strings.ToLower(err.Error()), "42p01") || strings.Contains(strings.ToLower(err.Error()), "42s02")  {
		        if err = store.CreateTable(ctx, bucket); err == nil {
				    res, err := db.ExecContext(ctx, store.GetSqlInsert(bucket), util.HashStringToLong(dir), name, dir, meta)
                    if err == nil {
                        return
                    }
			    }
		    }
	    }
		// return fmt.Errorf("insert: %s", err)
		// skip this since the error can be in a different language
	}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants