-
Notifications
You must be signed in to change notification settings - Fork 21.3k
accounts/keystore: fix flaky test TestWalletNotifications
#30053
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
base: master
Are you sure you want to change the base?
Conversation
Could you dump out the difference between |
@MariusVanDerWijden I have Dumped out the difference between It's more difficult to fix |
@MariusVanDerWijden I have found the reason for
If we only fix the flaky test issue, to avoid executing 4m15s: 22560 runs so far, 0 failures
4m20s: 22988 runs so far, 0 failures
4m25s: 23383 runs so far, 0 failures
4m30s: 23813 runs so far, 0 failures
4m35s: 24238 runs so far, 0 failures
4m40s: 24664 runs so far, 0 failures
4m45s: 25082 runs so far, 0 failures
4m50s: 25537 runs so far, 0 failures
4m55s: 25990 runs so far, 0 failures
5m0s: 26422 runs so far, 0 failures
5m5s: 26863 runs so far, 0 failures
5m10s: 27315 runs so far, 0 failures
5m15s: 27758 runs so far, 0 failures
5m20s: 28207 runs so far, 0 failures
5m25s: 28631 runs so far, 0 failures |
@MariusVanDerWijden Upgraded to use |
TestWalletNotifications
Cool nice find, reaching into the cache to acquire the lock kinda feels a bit weird to me. Feels like we are crossing the boundaries of our abstraction. I will think a bit about it |
I'm not sure about the changes in |
Then there must be something wrong with the order of events sent by wallet addition and removal. All events were handled correctly indeed, no events were missing actually, but they were not in the expected order. |
edit: nm, it looks like these changes now fix the |
There is no event missing. All events were handled correctly indeed, no events were missing actually, but they were not in the expected order. We need to find out why they are out of order. |
ks.cache.fileC.mu.Lock() | ||
defer ks.cache.fileC.mu.Unlock() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit of a "code-smell", to me. The KeyStore just reaches right into the member cache
, and then reaches one step further into the fileC
and just uses it's mutex.
There must be some more modular way of achieving the goal (I'm not 100% sure what the underlying problem that this solves, is).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One way to do it would be to first load and zero the key, and when that is done, invoke ks.cache.Remove(a)
. And then Remove
would obtain the lock, delete the file on disk, delete it in cache.
So instead of
err = os.Remove(a.URL.Path)
if err == nil {
ks.cache.delete(a)
ks.refreshWallets()
}
return err
if err = ks.cache.DeleteFile(a); err != nil{
return err
}
ks.refreshWallets()
return nil
Just an idea...
This PR fixes the
checkEvents
part of the flaky testTestWalletNotifications
. There is another flaky failure forcheckAccounts
.The original logic of
checkEvents
seems to ask for bothwantEvents
andhaveEvents
to keep a consistent order so that this function could work correctly.But actually, the order of both is not consistent. See the failed log comment on #29830
keystore_test.go:455: can't find event with Kind=2 for 56fe5c503fb7f1850298b7d6896cfd8019b525e1
Before this patch, the stress test of
TestWalletNotifications
failed bycheckAccounts
andcheckEvents
After this patch, the stress test of
TestWalletNotifications
only failed bycheckAccounts
.