X Tutup
Skip to content

fix improper use of iteration#1552

Merged
pongad merged 3 commits intogoogleapis:pubsub-hpfrom
pongad:fix-iter
Jan 24, 2017
Merged

fix improper use of iteration#1552
pongad merged 3 commits intogoogleapis:pubsub-hpfrom
pongad:fix-iter

Conversation

@pongad
Copy link
Copy Markdown
Contributor

@pongad pongad commented Jan 19, 2017

cc @davidtorres

The previous implementation modifies a HashMap while iterating through
its key set, causeing unpredictable iteration behavior.
This might be the reason our tests intermittently deadlock.

The new implementation uses a PriorityQueue.
The time complexity is O(M * log N),
where M is the number of expirations before the cut over time
and N is the total number of expirations.
I am not sure how this compares to O(N) intended in the previous
implementation.
If required, O(N) is also possible using an ArrayList.

Unfortunately, a new failure has emerged.
Instead of deadlocking, testModifyAckDeadline intermittently fails.
Maybe

  • I have fixed the old bug and created a new one,
  • I have fixed the old bug that was masking another one,
  • The deadlock wasn't caused by the iteration. Now the tests just fail
    before they could deadlock,
    or some combination thereof.
    The incorrect iteration should be fixed regardless.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

X Tutup