Drupal 8 installation with Mysql replication - mysql

I am trying to use the Mysql service from Compose.io
This service has, by default, replication (3 nodes)
When I try to install Drupal through either Drush or WebUI, I get some errors:
Failed to INSERT a value into a test table on your database server. We tried inserting a value with the command INSERT INTO {drupal_install_test} (id) VALUES (1) and the server reported the following error: SQLSTATE[HY000]: General error: 3098 The table does not comply with the requirements by an external plugin.: INSERT INTO {drupal_install_test} (id) VALUES (1); Array ( ) .
Failed to UPDATE a value in a test table on your database server. We tried updating a value with the command UPDATE {drupal_install_test} SET id = 2 and the server reported the following error: SQLSTATE[HY000]: General error: 3098 The table does not comply with the requirements by an external plugin.: UPDATE {drupal_install_test} SET id = 2; Array ( ) .
Failed to DELETE a value from a test table on your database server. We tried deleting a value with the command DELETE FROM {drupal_install_test} and the server reported the following error: SQLSTATE[HY000]: General error: 3098 The table does not comply with the requirements by an external plugin.: DELETE FROM {drupal_install_test}; Array ( ) .
When replication is on, every table needs to have a Primary Key, and apparently Drupal don't add those by default.
Is there any workaround on configuring Drupal to use a Mysql db with Replication on?
Note that Compose.io doesn't expose the replicas, only the master, to the user.

This is apparently an error message returned by the new Group Replication feature.
Yes, Group Replication requires that all tables have a primary key.
https://dev.mysql.com/doc/refman/5.7/en/group-replication-requirements.html says:
Every table that is to be replicated by the group must have a defined primary key, or primary key equivalent where the equivalent is a non-null unique key.
Unfortunately, the test table Drupal uses to test installation does not have a primary key (or equivalent).
This has been reported as an issue to Drupal: https://www.drupal.org/project/drupal/issues/2856362
There might be a fix coming in Drupal 8.5 or later, but in the meantime, there could be useful patches proposed by commenters in that issue. Basically, you just need to change the creation of the drupal_install_test table in a few files to:
CREATE TABLE {drupal_install_test} (id INT NOT NULL PRIMARY KEY)

EASY FIX (Drupal 7)
In your install.inc file line #307 must be changed to
CREATE TABLE {drupal_install_test} (id int NOT NULL PRIMARY KEY)

Related

How to solve the error of "SDB_RTN_COORD_ONLY" when connecting MySQL to create table in SequoiaDB?

In the stand-alone mode of SequoiaDB, when I want to connect MySQL to create table, it reported the following error:
mysql> use cs;
Database changed
mysql> create table cl(a int, b int, c text, primary key(a, b) ) engine = SequoiaDB ;
ERROR 1030 (HY000): Got error 49841 from storage engine
SDB_RTN_COORD_ONLY can only be used for coordination node
By default, when you create a table on MySQL, it will synchronize to create the corresponding partition table (hash partition, including all partition groups) on SequoiaDB. The partition key takes precedence over the primary key field. If the primary key is not created when creating table, please use the unique key. If the unique key is not created, please use the first field. Users can disable the creation of the default partition table by setting the configuration parameter sequoiadb_use_partition to OFF. This configuration parameter can also be modified in the shell command line and configuration file.
View configuration parameters and shell command:
mysql> show variables like sequoiadb%;
Turn the sequoiadb_use_partition to ON
Using command:
mysql> SET GLOBAL sequoiadb_use_partition=OFF;
And set it to OFF.
For more information, you can refer to this article

why record value in mysql innodb table is replaced unexpected?

server OS: centos 5.6
mysql server:5.6.16
I create a table:
create table test (
id int auto_incremented not null,
value int);
and insert into it a record such as
insert into test values(100001,15);
but next day I find (100001,15) does not exist,
but (100001,18) exists.
the table has no triggers , no foreign key.
I scanned the binlog and found the inserting statement, but found no (100001,15) related statments. What happened?
It should not happen, MySQL supports ACID, mean your data will not change automatically, until there is the trigger or modified by some application query. See the ACID for your reference: https://dev.mysql.com/doc/refman/5.6/en/mysql-acid.html
Hope, It will help you to understand properly ACID properties.

Rails: ActiveRecord::UnknownPrimaryKey exception

A ActiveRecord::UnknownPrimaryKey occurred in survey_response#create:
Unknown primary key for table question_responses in model QuestionResponse.
activerecord (3.2.8) lib/active_record/reflection.rb:366:in `primary_key'
Our application has been raising these exceptions and we do not know what is causing them. The exception happens in both production and test environments, but it is not reproducible in either. It seems to have some relation to server load, but even in times of peak loads some of the requests still complete successfully. The app (both production and test environments) is Rails 3.2.8, ruby 1.9.3-p194 using MySQL with the mysql2 gem. Production is Ubuntu and dev/test is OS X. The app is running under Phusion Passenger in production.
Here is a sample stack trace: https://gist.github.com/4068400
Here are the two models in question, the controller and the output of "desc question_responses;": https://gist.github.com/4b3667a6896b60383dc3
It most definitely has a primary key, which is a standard rails 'id' column.
Restarting the app server temporarily stops the exceptions from occurring, otherwise they happen over a period of time 30 minutes - 6 hours in length, starting as suddenly as they stop.
It always occurs on the same controller action, table and model.
Has anyone else run into this exception?
FWIW, I was getting this same intermittent error and after a heck of a lot of head-scratching I found the cause.
We have separate DBs per client, and some how one of the client's DBs had a missing primary key on the users table. This meant that when that client accessed our site, Rails updated it's in-memory schema to that of the database it had connected to, with the missing primary key. Any future requests served by that Passenger app process (or any others that had been 'infected' by this client) which tried to access the users table borked out with the primary key error, regardless of whether that particular database had a primary key.
In the end a fairly self-explanatory error, but difficult to pin down when you've got 500+ databases and only one of them was causing the problem, and it was intermittent.
Got this problem because my workers used shared connection to database. But I was on unicorn.
I know that Passenger reconnects by default, but maybe you have some complicated logic. Connections to number of databases, for example. So you need to reconnect all connections.
This same thing happened to me. I had a composite primary key in one of my table definitions which caused the error. It was further compounded because annotate models did not (but will shortly / does now) support annotation of composite primary keys.
My solution was to make the id column the only primary key and add a constraint (not shown) for the composition. To do this you need to drop auto_increment on id if this is set, drop your composite primary key, then re-add both the primary status and autoincrement.
ALTER TABLE indices MODIFY id INT NOT NULL;
ALTER TABLE indices DROP PRIMARY KEY;
ALTER TABLE indices MODIFY id INT NOT NULL PRIMARY KEY AUTO_INCREMENT;
on postgres database
ALTER TABLE indices ALTER COLUMN id SET DATA TYPE INT;
ALTER TABLE indices ADD PRIMARY KEY (id)

Sql Server 2008R2 enterprise with data encryption - backup and restore

I have a DB on which I enabled symmetric encryption, to encrypt some columns.
I created a SP to enable encryption after I create the DB from script, as below
CREATE PROCEDURE [dbo].[sys_EnableSymmetricEncryption]
AS
BEGIN
--If there is no master key, create one now.
IF NOT EXISTS
(SELECT * FROM sys.symmetric_keys WHERE symmetric_key_id = 101)
CREATE MASTER KEY ENCRYPTION BY
PASSWORD = '9809u0ij989oih9o8yyo98yyo89uyp9p9'
CREATE CERTIFICATE My_Certificate
WITH SUBJECT = 'My Database';
CREATE SYMMETRIC KEY My_Key_01
WITH ALGORITHM = AES_256
ENCRYPTION BY CERTIFICATE My_Certificate;
END
So after I create db from script, I run this and then I can store data in encrypted columns
with
INSERT INTO [dbo].[Cards]
([CardNumber]
,[CardSecurityCode]
,[CardExpirationDate]
,[NameOnCard])
VALUES
(EncryptByKey(Key_GUID('My_Key_01'), #CardNumber) ,
EncryptByKey(Key_GUID('My_Key_01'), #CardSecurityCode) ,
EncryptByKey(Key_GUID('My_Key_01'), #CardExpirationDate) ,
EncryptByKey(Key_GUID('My_Key_01'), #NameOnCard))
and retrieve data with
OPEN SYMMETRIC KEY My_Key_01
DECRYPTION BY CERTIFICATE My_Certificate;
SELECT [CardID]
,CONVERT(nvarchar, DecryptByKey([CardNumber])) as 'CardNumber'
,CONVERT(nvarchar, DecryptByKey([CardSecurityCode])) as 'CardSecurityCode'
,CONVERT(nvarchar, DecryptByKey([CardExpirationDate])) as 'CardExpirationDate'
,CONVERT(nvarchar, DecryptByKey([NameOnCard])) as 'NameOnCard'
FROM [Cards]
All works well till I backup db and try to restore the backup on a different server
After I restore, when I try to run Select (as above) I get this error
Please create a master key in the database or open the master key in the session before performing this operation.
So I was trying to recreate the key with
IF NOT EXISTS
(SELECT * FROM sys.symmetric_keys WHERE symmetric_key_id = 101)
CREATE MASTER KEY ENCRYPTION BY
PASSWORD = '9809u0ij989oih9o8yyo98yyo89uyp9p9'
But then on select In still get the same error.
If I try to run the first Sp shown above, to create master key, cert and symmetric key, I get error
Msg 15581, Level 16, State 3, Procedure sys_EnableSymmetricEncryption, Line 11
Please create a master key in the database or open the master key in the session before performing this operation.
Msg 15282, Level 16, State 1, Procedure sys_EnableSymmetricEncryption, Line 14
A key with name 'OneTest_Key_01' or user defined unique identifier already exists or you do not have permissions to create
Maybe I should try to delete the certificate and symmetric key before trying to create them, but I don't know where are they located.
Any idea how to handle this?
Thanks
PS if I restore in same server, even as different database, all works fine
Try to run:
ALTER MASTER KEY REGENERATE WITH ENCRYPTION BY PASSWORD = '9809u0ij989oih9o8yyo98yyo89uyp9p9';

phpMyAdmin: MySQL Error 1062 - Duplicate entry

I connect with user "root" onto my database "test" which I host locally for development. Among others I have the table "ratingcomment". For some reason when I click on the table "ratingcomment" phpMyAdmin shows me the following error:
Fehler
SQL-Befehl:
INSERT INTO `phpmyadmin`.`pma_history` (
`username` ,
`db` ,
`table` ,
`timevalue` ,
`sqlquery`
)
VALUES (
'root', 'test', 'ratingcomment', NOW( ) , 'SELECT * FROM `ratingcomment`'
)
MySQL meldet:
#1062 - Duplicate entry '838' for key 'PRIMARY'
I used google to finde out the following
"This indicates that you have a UNIQUE or PRIMARY index on a table, and there is a duplicate value someone on one of the values in one of these indexes."
But I still dont quite understand the error! I use a primary Key, which auto-increments for all of my tables, so there actually shouldnt be a problem with the table. I had another table named "rating" which had a column "comment". Can it be, that this causes problems?
Quick fix:
REPAIR TABLE `phpmyadmin`.`pma_history`
If that fails, I'd just truncate/empty the table.
TRUNCATE TABLE `phpmyadmin`.`pma_history`
Although phpmyadmin has it's place in my toolbox, I personally don't use it's internal db.
ADDENDUM
MyISAM tables can easily become corrupted. A couple causes that usually hit me: if the MySQL is not shutdown properly, or if the table has a FULLTEXT index and the stopword file on disk had changed.
Simply stated, the REPAIR just checkes the data file for errors (and depending on your options, makes it usable again) and rewrites the index file. Fair warning: with MyISAM, repairing a table can often toast all your data in that table to make it usable. See doc for more details.
A google search pertaining to this pma table being corrupted lead me to this.
This appears to be an internal error. You've issued this query:
SELECT * FROM `ratingcomment`
phpMyAdmin tries to write such action in its internal event log and it fails. If you Google for pma_history you'll find several references to such table being corrupted.
My advice is that you find another SQL client (such as HeidiSQL) and try to repair the phpMyAdmin database.
I know this is kinda late but I had the same problem and wanted to share what I did.
In PhpMyAdmin, I went to the table's Operation tab, and just incremented the AUTO_INCREMENT value under Table options and inserted a dummy record.