• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tf / pageflow / 2251
99%
master: 99%

Build:
Build:
LAST BUILD BRANCH: actions
DEFAULT BRANCH: master
Ran 31 Oct 2019 11:36AM UTC
Jobs 2
Files 460
Run time 2min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

pending completion
2251

push

travis-ci

tf
Prevent further cases of perma id clashes

Wrapping `RevisionComponent#save` in an advisory lock, does not
suffice for cases where the revision component is created through an
association, i.e

    revision.file_usages.create!(...)

In this case `CollectionAssociation#_create_record` [1] already starts
the transaction before the lock is required. Since the transaction is
then committed only after the advisory lock is already released, the
following race condition can occur:

    Thread 1:                       Thread 2:
    |                               |
    BEGIN                           |
    GET LOCK                        |
    SELECT MAX perma_id             |
    INSERT revision component       |
    RELEASE LOCK                    |
    |                               BEGIN
    |                               GET LOCK
    |                               SELECT MAX perma_id
    COMMIT                          |
    |                               INSERT revision component
    |                               RELEASE LOCK
    |                               COMMIT

Since the first transaction is not yet finished, the second thread
does not yet see the newly inserted perma id and calculates the same
maximum.

To ensure that the lock is acquired before the transaction starts, we
add a new class method `create_with_lock!` which then delegates to
`create!`.

For existing revision components (and models that behave like revision
components like `Page`) this race condition has never been a problem
since concurrent inserts are not that likely within a revision (and we
do not care about non-unique perma ids accross entries). We only
noticed the problem for file usages now since those are created by a
batch of requests when multiple files are uploaded at the same time.
So for now we use the new `create_with_lock!` method only in
`DraftEntry.create_file!`.

[1] https://github.com/rails/rails/blob/b9ca94cae/activerecord/lib... (continued)

17109 of 17233 relevant lines covered (99.28%)

58.9 hits per line

Jobs
ID Job ID Ran Files Coverage
1 2251.1 (2.3.1, PUBLISH_THEME_DOC=true COVERALLS_PARALLEL=true) 31 Oct 2019 11:35AM UTC 0
99.26
Travis Job 2251.1
2 2251.2 (2.5.3, PUBLISH_THEME_DOC=true COVERALLS_PARALLEL=true) 31 Oct 2019 11:37AM UTC 0
99.27
Travis Job 2251.2
Source Files on build 2251
Detailed source file information is not available for this build.
  • Back to Repo
  • Travis Build #2251
  • 3c573007 on github
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc