Problem/Motivation

Primary keys are missing from the publishing_options_bundles and publishing_options_option_node tables. This causes the following warning on the status page:

Transaction isolation level
REPEATABLE-READ
The recommended level for Drupal is "READ COMMITTED". For this to work correctly, all tables must have a primary key. The following table(s) do not have a primary key: publishing_options_bundles, publishing_options_option_node. See the setting MySQL transaction isolation level page for more information.

Steps to reproduce

Install module and have db stet to READ COMMITTED. Navigate to the /admin/reports/status page.

Proposed resolution

Update schema definition and add update hook in publishing_options.install file.

CommentFileSizeAuthor
#5 pub-options-before.png80.51 KBmukhtarm
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mizage@gmail.com created an issue. See original summary.

sarwan_verma made their first commit to this issue’s fork.

sarwan_verma’s picture

Status: Active » Needs review

Hi @mizage@gmail.com ,
I have fixed this issue "Primary keys missing" and also created MR,
kindly review the MR.

mukhtarm’s picture

StatusFileSize
new80.51 KB

I reviewed the MR. On the publishing_options_bundles table the better primary key option would on the pubid as it does for the publishing_options table. Updated the MR, please review

mizage@gmail.com’s picture

Thanks for the quick response! Do we need an update hook for existing installations?

mukhtarm’s picture

Updated the MR with hook_update that tested locally. Note that if you applied https://git.drupalcode.org/project/pub_options/-/merge_requests/15/diffs... already, it wont have any effects. Or you have to revert it to the earlier and run drush updb.

geocalleo’s picture

Hi and thanks for the update. I'll check the code and get it merged in once I'm done testing!

mizage@gmail.com’s picture

Thanks again for the quick response.

mizage@gmail.com’s picture

I'm seeing the following when applying the update:

[error]  SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1' for key 'PRIMARY': ALTER TABLE "publishing_options_bundles" ADD PRIMARY KEY ("pubid"); Array

mukhtarm’s picture

Thanks @geocalleo. When i tried to apply the patch from MR via composer (https://git.drupalcode.org/project/pub_options/-/merge_requests/17.patch) it fails (As there are conflicts in publishing_options.install). I had to wget the patch to local and then git apply -3 patch and had to resolve the conflict to get it work. I think all other changes was already there in place for 2.0.3 version.

geocalleo’s picture

Hi @MukhtarM, I am trying to merge the updates you put in place. But it looks like the merge request is set for 2.x branch. Can you switch that over to 2.0.0 branch? I've been making release tags on that branch for the latest releases.

mukhtarm’s picture

Yea sure @geocalleo i will do that

mukhtarm’s picture

@geocalleo i raised against 2.0.0 now. First i tried to raise in the git UI itself (as there no code change), but it didn't worked. Thats why there is a intermediate MR :)

aurora.luzzardi’s picture

None of those branches/pr could be applied on 2.0.3 what should be the steps?
Do we have a patch that can be applied?

sprite’s picture

thread started: 2026-10-03 - - current comment added: 2026-06-21 -

Drupal 11 admin [ status report] error:

Transaction isolation level
READ-COMMITTED
For this to work correctly, all tables must have a primary key. The following table(s) do not have a primary key: captcha_questions_dblog. See the setting MySQL transaction isolation level page for more information.

The - captcha_questions_dblog - table needs a primary key.

  • geocalleo committed 6b17b725 on 2.0.0
    Issue #3396971 by mukharrm, sarwan_verma, geocalleo: Add missing primary...
geocalleo’s picture

Hi all,

Thanks for the report, @mlcage, and thanks @sarwan_verma and @mukharrm for taking a crack at this.

I committed a fix to the 2.0.x branch (6b17b72) and tagged it as 2.0.4. I went a slightly different route from the MRs, so here's the quick rundown:

The two tables are many-to-many. One publishing option can map to a bunch of bundles, and a node can have more than one option on it, so the keys need to be composite instead of single column: publishing_options_bundles gets (pubid, bundle) and publishing_options_option_node gets (pubid, nid). I left pubid as a plain int since it's just pointing back at publishing_options, not a serial.

For existing sites, the update hook (publishing_options_update_8001) clears out any duplicate rows first and then adds the keys, so you just need to run your db updates after pulling 2.0.4. I bumped it to 8001 since update hooks numbered below 8000 don't actually run on Drupal 8+.

I tested it on a Drupal 10 site set to READ COMMITTED. Before the update the status report flags both tables, and once it runs the isolation check goes back to green. Fresh installs come out with the keys already in place.

Marking this fixed. Thanks again, everyone.

geocalleo’s picture

Assigned: Unassigned » geocalleo
Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.