Skip to content

Key failure causes entire job to abort #2

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

Open
deinspanjer opened this issue Feb 18, 2011 · 3 comments
Open

Key failure causes entire job to abort #2

deinspanjer opened this issue Feb 18, 2011 · 3 comments

Comments

@deinspanjer
Copy link

We occasionally get keys that don't return on some requests. Currently, if that happens, the entire csv request fails. I added the following code to be able to log those problems and continue:

1.  to_csv(Pid, Bucket, Props, Csv, [Key|Keys]) -> 
2.      NewCsv = try
3.                   {ok, Object} = riakc_pb_socket:get(Pid, Bucket, Key),
4.                   Entry = doc_to_csv(Object, Props),
5.                   case Keys of
6.                       [] -> <<Csv/binary, Entry/binary>>; %% end of dump
7.                       _ -> <<Csv/binary, Entry/binary, 10>>
8.                   end
9.               catch
10.                  error:_ ->
11.                      io:fwrite("~p:~p\n", [Key,bucket]),
12.                      Csv
13.              end,
14.         to_csv(Pid, Bucket, Props, NewCsv, Keys); 
@bradfordw
Copy link
Owner

Awesome, I had labelled a few of the cases for additional error support but hadn't gotten to them yet; I had a suspicion that something bad could happen and bork the response! Thanks for the snippet, I'll get it merged in shortly.

@deinspanjer
Copy link
Author

This was actually the most erlang I've written to date. That said, I imagine that you might want to use something better than io:fwrite so it shows up in the sasl-error log maybe?

@bradfordw
Copy link
Owner

Yea, it'll go into the error_logger:warning_msg() since I assume you want it to keep running after it's "missed" right?

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