Skip to content
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

ActiveRecord::RecordInvalid: Validation failed: Interval end can't be in the past #17

Open
fernaper opened this issue Sep 23, 2020 · 1 comment

Comments

@fernaper
Copy link

Hi,

I am trying to install RTB4Free with Docker and docker-compose, I just copy the docker-compose.yml from:

https://rtb4free.readthedocs.io/en/latest/intro/getting-started-with-docker.html

The problem is that I am getting an error on campaign manager.

Frist, I can't access, with the user and password, [email protected] and rtb4free respectively:
image

I tried to go inside campaign-manager, and execute from scratch rake db:setup, but it I get the following response:

# rake db:setup --trace
** Invoke db:setup (first_time)
** Invoke db:schema:load_if_ruby (first_time)
** Invoke db:create (first_time)
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:create
rtb4free already exists
rtb4free already exists
** Invoke environment (first_time)
** Execute environment
Setting CUSTOMER_NAME to RTB4FREE (string)
Setting BIDDER_TIME_OFFSET to 0 (number)
Setting RTB4FREE_DATABASE_HOST to localhost (string)
Setting RTB4FREE_DATABASE_PORT to 3306 (number)
Setting RTB4FREE_DATABASE_USERNAME to root (string)
Setting RTB4FREE_DATABASE_PASSWORD to  (string)
Setting RTB4FREE_DATABASE_NAME to rtb4free (string)
Setting ELASTICSEARCH_ENABLE to true (boolean)
Setting ELASTICSEARCH_HOST to elastic:9200 (string)
Setting ELASTICSEARCH_KIBANA_URL to http://kibana:5601/ (string)
Setting ELASTICSEARCH_HOSTS to {"US" => "elastic1:9200"} (hash)
Setting ELASTICSEARCH_REQUESTS_INDEX to requests-* (string)
Setting ELASTICSEARCH_BIDS_INDEX to bids-* (string)
Setting ELASTICSEARCH_WINS_INDEX to wins-* (string)
Setting ELASTICSEARCH_PIXELS_INDEX to pixels-* (string)
Setting ELASTICSEARCH_CLICKS_INDEX to clicks-* (string)
Setting ELASTICSEARCH_STATS_INDEX to status-* (string)
Setting RTB_CROSSTALK_REGION_HOSTS to {"US" => "crosstalk"} (hash)
Setting RTB_CROSSTALK_PORT to 8100 (string)
Setting RTB_CROSSTALK_USER to ben* (string)
Setting RTB_CROSSTALK_PASSWORD to test (string)
Setting AWS_ACCESS_KEY_S3 to XXXXXXXX (string)
Setting AWS_SECRET_KEY_S3 to XXXXXXXX (string)
Setting AWS_REGION_S3 to us-east-1 (string)
Setting AWS_S3_BUCKET to my-rtb4free-bidder-lists (string)
Setting AWS_S3_BASE_URL to https://s3.amazonaws.com/my-rtb4free-bidder-lists (string)
Setting RTB_REPORT_TIMEZONE to America/Los_Angeles (string)
** Execute db:schema:load_if_ruby
** Invoke db:schema:load (first_time)
** Invoke environment 
** Invoke db:load_config 
** Execute db:schema:load
-- create_table("attachments", {:force=>:cascade})
   -> 0.4850s
-- create_table("banner_videos", {:force=>:cascade})
   -> 0.4517s
-- create_table("banner_videos_rtb_standards", {:id=>false, :force=>:cascade})
   -> 0.4936s
-- add_index("banner_videos_rtb_standards", ["banner_video_id"], {:name=>"index_banner_videos_rtb_standards_on_banner_video_id", :using=>:btree})
   -> 0.3337s
-- add_index("banner_videos_rtb_standards", ["rtb_standard_id"], {:name=>"index_banner_videos_rtb_standards_on_rtb_standard_id", :using=>:btree})
   -> 0.4661s
-- create_table("banners", {:force=>:cascade})
   -> 0.4115s
-- create_table("banners_rtb_standards", {:id=>false, :force=>:cascade})
   -> 0.4179s
-- add_index("banners_rtb_standards", ["banner_id"], {:name=>"index_banners_rtb_standards_on_banner_id", :using=>:btree})
   -> 0.4173s
-- add_index("banners_rtb_standards", ["rtb_standard_id"], {:name=>"index_banners_rtb_standards_on_rtb_standard_id", :using=>:btree})
   -> 0.2846s
-- create_table("campaigns", {:force=>:cascade})
   -> 0.6946s
-- create_table("campaigns_rtb_standards", {:id=>false, :force=>:cascade})
   -> 0.6930s
-- add_index("campaigns_rtb_standards", ["campaign_id"], {:name=>"index_campaigns_rtb_standards_on_campaign_id", :using=>:btree})
   -> 0.2593s
-- add_index("campaigns_rtb_standards", ["rtb_standard_id"], {:name=>"index_campaigns_rtb_standards_on_rtb_standard_id", :using=>:btree})
   -> 0.2519s
-- create_table("categories", {:force=>:cascade})
   -> 0.5084s
-- create_table("categories_documents", {:id=>false, :force=>:cascade})
   -> 0.5192s
-- add_index("categories_documents", ["category_id"], {:name=>"index_categories_documents_on_category_id", :using=>:btree})
   -> 0.2419s
-- add_index("categories_documents", ["document_id"], {:name=>"index_categories_documents_on_document_id", :using=>:btree})
   -> 0.3091s
-- create_table("countries", {:force=>:cascade})
   -> 0.5271s
-- create_table("documents", {:force=>:cascade})
   -> 0.3930s
-- create_table("exchange_attributes", {:force=>:cascade})
   -> 0.4768s
-- add_index("exchange_attributes", ["banner_id"], {:name=>"index_exchange_attributes_on_banner_id", :using=>:btree})
   -> 0.2917s
-- add_index("exchange_attributes", ["banner_video_id"], {:name=>"index_exchange_attributes_on_banner_video_id", :using=>:btree})
   -> 0.3424s
-- create_table("exchange_rtbspecs", {:force=>:cascade})
   -> 0.7611s
-- create_table("exchange_smarty_ads_rtbspecs", {:force=>:cascade})
   -> 0.6017s
-- create_table("iab_categories", {:force=>:cascade})
   -> 0.5597s
-- create_table("lists", {:force=>:cascade})
   -> 0.5430s
-- create_table("report_commands", {:force=>:cascade})
   -> 0.6267s
-- create_table("rtb_standards", {:force=>:cascade})
   -> 0.6277s
-- create_table("stats_rtb", {:force=>:cascade})
   -> 0.5856s
-- create_table("targets", {:force=>:cascade})
   -> 0.7269s
-- create_table("users", {:force=>:cascade})
   -> 0.5435s
-- initialize_schema_migrations_table()
   -> 0.0476s
-- create_table("attachments", {:force=>:cascade})
   -> 0.5778s
-- create_table("banner_videos", {:force=>:cascade})
   -> 0.4758s
-- create_table("banner_videos_rtb_standards", {:id=>false, :force=>:cascade})
   -> 0.4927s
-- add_index("banner_videos_rtb_standards", ["banner_video_id"], {:name=>"index_banner_videos_rtb_standards_on_banner_video_id", :using=>:btree})
   -> 0.3681s
-- add_index("banner_videos_rtb_standards", ["rtb_standard_id"], {:name=>"index_banner_videos_rtb_standards_on_rtb_standard_id", :using=>:btree})
   -> 0.3499s
-- create_table("banners", {:force=>:cascade})
   -> 0.4935s
-- create_table("banners_rtb_standards", {:id=>false, :force=>:cascade})
   -> 0.5435s
-- add_index("banners_rtb_standards", ["banner_id"], {:name=>"index_banners_rtb_standards_on_banner_id", :using=>:btree})
   -> 0.3588s
-- add_index("banners_rtb_standards", ["rtb_standard_id"], {:name=>"index_banners_rtb_standards_on_rtb_standard_id", :using=>:btree})
   -> 0.2673s
-- create_table("campaigns", {:force=>:cascade})
   -> 0.4350s
-- create_table("campaigns_rtb_standards", {:id=>false, :force=>:cascade})
   -> 0.6185s
-- add_index("campaigns_rtb_standards", ["campaign_id"], {:name=>"index_campaigns_rtb_standards_on_campaign_id", :using=>:btree})
   -> 0.2920s
-- add_index("campaigns_rtb_standards", ["rtb_standard_id"], {:name=>"index_campaigns_rtb_standards_on_rtb_standard_id", :using=>:btree})
   -> 0.3591s
-- create_table("categories", {:force=>:cascade})
   -> 0.4936s
-- create_table("categories_documents", {:id=>false, :force=>:cascade})
   -> 0.4763s
-- add_index("categories_documents", ["category_id"], {:name=>"index_categories_documents_on_category_id", :using=>:btree})
   -> 0.2260s
-- add_index("categories_documents", ["document_id"], {:name=>"index_categories_documents_on_document_id", :using=>:btree})
   -> 0.2507s
-- create_table("countries", {:force=>:cascade})
   -> 0.9771s
-- create_table("documents", {:force=>:cascade})
   -> 0.4675s
-- create_table("exchange_attributes", {:force=>:cascade})
   -> 0.5101s
-- add_index("exchange_attributes", ["banner_id"], {:name=>"index_exchange_attributes_on_banner_id", :using=>:btree})
   -> 0.3259s
-- add_index("exchange_attributes", ["banner_video_id"], {:name=>"index_exchange_attributes_on_banner_video_id", :using=>:btree})
   -> 0.3098s
-- create_table("exchange_rtbspecs", {:force=>:cascade})
   -> 0.4853s
-- create_table("exchange_smarty_ads_rtbspecs", {:force=>:cascade})
   -> 0.5187s
-- create_table("iab_categories", {:force=>:cascade})
   -> 0.5516s
-- create_table("lists", {:force=>:cascade})
   -> 0.6184s
-- create_table("report_commands", {:force=>:cascade})
   -> 0.8526s
-- create_table("rtb_standards", {:force=>:cascade})
   -> 0.6769s
-- create_table("stats_rtb", {:force=>:cascade})
   -> 0.4599s
-- create_table("targets", {:force=>:cascade})
   -> 0.5012s
-- create_table("users", {:force=>:cascade})
   -> 0.7117s
-- initialize_schema_migrations_table()
   -> 0.0022s
** Invoke db:structure:load_if_sql (first_time)
** Invoke db:create 
** Invoke environment 
** Execute db:structure:load_if_sql
** Invoke db:seed (first_time)
** Execute db:seed
** Invoke db:abort_if_pending_migrations (first_time)
** Invoke environment 
** Execute db:abort_if_pending_migrations
rake aborted!
ActiveRecord::RecordInvalid: Validation failed: Interval end can't be in the past
/usr/local/bundle/gems/activerecord-4.2.11/lib/active_record/validations.rb:79:in `raise_record_invalid'
/usr/local/bundle/gems/activerecord-4.2.11/lib/active_record/validations.rb:43:in `save!'
/usr/local/bundle/gems/activerecord-4.2.11/lib/active_record/attribute_methods/dirty.rb:29:in `save!'
/usr/local/bundle/gems/activerecord-4.2.11/lib/active_record/transactions.rb:291:in `block in save!'
/usr/local/bundle/gems/activerecord-4.2.11/lib/active_record/transactions.rb:351:in `block in with_transaction_returning_status'
/usr/local/bundle/gems/activerecord-4.2.11/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `block in transaction'
/usr/local/bundle/gems/activerecord-4.2.11/lib/active_record/connection_adapters/abstract/transaction.rb:184:in `within_new_transaction'
/usr/local/bundle/gems/activerecord-4.2.11/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction'
/usr/local/bundle/gems/activerecord-4.2.11/lib/active_record/transactions.rb:220:in `transaction'
/usr/local/bundle/gems/activerecord-4.2.11/lib/active_record/transactions.rb:348:in `with_transaction_returning_status'
/usr/local/bundle/gems/activerecord-4.2.11/lib/active_record/transactions.rb:291:in `save!'
/usr/local/bundle/gems/activerecord-4.2.11/lib/active_record/persistence.rb:51:in `create!'
/usr/local/bundle/gems/activerecord-4.2.11/lib/active_record/persistence.rb:48:in `block in create!'
/usr/local/bundle/gems/activerecord-4.2.11/lib/active_record/persistence.rb:48:in `collect'
/usr/local/bundle/gems/activerecord-4.2.11/lib/active_record/persistence.rb:48:in `create!'
/campaign-manager/db/seeds.rb:1:in `<top (required)>'
/usr/local/bundle/gems/activesupport-4.2.11/lib/active_support/dependencies.rb:268:in `load'
/usr/local/bundle/gems/activesupport-4.2.11/lib/active_support/dependencies.rb:268:in `block in load'
/usr/local/bundle/gems/activesupport-4.2.11/lib/active_support/dependencies.rb:240:in `load_dependency'
/usr/local/bundle/gems/activesupport-4.2.11/lib/active_support/dependencies.rb:268:in `load'
/usr/local/bundle/gems/railties-4.2.11/lib/rails/engine.rb:547:in `load_seed'
/usr/local/bundle/gems/activerecord-4.2.11/lib/active_record/tasks/database_tasks.rb:253:in `load_seed'
/usr/local/bundle/gems/activerecord-4.2.11/lib/active_record/railties/databases.rake:173:in `block (2 levels) in <top (required)>'
/usr/local/bundle/gems/rake-12.3.2/lib/rake/task.rb:273:in `block in execute'
/usr/local/bundle/gems/rake-12.3.2/lib/rake/task.rb:273:in `each'
/usr/local/bundle/gems/rake-12.3.2/lib/rake/task.rb:273:in `execute'
/usr/local/bundle/gems/rake-12.3.2/lib/rake/task.rb:214:in `block in invoke_with_call_chain'
/usr/local/lib/ruby/2.4.0/monitor.rb:214:in `mon_synchronize'
/usr/local/bundle/gems/rake-12.3.2/lib/rake/task.rb:194:in `invoke_with_call_chain'
/usr/local/bundle/gems/rake-12.3.2/lib/rake/task.rb:238:in `block in invoke_prerequisites'
/usr/local/bundle/gems/rake-12.3.2/lib/rake/task.rb:236:in `each'
/usr/local/bundle/gems/rake-12.3.2/lib/rake/task.rb:236:in `invoke_prerequisites'
/usr/local/bundle/gems/rake-12.3.2/lib/rake/task.rb:213:in `block in invoke_with_call_chain'
/usr/local/lib/ruby/2.4.0/monitor.rb:214:in `mon_synchronize'
/usr/local/bundle/gems/rake-12.3.2/lib/rake/task.rb:194:in `invoke_with_call_chain'
/usr/local/bundle/gems/rake-12.3.2/lib/rake/task.rb:183:in `invoke'
/usr/local/bundle/gems/rake-12.3.2/lib/rake/application.rb:160:in `invoke_task'
/usr/local/bundle/gems/rake-12.3.2/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/usr/local/bundle/gems/rake-12.3.2/lib/rake/application.rb:116:in `each'
/usr/local/bundle/gems/rake-12.3.2/lib/rake/application.rb:116:in `block in top_level'
/usr/local/bundle/gems/rake-12.3.2/lib/rake/application.rb:125:in `run_with_threads'
/usr/local/bundle/gems/rake-12.3.2/lib/rake/application.rb:110:in `top_level'
/usr/local/bundle/gems/rake-12.3.2/lib/rake/application.rb:83:in `block in run'
/usr/local/bundle/gems/rake-12.3.2/lib/rake/application.rb:186:in `standard_exception_handling'
/usr/local/bundle/gems/rake-12.3.2/lib/rake/application.rb:80:in `run'
/usr/local/bundle/gems/rake-12.3.2/exe/rake:27:in `<top (required)>'
/usr/local/bundle/bin/rake:23:in `load'
/usr/local/bundle/bin/rake:23:in `<main>'
Tasks: TOP => db:setup => db:seed

I'm not much of a Ruby expert, so I don't know how I can fix it.
Can anyone give me a hint?

Thanks in advance,
Fernando

@deepshig
Copy link

deepshig commented Oct 17, 2020

In seeds.rb, there is a record each for banners and bannervideos with interval_end: "2020-01-01 00:00:00". However, in models, there is a validation check which says that if interval_end < Time.now, it is invalid.

Clearly, current time is more than the given interval_end timestamp. Thus, this validation is failing. We need to change the seed data to fix this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants