Save fails if Dynamoid has to create a table
If the table does not yet exist, a call to model.save fails on first call and succeeds on subsequent calls.
irb(main):005:0> r.save
(456.44 ms) LIST TABLES - [[]]
(456.76 ms) CACHE TABLES
Creating olev_residentialapplications table. This could take a while.
(63.21 ms) CREATE TABLE
Aws::DynamoDB::Errors::ResourceNotFoundException: Requested resource not found
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/aws-sdk-core-2.3.1/lib/seahorse/client/plugins/raise_response_errors.rb:15:in `call'
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/aws-sdk-core-2.3.1/lib/aws-sdk-core/plugins/dynamodb_simple_attributes.rb:112:in `call'
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/aws-sdk-core-2.3.1/lib/aws-sdk-core/plugins/param_converter.rb:20:in `call'
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/aws-sdk-core-2.3.1/lib/seahorse/client/plugins/response_target.rb:21:in `call'
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/aws-sdk-core-2.3.1/lib/seahorse/client/request.rb:70:in `send_request'
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/aws-sdk-core-2.3.1/lib/seahorse/client/base.rb:207:in `block (2 levels) in define_operation_methods'
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/dynamoid-1.1.0/lib/dynamoid/adapter_plugin/aws_sdk_v2.rb:249:in `put_item'
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/dynamoid-1.1.0/lib/dynamoid/adapter.rb:139:in `block (3 levels) in <class:Adapter>'
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/dynamoid-1.1.0/lib/dynamoid/adapter.rb:53:in `benchmark'
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/dynamoid-1.1.0/lib/dynamoid/adapter.rb:139:in `block (2 levels) in <class:Adapter>'
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/dynamoid-1.1.0/lib/dynamoid/adapter.rb:68:in `write'
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/dynamoid-1.1.0/lib/dynamoid/persistence.rb:308:in `block in persist'
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:117:in `call'
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:555:in `block (2 levels) in compile'
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:505:in `call'
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:92:in `__run_callbacks__'
... 8 levels...
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:778:in `_run_create_callbacks'
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:81:in `run_callbacks'
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/dynamoid-1.1.0/lib/dynamoid/persistence.rb:165:in `save'
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/dynamoid-1.1.0/lib/dynamoid/validations.rb:17:in `save'
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/dynamoid-1.1.0/lib/dynamoid/identity_map.rb:68:in `save'
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/dynamoid-1.1.0/lib/dynamoid/dirty.rb:13:in `block in save'
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/dynamoid-1.1.0/lib/dynamoid/dirty.rb:28:in `clear_changes'
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/dynamoid-1.1.0/lib/dynamoid/dirty.rb:13:in `save'
from (irb):5
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/commands/console.rb:110:in `start'
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/commands/console.rb:9:in `start'
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:68:in `console'
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'irb(main):006:0> r.save
(595.87 ms) PUT ITEM - [["olev_residentialapplications", {:created_at=>1462523745.554208, :updated_at=>1462523745.554333, :id=>"d703d3fa-dc9b-445d-9b91-fd09a7fec770", :customer_name=>"aaa", :customer_adress=>"111"}, {:unless_exists=>[:id, :id]}]]
FYI I'm seeing this as well, doing more investigation.
+1
Please retry with newest 1.2.1. I've just added the ability to make create_table synchronous, but I may still need to integrate it into the save hook. Will find out. Please test new release!
This issue still persists in 1.2.1
Issue persists with gem pulled from master branch of repo as of today.
I will look into this if I have time. Otherwise, pull requests (with specs?) are welcome!
This is fixed in master. There will be a new release soon.
the same issue while using dynamoid (3.4.1)
@vsuzdaltsev
Could you reproduce it constantly? Please provide steps to reproduce.
@vsuzdaltsev
Could you reproduce it constantly? Please provide steps to reproduce.
Yes I can, but for now I'm not sure if I was doing all the things correctly. ->First of all tables are being created without any problems using rake.
But if I create something like
class Conf
include Dynamoid::Document
field :id
field :cloud
field :tenant
field :cloud_type
end
Conf.save
And run it It fails to create the table first time.
E, [2020-02-20T14:12:00.728364 #7] ERROR -- : app error: Requested resource not found (Aws::DynamoDB::Errors::ResourceNotFoundException)
But after running several times the table is being created successfully and the item saved
@vsuzdaltsev
Can you check the branch fix-table-lazy-creation-issue with a fix (https://github.com/Dynamoid/dynamoid/pull/414) and try to reproduce the issue?