Implement lazy database creation for sessions

Created on 15 March 2024, 9 months ago
Updated 4 April 2024, 9 months ago

Problem/Motivation

If we want to do πŸ“Œ Stop installing system module before everything else Needs work we need sessions to work without system module being installed first. We've got an established pattern for this already used for cache/batch/dblog etc. and SessionHandler can implement the same thing.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

πŸ“Œ Task
Status

Fixed

Version

11.0 πŸ”₯

Component
BaseΒ  β†’

Last updated 1 day ago

Created by

πŸ‡¬πŸ‡§United Kingdom catch

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @catch
  • Pipeline finished with Failed
    9 months ago
    Total: 187s
    #120289
  • Pipeline finished with Failed
    9 months ago
    Total: 188s
    #120307
  • Status changed to Needs review 9 months ago
  • πŸ‡¬πŸ‡§United Kingdom catch
  • Pipeline finished with Success
    9 months ago
    Total: 563s
    #120319
  • πŸ‡¬πŸ‡§United Kingdom catch
  • Status changed to Needs work 9 months ago
  • πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts

    Seems relatively straightforward, but I have some complaints about the code. :)

  • Status changed to Needs review 9 months ago
  • πŸ‡¬πŸ‡§United Kingdom catch

    Addressed all the feedback I think.

  • πŸ‡«πŸ‡·France andypost

    Looks in combination with ✨ provide an API to forcibly start a session Needs work there will be single place for sessions to start and create its storage

  • Status changed to Needs work 9 months ago
  • πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts

    A few more small points/questions, but otherwise this is probably ready. Since this is an internal refactoring and tests are passing, I don't think it needs explicit test coverage. But it might need a change record...?

  • πŸ‡¦πŸ‡ΊAustralia larowlan πŸ‡¦πŸ‡ΊπŸ.au GMT+10

    One fun thing with these auto created tables is restoring a database when the site is under load.

    Found that out the hard way when the restore died 80% through because the key value table had auto created itself. Solution was to shutdown the nginx server as well.

  • πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts

    Ensuring @catch is credited for the patch, and I'm credited for my impeccable code review (hah!)

  • Pipeline finished with Canceled
    9 months ago
    Total: 36s
    #122259
  • Pipeline finished with Canceled
    9 months ago
    Total: 27s
    #122261
  • Status changed to Needs review 9 months ago
  • πŸ‡¬πŸ‡§United Kingdom catch

    We should probably open a follow-up to bring some of the other subsystems that implement this up-to-date with SchemaObectNotExistsException etc., I think they were added after we started doing this.

  • Pipeline finished with Success
    9 months ago
    Total: 494s
    #122262
  • Status changed to RTBC 9 months ago
  • πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts

    No objections here.

    Should we remove the sessions table from system_schema() in this MR, per the change record?

  • Status changed to Needs work 9 months ago
  • πŸ‡¬πŸ‡§United Kingdom alexpott πŸ‡ͺπŸ‡ΊπŸŒ

    Don't we need to remove sessions from system_schema - otherwise we have to maintain the schema in two locations which seems wrong. Plus we're not really using the changes here if we're still creating the table during system module install.

  • Status changed to Needs review 9 months ago
  • πŸ‡¬πŸ‡§United Kingdom catch

    Don't know how I missed the most important and most satisfying part of the change...

  • Pipeline finished with Failed
    9 months ago
    Total: 647s
    #122549
  • πŸ‡¬πŸ‡§United Kingdom catch

    OK the answer to 'why doesn't this use SchemaObjectDoesNotExistException is that that exception is only thrown when you try to change a schema object that doesn't exist (like altering a table or something), not when just querying from a table that doesn't exists, so went back to \Throwable in the MR.

    @phenaproxima I had already opened πŸ“Œ Update lazy database creation pattern for more specific exceptions etc. Active , we should consolidate those two and not mention SchemaObjectDoesNotExistException.

  • Status changed to RTBC 9 months ago
  • πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts

    Huh, too bad about SchemaObjectExistsException. The change to Throwable makes sense. RTBC assuming all tests pass.

  • Pipeline finished with Failed
    9 months ago
    Total: 561s
    #122576
  • πŸ‡¬πŸ‡§United Kingdom catch

    I appreciate the enthusiasm but all tests very much do not pass yet - removing the entry from system_schema() is finding bugs, thought this too easy when I pushed the initial changes.

  • Pipeline finished with Failed
    9 months ago
    #122592
  • Status changed to Needs work 9 months ago
  • πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts

    Well, that's a sadness.

  • Pipeline finished with Failed
    9 months ago
    Total: 534s
    #122606
  • Pipeline finished with Failed
    9 months ago
    #122627
  • Pipeline finished with Failed
    9 months ago
    Total: 493s
    #122647
  • Pipeline finished with Failed
    9 months ago
    Total: 492s
    #122657
  • Status changed to Needs review 9 months ago
  • πŸ‡¬πŸ‡§United Kingdom catch

    Test failures resolved I think:

    1. The installer redirect trait hard-codes the {sessions} table, changed this to {sequences}. This will have to be tackled in πŸ“Œ Stop installing system module before everything else Needs work so doesn't need its own follow-up.

    2. SessionManager hard-codes a database query to the {sessions} table. Added a further try/catch there and opened πŸ“Œ SessionManager should not directly query the sessions table Active .

  • Pipeline finished with Success
    9 months ago
    Total: 1037s
    #122669
  • Status changed to RTBC 9 months ago
  • πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts

    No objections.

  • Status changed to Needs work 9 months ago
  • πŸ‡¬πŸ‡§United Kingdom alexpott πŸ‡ͺπŸ‡ΊπŸŒ

    Throwable is way more generic than the other instances of this in core... not sure if that matters but it feels odd. They all go for \Exception which is still super generic but less :). I think we should try to work on πŸ“Œ Simplify exception handling for lazy-load pattern Needs work and try to standardise this in some way.

    Left some other feedback on the MR.

  • πŸ‡¬πŸ‡§United Kingdom catch

    Yeah it didn't seem to hurt catching throwable in these cases because there's not really a lot else that can go wrong in the code path anyway, but also makes it a bit pointless - switched back to Exception everywhere and also applied the two suggestions.

    Replied in the MR but we already have a follow-up which will handle the installer check it's just got slightly wider scope than just that check, but IMO between that issue and the eventual Drupal 12 issue to remove the sequences table it won't get forgotten.

  • Status changed to Needs review 9 months ago
  • πŸ‡¬πŸ‡§United Kingdom catch
  • Status changed to RTBC 9 months ago
  • πŸ‡¬πŸ‡§United Kingdom catch

    Only applying @alexpott's suggestions (either literal gitlab ones or review points), so moving back to RTBC.

  • πŸ‡¬πŸ‡§United Kingdom alexpott πŸ‡ͺπŸ‡ΊπŸŒ

    Committed and pushed da2e2ce2ae to 11.x and 9feabd3759 to 10.3.x. Thanks!

    • alexpott β†’ committed 9feabd37 on 10.3.x
      Issue #3428565 by catch, phenaproxima, alexpott: Implement lazy database...
  • Status changed to Fixed 9 months ago
    • alexpott β†’ committed da2e2ce2 on 11.x
      Issue #3428565 by catch, phenaproxima, alexpott: Implement lazy database...
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024