Bug 17240 - Allow processes that rely on background jobs run in Plack mode
Summary: Allow processes that rely on background jobs run in Plack mode
Status: In Discussion
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: master
Hardware: All All
: P5 - low normal (vote)
Assignee: Fridolin SOMERS
QA Contact: Testopia
URL:
Whiteboard:
Keywords:
Depends on: 15218
Blocks:
  Show dependency treegraph
 
Reported: 2016-09-02 10:26 UTC by Fridolin SOMERS
Modified: 2017-06-28 09:11 UTC (History)
4 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Bot Control: ---
When did the bot last check this:
Who signed the patch off:
Text to go in the release notes:


Attachments
Bug 17240 - Allow processes that rely on background jobs run in Plack mode (1.67 KB, patch)
2016-09-02 10:33 UTC, Fridolin SOMERS
Details | Diff | Splinter Review
Bug 17240 - Allow processes that rely on background jobs run in Plack mode - prepare (1.68 KB, patch)
2016-09-02 10:34 UTC, Fridolin SOMERS
Details | Diff | Splinter Review
Bug 17240 - Allow processes that rely on background jobs run in Plack mode - prepare (3.36 KB, patch)
2016-09-02 13:31 UTC, Fridolin SOMERS
Details | Diff | Splinter Review
Bug 17240 - Allow processes that rely on background jobs run in Plack mode (7.76 KB, patch)
2016-09-02 13:32 UTC, Fridolin SOMERS
Details | Diff | Splinter Review
Bug 17240 - Allow processes that rely on background jobs run in Plack mode - prepare (3.36 KB, patch)
2016-09-02 14:15 UTC, Fridolin SOMERS
Details | Diff | Splinter Review
Bug 17240 - Allow processes that rely on background jobs run in Plack mode (7.76 KB, patch)
2016-09-02 14:15 UTC, Fridolin SOMERS
Details | Diff | Splinter Review
Bug 17240 - Allow processes that rely on background jobs run in Plack mode - followup (2.84 KB, patch)
2016-09-06 12:48 UTC, Fridolin SOMERS
Details | Diff | Splinter Review
Bug 17240 - Allow processes that rely on background jobs run in Plack mode - followup 2 (1.22 KB, patch)
2016-12-28 08:55 UTC, Fridolin SOMERS
Details | Diff | Splinter Review
Bug 17240 - Allow processes that rely on background jobs run in Plack mode - followup 3 (2.38 KB, patch)
2017-05-09 14:40 UTC, Fridolin SOMERS
Details | Diff | Splinter Review
Bug 17240 - Allow processes that rely on background jobs run in Plack mode - followup 3 (3.26 KB, patch)
2017-05-15 06:44 UTC, Fridolin SOMERS
Details | Diff | Splinter Review
Bug 17240 - Allow processes that rely on background jobs run in Plack mode - followup 3 (3.75 KB, patch)
2017-05-31 11:00 UTC, Fridolin SOMERS
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Fridolin SOMERS 2016-09-02 10:26:45 UTC
Since Plack mode (PSGI), the processes running with background jobs are broken.

Bug 15218 corrected by using CGI mode for concerned pages.

This patch proposes to allow running those pages in PSGI mode by disabling background jobs when PSGI is used.
Comment 1 Fridolin SOMERS 2016-09-02 10:33:51 UTC Comment hidden (obsolete)
Comment 2 Fridolin SOMERS 2016-09-02 10:34:38 UTC Comment hidden (obsolete)
Comment 3 Fridolin SOMERS 2016-09-02 13:31:40 UTC Comment hidden (obsolete)
Comment 4 Fridolin SOMERS 2016-09-02 13:32:00 UTC Comment hidden (obsolete)
Comment 5 Fridolin SOMERS 2016-09-02 14:15:12 UTC
Created attachment 55137 [details] [review]
Bug 17240 - Allow processes that rely on background jobs run in Plack mode - prepare

This adds prepares the main one by adding method "is_psgi" to C4::Context and using it in C4::Auth for all templates.
It is used by about.pl and Koha::AuthUtils.

Test plan :
- On a Koha running with Plack
- Go to about.pl
- Look at line "PGSI:"
=> You should see "Plack"
- Enable CAS authentication
- Go to OPAC auth page
- Look at the CAS link
=> You see the current page in this URL
Comment 6 Fridolin SOMERS 2016-09-02 14:15:24 UTC
Created attachment 55138 [details] [review]
Bug 17240 - Allow processes that rely on background jobs run in Plack mode

Since Plack mode (PSGI), the processes running with background jobs are broken.

Bug 15218 corrected by using CGI mode for concerned pages.

This patch proposes to allow running those pages in PSGI mode by disabling background jobs when PSGI is used.

Script are running so faster with Plack, there are less chances that the process will end in HTTP timeout.

Test plan :
 - on a Koha running with plack
 - revert Bug 15218 changes
 - test processes on pages :
     offline_circ/process_koc.pl
     tools/batchMod-edit.pl
     tools/batch_record_modification.pl
     tools/manage-marc-import.pl
     tools/stage-marc-import.pl
     tools/upload-images.pl
Comment 7 Jonathan Druart 2016-09-05 09:51:21 UTC
Not sure it makes sense to disable the background mode. Did you try and edit 100k bibliographic records or items or patrons?
Comment 8 Tomás Cohen Arazi 2016-09-05 14:58:03 UTC
I don't agree with the proposed solution (we should make it work). But I love the first patch, it should have it's own bug, something like "Add C4::Context->is_psgi" in the title :-D
Comment 9 Marcel de Rooy 2016-09-05 19:43:47 UTC
We should probably remove all fork calls. Resolve it with an ajax call (like the upload in one of these scripts) or via a queue serviced by some daemon.
In general, it seems better to prevent starting jobs directly by the web interface.
Comment 10 Fridolin SOMERS 2016-09-06 10:42:05 UTC
(In reply to Jonathan Druart from comment #7)
> Not sure it makes sense to disable the background mode. Did you try and edit
> 100k bibliographic records or items or patrons?

(In reply to Tomás Cohen Arazi from comment #8)
> I don't agree with the proposed solution (we should make it work).

But since in PSGI mode it is broken, why not make it work quickly ?
A revamping may take a while.
Comment 11 Fridolin SOMERS 2016-09-06 12:48:28 UTC
Created attachment 55257 [details] [review]
Bug 17240 - Allow processes that rely on background jobs run in Plack mode - followup

Followup
If not running in background mode, some calls are made on $job var.
Comment 12 Fridolin SOMERS 2016-12-28 08:55:57 UTC
Created attachment 58461 [details] [review]
Bug 17240 - Allow processes that rely on background jobs run in Plack mode - followup 2

Followup 2
If not running in background mode, some calls are made on $job var in tools/batch_record_modification.pl.
Comment 13 Fridolin SOMERS 2017-01-11 15:11:28 UTC
I should split this into several bugs.
Comment 14 Fridolin SOMERS 2017-05-09 14:40:16 UTC
Created attachment 63291 [details] [review]
Bug 17240 - Allow processes that rely on background jobs run in Plack mode - followup 3

Followup 3
If not running in background mode, items are not displayed in result page in tools/batchMod.pl.
Comment 15 Fridolin SOMERS 2017-05-15 06:44:55 UTC
Created attachment 63459 [details] [review]
Bug 17240 - Allow processes that rely on background jobs run in Plack mode - followup 3

Followup 3
If not running in background mode, items are not displayed in result page in tools/batchMod.pl.
Also the number of items and fields are missing in message.
Comment 16 Fridolin SOMERS 2017-05-31 11:00:55 UTC
Created attachment 63862 [details] [review]
Bug 17240 - Allow processes that rely on background jobs run in Plack mode - followup 3

Followup 3
If not running in background mode, items are not displayed in result page in tools/batchMod.pl.
Also the number of items and fields are missing in message.