vikin91 / BibSpace

BibSpace: Online Bibtex Publications Management Software for Authors and Research Groups
Other
6 stars 2 forks source link

IntegerUidProviders are not singletons in hypnotoad with multiple workers #10

Closed vikin91 closed 7 years ago

vikin91 commented 7 years ago
[Tue Feb  7 10:20:30 2017] WARNING: Id Provider for Tag          has addr '140607898259360', last_id: 231 (Origin: SmartUidProvider->get_provider).
...
[Tue Feb  7 10:20:33 2017] WARNING: Id Provider for Tag          has addr '140607891694720', last_id: 0 (Origin: SmartUidProvider->get_provider).
[Tue Feb  7 10:20:33 2017] DEBUG: IntegerUidProvider (140607891694720) has generated uid '1' for type 'Tag' (Origin: IntegerUidProvider->generateUID)

The address in memory of Tag ID Provider changes during operation...

vikin91 commented 7 years ago

Possibly-useful hints: https://groups.google.com/forum/#!msg/mojolicious/T9uH9a14CHM/Ujqpc2EPBgAJ

vikin91 commented 7 years ago

Starting BibSpace like seemed to cause no problems (but it does):

BIBSPACE_USE_DUMP=1  bin/bibspace daemon -m production -l http://*:8080
BIBSPACE_USE_DUMP=1  bin/bibspace daemon -m production -w 2 -l http://*:8080

but like this does:

BIBSPACE_USE_DUMP=1  bin/bibspace prefork -m production -w 2 -l http://*:8080
BIBSPACE_USE_DUMP=1  bin/bibspace prefork -m production -w 4 -c 10  -l http://*:8080

... and using hypnotoad do cause problems - even with single worker.

Testing called like this can reproduce problems:

BIBSPACE_CONFIG=/etc/bibspace_test.conf bin/bibspace test

Testing with prove seems to not discover the problems.

vikin91 commented 7 years ago

bin/bibspace daemon -l http://*:8080 causes problems on linux as well... this must be something else.

vikin91 commented 7 years ago

Next trait: this problem seems to be related with USE_BISPACE_DUMP and restoring backups. By restoration, the UIdProvider seems to be duplicated. Is this only a fixture error??

vikin91 commented 7 years ago

The problem seems to be located in:

package BibSpace::Functions::FDB;
...
my $drh = DBI->install_driver("mysql");
my $rc = $drh->func( 'dropdb', $db_database, $db_host, $db_user, $db_pass, 'admin' );
my $rc = $drh->func( 'createdb', $db_database, $db_host, $db_user, $db_pass, 'admin' );

Need more tests to make sure it is fixed now.

vikin91 commented 7 years ago

Starting the app on the test server using command: BIBSPACE_CONFIG=/etc/bibspace_test.conf BIBSPACE_USE_DUMP=0 MOJO_MODE=development hypnotoad -f bin/bibspace seems to cause no problems. Starting it with sudo service bibspace-test start (runs as root) causes problems. Maybe the issue is caused by sudo/root? Or maybe BIBSPACE_USE_DUMP=1 is the problem?

vikin91 commented 7 years ago

It seemed to be a problem with keeping some objects inside mojolicious has function. The function is executed only once at startup and during layer replacement the original object is not replaced with the new one, but exists alongside with it. This seems to be fixed finally in 4a0a63e

vikin91 commented 7 years ago

http://search.cpan.org/~sri/Mojolicious-7.25/lib/Mojolicious/Guides/Cookbook.pod#DEPLOYMENT