-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
google.cloud.bigquery.table.Table.insert_data fail silently after deleting and recreating table #3822
Comments
I've updated the issue description. Originally I'd only observed this after deleting and recreating a dataset and a table; I can now reproduce it after deleting and recreating a table. |
@inglesp, Help me understand better. Is this an eventual consistency problem (e.g. it works a few minutes later)? Or does it never work for some reason? |
By my understanding of eventual consistency, this is not an eventual consistency problem, in that writes to a table appear to succeed but get lost. I think I can come up with a better code example for the notes, so I'll update the description shortly. |
@inglesp Go ahead and make a new comment; will be easier for me to grok. Thanks. :-) |
I updated the description an hour ago with updated script that should demonstrate the problem. |
I wonder if this is related to this SO thread. As Hoffa pointed out, this is an expected behavior of BigQuery so I imagine the python API might not have much to do here, other then throw a |
Yeah, this is a known backend issue. Basically, it can take 2 minutes for the streaming buffer's cache of where tables are located to update, so the writes after a delete and recreate can end up going to the deleted table's files in that 2 minute window. Related: #4553 For adding data to brand new table, it's recommended to use a load job instead. We can make doing this easier with the client library. |
Has this been fixed? |
This is still a known issue with the BigQuery API: https://issuetracker.google.com/issues/64329577#comment3 Note: for many use cases you can recreate the table with the new rows by using a load job and the |
@tswast could you explain how to do that? WRITE_TRUNCATE is not present at all in the python documentation for bigquery. |
@Luttik The That documentation is more of an API reference, though, but more samples can be found in the how-to guides in the BigQuery product documentation. For example, for the JSON format, there is a Python sample that explains the effect of the WRITE_TRUNCATE option. Does that help? |
@plamut thanks for your kind reaction, even though I was wrong about the documentation (I guess I had a fluke with the quick search). I changed to a Postgress DB so I do not know it this would have worked. But I'll definitely keep this in mind. |
Summary
For about 12 seconds after deleting and recreating a table,
table.fetch_data()
returns nothing, even thoughtable.insert_data()
has been called without error. Between about 12 and 60 seconds, callingtable.insert_data()
raisesServiceUnavailable
. After that,table.insert_data()
succeeds and the inserted data can be retrieved.Details
Here's some code that demonstrates the problem:
It produces output similar to the following:
The text was updated successfully, but these errors were encountered: