Rake test:units fails with Octopus

55 views
Skip to first unread message

Panayotis Matsinopoulos

unread,
Jan 4, 2012, 9:05:46 AM1/4/12
to Octopus - Database sharding for ActiveRecord
Hi,

I have the following program with Octopus.

When I run "rake" it fails with message of missing tables. After the
failure I log in my database and I see that the test database does not
contain any tables. This probably means that "rake", which invokes
"db:schema:load" didn't manage to run successfully.

I try "rake test:units" (which also fails) and put on "--trace" and I
see that it tries to drop the tables on my development database. Not
the test database.

When I remove the "shards.yml" file from my config directory, "rake"
and "rake test:units" works perfect.

I am using Octopus 0.4.0.

Does anybody have any clue about this problem?

Here are logs to help you out from mysql general log:

This is when I use shards.yml in my config file:
(as you can see though it creates the test database, it is connected
to the development database and tries to drop the accounts table).

120104 15:54:43 440 Query select 1
440 Query SHOW TABLES
440 Query select 1
440 Query SHOW TABLES
440 Query select 1
440 Query SHOW FIELDS FROM `schema_migrations`
440 Query select 1
440 Query select 1
440 Query select 1
440 Query select 1
440 Query SELECT `schema_migrations`.`version`
FROM `schema_migrations`
120104 15:54:45 440 Query select 1
440 Query select 1
440 Query SHOW TABLES
440 Query select 1
440 Query SHOW FIELDS FROM `schema_migrations`
440 Query select 1
440 Query select 1
440 Query select 1
440 Query select 1
440 Query SELECT `schema_migrations`.`version`
FROM `schema_migrations`
440 Quit
441 Connect ro...@10.0.0.123 on shop_development
441 Query SET SQL_AUTO_IS_NULL=0, NAMES 'utf8',
@@wait_timeout = 2592000
441 Query select 1
441 Query DROP DATABASE IF EXISTS `shop_test`
441 Query CREATE DATABASE `shop_test` DEFAULT
CHARACTER SET `utf8`
441 Query select 1
441 Query SHOW TABLES
441 Query DROP TABLE `accounts`
.....

This is when I do not have shards.yml in my config file:
(as you can see after getting the schema_migrations from development
database, it then goes to the test database0

120104 15:56:33 442 Connect ro...@10.0.0.123 on shop_development
442 Query SET SQL_AUTO_IS_NULL=0, NAMES 'utf8',
@@wait_timeout = 2592000
442 Query select 1
442 Query SHOW TABLES
442 Query SHOW TABLES
442 Query SHOW FIELDS FROM `schema_migrations`
442 Query SELECT `schema_migrations`.`version`
FROM `schema_migrations`
120104 15:56:35 442 Query SHOW TABLES
442 Query SHOW FIELDS FROM `schema_migrations`
442 Query SELECT `schema_migrations`.`version`
FROM `schema_migrations`
442 Quit
443 Connect ro...@10.0.0.123 on shop_test
443 Query SET SQL_AUTO_IS_NULL=0, NAMES 'utf8',
@@wait_timeout = 2592000
443 Query select 1
443 Query DROP DATABASE IF EXISTS `shop_test`
443 Query CREATE DATABASE `shop_test` DEFAULT
CHARACTER SET `utf8`
443 Quit
444 Connect ro...@10.0.0.123 on shop_test
444 Query SET SQL_AUTO_IS_NULL=0, NAMES 'utf8',
@@wait_timeout = 2592000
444 Query select 1
444 Query SHOW TABLES
444 Query CREATE TABLE `accounts` (`id`
......

Panayotis

Panayotis Matsinopoulos

unread,
Jan 4, 2012, 9:56:35 AM1/4/12
to Octopus - Database sharding for ActiveRecord
I found the error. It was that in my shards.yml file I was using the
"environments" tag (as the official documentation used to say).
I changed that to "octopus_environments" and now works ok. I am going
to edit the wiki pages of Octopus now to reflect this.

Panayotis


On Jan 4, 4:05 pm, Panayotis Matsinopoulos
>                   441 Connect   r...@10.0.0.123 on shop_development
>                   441 Query     SET SQL_AUTO_IS_NULL=0, NAMES 'utf8',
> @@wait_timeout = 2592000
>                   441 Query     select 1
>                   441 Query     DROP DATABASE IF EXISTS `shop_test`
>                   441 Query     CREATE DATABASE `shop_test` DEFAULT
> CHARACTER SET `utf8`
>                   441 Query     select 1
>                   441 Query     SHOW TABLES
>                   441 Query     DROP TABLE `accounts`
> .....
>
> This is when I do not have shards.yml in my config file:
> (as you can see after getting the schema_migrations from development
> database, it then goes to the test database0
>
> 120104 15:56:33   442 Connect   r...@10.0.0.123 on shop_development
>                   442 Query     SET SQL_AUTO_IS_NULL=0, NAMES 'utf8',
> @@wait_timeout = 2592000
>                   442 Query     select 1
>                   442 Query     SHOW TABLES
>                   442 Query     SHOW TABLES
>                   442 Query     SHOW FIELDS FROM `schema_migrations`
>                   442 Query     SELECT `schema_migrations`.`version`
> FROM `schema_migrations`
> 120104 15:56:35   442 Query     SHOW TABLES
>                   442 Query     SHOW FIELDS FROM `schema_migrations`
>                   442 Query     SELECT `schema_migrations`.`version`
> FROM `schema_migrations`
>                   442 Quit
>                   443 Connect   r...@10.0.0.123 on shop_test
>                   443 Query     SET SQL_AUTO_IS_NULL=0, NAMES 'utf8',
> @@wait_timeout = 2592000
>                   443 Query     select 1
>                   443 Query     DROP DATABASE IF EXISTS `shop_test`
>                   443 Query     CREATE DATABASE `shop_test` DEFAULT
> CHARACTER SET `utf8`
>                   443 Quit
>                   444 Connect   r...@10.0.0.123 on shop_test

Panayotis Matsinopoulos

unread,
Jan 4, 2012, 12:19:00 PM1/4/12
to Octopus - Database sharding for ActiveRecord
Ok....the case is still open and I would appreciate any help.

When I renamed "environments" to "octopus_environments", while "rake
test:units" worked ok, the application didn't work ok, i.e. it didn't
replicate. All the queries went to master and not to slave.

Any clue?



On Jan 4, 4:56 pm, Panayotis Matsinopoulos

Panayotis Matsinopoulos

unread,
Jan 5, 2012, 7:38:38 AM1/5/12
to Octopus - Database sharding for ActiveRecord
Update:

Read this one: https://github.com/pmatsinopoulos/octopus_replication_example

On 4 Ιαν, 19:19, Panayotis Matsinopoulos <panayo...@matsinopoulos.gr>
wrote:
> > > Panayotis- Απόκρυψη κειμένου σε παράθεση -
>
> - Εμφάνιση κειμένου σε παράθεση -
Reply all
Reply to author
Forward
0 new messages