Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[FrameworkBundle][Cache] Allow configuring PDO-based cache pools, with table auto-creation on first use#27694

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fabpot merged 1 commit intosymfony:masterfromnicolas-grekas:cache-pdo-config
Jul 9, 2018

Conversation

@nicolas-grekas
Copy link
Member

QA
Branch?master
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets-
LicenseMIT
Doc PR-
  • Allowed configuring PDO-based cache pools via a newcache.adapter.pdo abstract service
  • added automatic table creation when using Doctrine DBAL with PDO-based backends

onEXHovia and ostrolucky reacted with thumbs up emoji
@dmaicher
Copy link
Contributor

dmaicher commentedJun 24, 2018
edited
Loading

Hmm I can imagine some scenarios where this automatic table creation could have some side-effects.

For example:

  • the caching table does not exist yet
  • I start a transaction somewhere in my user-land code
  • I perform some updates/inserts to the database (other tables, unrelated to cache)
  • during this transaction I perform some cache saves
  • I want to roll-back my transaction ==> this fails because my transaction was committed implicitly because of the table creation query?

Not sure how likely a scenario like this is 😄 But it could happen I guess

@nicolas-grekas
Copy link
MemberAuthor

@dmaicher sure that's possible. Is this any different than the same scenario with the table already created before, and items not saved for the same reason (a rollback?)

@dmaicher
Copy link
Contributor

Is this any different than the same scenario with the table already created before, and items not saved for the same reason (a rollback?)

I added one point above:I perform some updates/inserts to the database (other tables, unrelated to cache) . So then we have a difference, right? Those changes cannot be rolled back anymore.

@nicolas-grekas
Copy link
MemberAuthor

nicolas-grekas commentedJun 24, 2018
edited
Loading

Oh sorry I missed that part. Here are some docs on the topic:
https://wiki.postgresql.org/wiki/Transactional_DDL_in_PostgreSQL:_A_Competitive_Analysis
https://stackoverflow.com/questions/4692690/is-it-possible-to-roll-back-create-table-and-alter-table-statements-in-major-sql

We may prefer disabling auto-creation when in the middle of a transaction...

Status: needs work

@nicolas-grekas
Copy link
MemberAuthor

@dmaicher fixed.

Copy link
Contributor

@dmaicherdmaicher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

one comment for the auto-creation. Otherwise looks good to me 👍

try {
$stmt =$conn->prepare($sql);
}catch (TableNotFoundException$e) {
if (!$conn->isTransactionActive() ||\in_array($this->driver,array('pgsql','sqlite','sqlsrv'),true)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Ok this looks safer now.

I'm just wondering: What exactly is the use-case now for this auto-creation?

I mean we cannot really rely on it anyway on production as this will simply fail if we are in the middle of a transaction. Sure we can assume eventually there will be a request where this condition is true 😄 But as said we cannot rely on it anyway.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Ease of use. And pgsql users will love it. Note also that even now, no exceptions are thrown when the table is not found. PSR-6 only allows a log line. This doesn't change it.

sstok reacted with heart emoji
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Ah true about the muted exceptions. Forgot about that.

Yeah for pgsql indeed nice 👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Hi guys ! seems like issue here...
im using pgsql and TableNotFoundException throwed only when $stmt->execute();
$stmt = $conn->prepare($sql); is not throwing TableNotFoundException when cache_items table does not exists
@nicolas-grekas what do you think?

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I think I will forget about this in one hour :)
Please create an issue if you think there is something to track.

@javiereguiluz
Copy link
Member

I'm all in for easing the usage of features ... but"database table auto-creation when the PDO cache needs it" makes me nervous. Not sure if it's a real scenario, but imagine this: I enable PDO cache in production without preparing the database for it:

  1. Without table auto-creation I see an error and I'm aware that I need to do some things in the database.
  2. With table auto-creation, everything works ... but maybe I'm using a cloud server, the cache grows a lot ... and I end up with a huge bill from my cloud provider because of the database usage.

@nicolas-grekas
Copy link
MemberAuthor

Without table auto-creation I see an error and I'm aware that I need to do some things in the database.

no you don't, as explainedin a comment above, PSR-6 allows no error to be reported, so this is silent - or at best logged. That's why this is an improvement over the current situation.

@fabpot
Copy link
Member

Thank you@nicolas-grekas.

@fabpotfabpot merged commit1484117 intosymfony:masterJul 9, 2018
fabpot added a commit that referenced this pull requestJul 9, 2018
…ache pools, with table auto-creation on first use (nicolas-grekas)This PR was merged into the 4.2-dev branch.Discussion----------[FrameworkBundle][Cache] Allow configuring PDO-based cache pools, with table auto-creation on first use| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | -| License       | MIT| Doc PR        | -* Allowed configuring PDO-based cache pools via a new `cache.adapter.pdo` abstract service* added automatic table creation when using Doctrine DBAL with PDO-based backendsCommits-------1484117 [FrameworkBundle][Cache] Allow configuring PDO-based cache pools, with table auto-creation on first use
@weaverryan
Copy link
Member

Do we need a docs issue?

nicolas-grekas and cybernet reacted with thumbs up emoji

@nicolas-grekasnicolas-grekas deleted the cache-pdo-config branchJuly 22, 2018 20:25
javiereguiluz added a commit to symfony/symfony-docs that referenced this pull requestJul 23, 2018
…ion (nicolas-grekas)This PR was merged into the master branch.Discussion----------[Cache] tell about PDO configuration and table autocreationDoc forsymfony/symfony#27694Commits-------187300a [Cache] tell about PDO configuration and table autocreation
@nicolas-grekasnicolas-grekas modified the milestones:next,4.2Nov 1, 2018
This was referencedNov 3, 2018
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fabpotfabpotfabpot approved these changes

+2 more reviewers

@errogahterrogahterrogaht left review comments

@dmaicherdmaicherdmaicher approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

4.2

Development

Successfully merging this pull request may close these issues.

7 participants

@nicolas-grekas@dmaicher@javiereguiluz@fabpot@weaverryan@errogaht@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp