Last Comment Bug 476943 - Edit multiple issues token after switching to shadow DB
: Edit multiple issues token after switching to shadow DB
Status: RESOLVED FIXED
: regression, selenium
Product: Bugzilla
Classification: Server Software
Component: Query/Bug List (show other bugs)
: 3.2.2
: All All
: -- normal (vote)
: Bugzilla 3.2
Assigned To: Greg Hendricks
: default-qa
Mentors:
: 476884 (view as bug list)
Depends on: 26257
Blocks:
  Show dependency treegraph
 
Reported: 2009-02-04 14:18 PST by Greg Hendricks
Modified: 2011-09-23 15:31 PDT (History)
4 users (show)
mkanat: approval+
mkanat: approval3.2+
LpSolit: blocking3.2.3+
LpSolit: testcase+
See Also:
QA Whiteboard:
Iteration: ---
Points: ---


Attachments
V1 (1.04 KB, patch)
2009-02-04 14:38 PST, Greg Hendricks
mkanat: review-
Details | Diff | Splinter Review
V2 (791 bytes, patch)
2009-02-04 15:36 PST, Greg Hendricks
mkanat: review-
Details | Diff | Splinter Review
V3 (777 bytes, patch)
2009-02-05 08:32 PST, Greg Hendricks
mkanat: review+
Details | Diff | Splinter Review

Description Greg Hendricks 2009-02-04 14:18:22 PST
As part of the fix to Bug 466748 a token is now generated in buglist.cgi. This is done after the switch to the shadow db, meaning that issue_token tries to write the token to the shadow database. If the shadow is in readonly mode (as it should be), this will fail with the following error:

DBD::mysql::db do failed: The MySQL server is running with the --read-only option so it cannot execute this statement [for Statement "INSERT INTO tokens (userid, issuedate, token, tokentype, eventdata)
        VALUES (?, NOW(), ?, ?, ?)"] at Bugzilla/Token.pm line 418
	Bugzilla::Token::_create_token(9, 'session', 'buglist_mass_change') called at Bugzilla/Token.pm line 173
	Bugzilla::Token::issue_session_token('buglist_mass_change') called at /shared/bugzilla/docroot/buglist.cgi line 1252
Comment 1 Greg Hendricks 2009-02-04 14:38:52 PST
Created attachment 360590 [details] [diff] [review]
V1

I have tested this on our installation and it seems to work.
Comment 2 Max Kanat-Alexander 2009-02-04 14:53:47 PST
Comment on attachment 360590 [details] [diff] [review]
V1

This then generates the token for all searches, which we definitely don't want to do.

What would probably be ideal would be function like:

  on_main_db {
    issue_session_token
  }

  This can be accomplished by writing a function with a prototype of (&).

Then we can make sure that certain code always runs on the main DB even if we're currently on the shadow DB.

So that's my thought unless you have any other idea. I'm not perfectly happy with it, because it seems like a hacky solution instead of a good architectural solution, but it's the best idea I have.
Comment 3 Max Kanat-Alexander 2009-02-04 14:58:45 PST
But for 3.2, you can just wrap it in switch_to_main_db and switch_to_shadow_db.
Comment 4 Frédéric Buclin 2009-02-04 14:59:34 PST
(In reply to comment #3)
> But for 3.2, you can just wrap it in switch_to_main_db and switch_to_shadow_db.

I think you should use them even on tip. We don't need anything else.
Comment 5 Greg Hendricks 2009-02-04 15:36:00 PST
Created attachment 360601 [details] [diff] [review]
V2
Comment 6 Frédéric Buclin 2009-02-04 15:45:01 PST
(In reply to comment #0)
> As part of the fix to Bug 466748 a token is now generated in buglist.cgi.

No, this token has been introduced in bug 26257, which affects 3.2.1 and newer only. 3.0.x is not affected.
Comment 7 Max Kanat-Alexander 2009-02-04 18:13:14 PST
Comment on attachment 360601 [details] [diff] [review]
V2

You actually don't even need the $dbh = bits. Could I get a new patch without them? (I just don't like relying on checkin fixes for important multi-branch patches like this one.)
Comment 8 Greg Hendricks 2009-02-05 08:32:22 PST
Created attachment 360732 [details] [diff] [review]
V3

I just copied and pasted without looking closely. Sorry. Fixed now.
Comment 9 Max Kanat-Alexander 2009-02-05 08:33:05 PST
Comment on attachment 360732 [details] [diff] [review]
V3

Looks fine.
Comment 10 Greg Hendricks 2009-02-05 08:37:23 PST
    Checking in buglist.cgi;
    /cvsroot/mozilla/webtools/bugzilla/buglist.cgi,v  <--  buglist.cgi
    new revision: 1.374.2.8; previous revision: 1.374.2.7
Comment 11 Frédéric Buclin 2009-02-05 08:42:04 PST
Please also commit it on tip.
Comment 12 Greg Hendricks 2009-02-05 09:14:04 PST
    Checking in buglist.cgi;
    /cvsroot/mozilla/webtools/bugzilla/buglist.cgi,v  <--  buglist.cgi
    new revision: 1.393; previous revision: 1.392
Comment 13 Frédéric Buclin 2009-02-05 10:12:05 PST
*** Bug 476884 has been marked as a duplicate of this bug. ***
Comment 14 Frédéric Buclin 2009-02-17 07:37:39 PST
Will be tested by test_bug_editing.t, see qa bug 3098.

Note You need to log in before you can comment on or make changes to this bug.