Ghost/ghost/core/test
Chris Raible 5154e8d24f
Fixed race condition when updating member's last_seen_at timestamp (#20389)
ref
https://linear.app/tryghost/issue/ENG-1240/race-condition-when-updating-members-last-seen-at-timestamp
    
When members click a link in an email, Ghost updates the member's
`last_seen_at` timestamp, but it should only update the timestamp if the
member hasn't yet been seen in the current day (based on the
publication's timezone).
    
Currently there is a race condition present where multiple simultaneous
requests from the same member (if e.g. an email link checker is
following all links in an email) can cause the `last_seen_at` timestamp
to be updated multiple times in the same day for the same member. These
additional queries add a significant load on Ghost and its database,
which can contribute to the exhaustion of the connection pool and
eventually requests may time out.
    
The primary motivation for this change is to avoid that race condition
by adding a lock to the member row, checking if `last_seen_at` has
already been updated in the current day, and only updating it if it
hasn't.
    
Another beneficial side-effect of this change is that it avoids locking
the `labels` and `newsletters` tables, which are locked when we update
the `last_seen_at` timestamp in the `members` table currently. This
should improve Ghost's ability to handle a large influx of requests to
redirect endpoints (confirmed with load tests), which tend to happen
immediately after a publisher sends an email.
2024-06-18 20:03:32 -07:00
..
e2e-api Adjusted spacing and amount of text of newsletter latest posts (#20285) 2024-06-11 12:30:32 +08:00
e2e-browser 🐛 Fixed admin error when deleting an unsaved or imported post (#20053) 2024-04-18 10:02:02 -07:00
e2e-frontend Fixed offer not found case during Stripe checkout (#20322) 2024-06-04 10:27:45 +00:00
e2e-server Fixed race condition when updating member's last_seen_at timestamp (#20389) 2024-06-18 20:03:32 -07:00
e2e-webhooks Cleaned up lexicalEditor labs flag, switched Post model to lexical-by-default (#18607) 2023-10-23 17:51:34 +01:00
integration Newsletter captions fix (#20396) 2024-06-18 11:26:20 +02:00
regression Updated staff deletion logic (#20069) 2024-04-25 08:19:11 -05:00
unit Fixed handling SVG files with missing tag 2024-06-18 14:41:11 +02:00
utils Fixed handling SVG files with missing tag 2024-06-18 14:41:11 +02:00
.eslintignore Added Source as the new default theme 2023-10-03 14:02:08 +02:00
.eslintrc.js Enforced more Mocha lint rules (#19720) 2024-04-16 09:37:06 +02:00