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

print Redshift loading error #23

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

print Redshift loading error #23

wants to merge 4 commits into from

Conversation

jhuangtw
Copy link
Contributor

@jhuangtw jhuangtw commented Jul 19, 2016

#3

  • print Redshift loading error as applicable.
  • fix a few lints (single quote etc) according to rubocop.
  • expose an optional flag to ignore error and keep loading other tables into Redshift. useful for debug.


target_connection.exec("CREATE TABLE public.#{target_connection.quote_ident(table.target_table_name)} (#{table.columns_for_create})")
print_last_redshift_loading_error if e.message.include?('stl_load_errors')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like this will not print any errors that do not match. Will other kinds of errors fail silently?

@toothrot
Copy link
Owner

Thanks! I left a few comments. Let me know what you think.

@toothrot
Copy link
Owner

Also, what's an example of the error message being caught?

@jhuangtw
Copy link
Contributor Author

@toothrot thanks for reviewing. I've updated the pull request to improve the messaging.
an example redshift loading error output:

INFO:  Relation "some_table" already exists and will be skipped
Downloading some_table
Uploading some_table.1
Importing some_table
INFO:  Table "some_table_updating" does not exist and will be skipped
ERROR:  Load into table 'some_table' failed.  Check 'stl_load_errors' system table for details.
ERROR:  Last entry in Redshift's 'stl_load_errors' table:
    userid: 100
    slice: 0
    tbl: 112357
    starttime: 2016-07-19 20:07:36.182859
    session: 4595
    query: _n_
    filename: s3://_some_file_.psv.gz.1                                                                                                                                                                                                        
    line_number: 11302
    colname: body                                                                                                                           
    type: varchar   
    col_length: 65535     
    position: 119
    raw_line: a|b|c|...
    raw_field_value: _some_raw_value_
    err_code: 1220
    err_reason: String contains invalid or unsupported UTF8 codepoints. Bad UTF8 hex sequence: ef bf bf (error 7)   

INFO:  Skipping 'some_table' and continuing on.

the last INFO line only prints if WARN_ON_LOADING_ERROR is specified. for other exceptions, error and stacktrace will be printed.

puts "ERROR: Last entry in Redshift's 'stl_load_errors' table:"
print_last_redshift_loading_error
else
puts 'ERROR: Unhandled PG error:'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think this should "raise", right? If we aren't explicitly handling the exception, then we need to ensure it errors correctly. Otherwise, we may hit this over and over again for something we are not handling.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@toothrot thanks for the feedback. please take a look at the new snapshot.

@jhuangtw
Copy link
Contributor Author

@toothrot how's this one looking?

@jhuangtw
Copy link
Contributor Author

jhuangtw commented Aug 9, 2016

@toothrot ping?

@toothrot
Copy link
Owner

toothrot commented Aug 9, 2016

I think I want to take another pass at this before merging it. I'll do that this week. Sorry for the delay.

@jhuangtw
Copy link
Contributor Author

@toothrot ping :)

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

Successfully merging this pull request may close these issues.

2 participants