-
Notifications
You must be signed in to change notification settings - Fork 430
Fall back to credential refresh on EDEADLK #336
Conversation
Using threading.Lock / multiprocessing.Lock is substantially more complex because it's necessary to pass one per _MultistoreFile and then plumb them through. We would need this code regardless to protect against multi-application calls, so starting out with this. Also, would like this in a release soon if that is feasible. |
In particular, don't you have some code which caused this to fail which could be used to protect against regression for all time? |
Added tests. |
|
||
class MockLockedFile(object): | ||
|
||
def __init__(self, filename_str, error_code): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
I'm pretty unfamiliar with both the problem and the solution at play here; I'd feel more comfortable with this if @dhermes also reviewed and approved this change. |
FYI the test error is related to The issue is caused by https://github.com/google/oauth2client/blob/311a53fbcae550526a74057f27cb9df73a0af009/tox.ini#L86-L87 |
for error_code in (errno.EDEADLK, errno.ENOSYS, errno.ENOLCK): | ||
multistore = multistore_file._MultiStore(filename) | ||
multistore._file = MockLockedFile(filename, error_code) | ||
# Should not raise even though the underlying file class did. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
RE: Release process. Pushing a new version is as simple as pushing a new tag. My simple process for new release
NOTE: I work with two remotes ( $ git remote -vv
official git@github.com:google/oauth2client.git (fetch)
official git@github.com:google/oauth2client.git (push)
origin git@github.com:dhermes/oauth2client.git (fetch)
origin git@github.com:dhermes/oauth2client.git (push) |
Please also squash commits; there's no reason for project history to include all our review back-and-forth. |
Planning to squash commits once I have reviewer approval, or would you prefer that I squash them with each iteration? |
SGTM RE: Squashing after review is completed. |
|
||
def test_lock_file_raises_ioerror(self): | ||
filehandle, filename = tempfile.mkstemp() | ||
os.close(filehandle) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
BTW This LGTM, Let's let @nathanielmanistaatgoogle weigh in before considering this ready to squash and merge. |
Change content LGTM; please produce a passing test run and single commit. @dhermes please feel free to merge when satisfied. |
Fixes googleapis#335 This change fixes a bug where multiple threads and/or processes using multistore_file to access the same backing store could raise IOError errno.EDEADLK to the calling application. Since EDEADLK is a possibility with concurrent access, this change instead causes a fallback to read only mode and refresh credentials if necessary.
@thobrla Travis finally ran the tests! All green. Ping me when you've squashed commits? |
JK Just realized they were already squashed. Good call. |
Fall back to credential refresh on EDEADLK
Not sure why the tests took so long to run; build sat in a pending state for several hours before finally running. @dhermes Can you pull this into a release? |
Yeah Travis sometimes has issues or like doesn't like the Can you assist with the release (send the PR with release notes and version bump as noted above)? Then I'll accept the PR / push the new tag. |
Fixes #335
This change fixes a bug where multiple threads and/or processes
using multistore_file to access the same backing store could
raise IOError errno.EDEADLK to the calling application. Since
EDEADLK is a possibility with concurrent access, this change
instead causes a fallback to read only mode and refresh
credentials if necessary.