Skip to content

Avoid infinite loop during session garbage collection. #6

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

Merged
merged 1 commit into from
Mar 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/aws/session_store/dynamo_db/garbage_collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def eliminate_unwanted_sessions(config, last_key = nil)
# @api private
def scan(config, last_item = nil)
options = scan_opts(config)
options.merge(start_key(last_item)) if last_item
options = options.merge(start_key(last_item)) if last_item
config.dynamo_db_client.scan(options)
end

Expand Down
5 changes: 4 additions & 1 deletion spec/aws/session_store/dynamo_db/garbage_collection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,10 @@ def collect_garbage

it "gets scan results then returns last evaluated key and resumes scanning" do
dynamo_db_client.should_receive(:scan).
exactly(2).times.and_return(scan_resp2, scan_resp3)
exactly(1).times.and_return(scan_resp2)
dynamo_db_client.should_receive(:scan).
exactly(1).times.with(hash_including({:exclusive_start_key => scan_resp2.last_evaluated_key})).
and_return(scan_resp3)
dynamo_db_client.should_receive(:batch_write_item).
exactly(3).times.and_return(write_resp1)
collect_garbage
Expand Down