Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API returned an error (primary keys missing in database) #7830

Closed
msigrun opened this issue May 4, 2015 · 13 comments
Closed

API returned an error (primary keys missing in database) #7830

msigrun opened this issue May 4, 2015 · 13 comments
Assignees
Labels
answered For when a question was asked and we referred to forum or answered it.
Milestone

Comments

@msigrun
Copy link

msigrun commented May 4, 2015

Hi,
in the forum http://forum.piwik.org/read.php?2,122923 you said this bug should be fixed but unfortunately, it is not in my Piwik installation version 2.12.1.

I get this error message:
API returned an error: Sequence 'myprefix_archive_numeric_2015_05' not found. at Sequence.php:99

'INSERT INTO myprefix_sequence (name, value) VALUES ('myprefix_archive_numeric_2015_03' , 99999)' did not fix the problem. In the database table 'myprefix_sequence' I find the name
'myprefix_archive_numeric_2015_05' 113 times (with the values 1 until 222 and the value 100047 between 47 and 49) while the other names like 'myprefix_archive_numeric_2015_04' exist only one time.

Indeed, the number of 'myprefix_archive_numeric_2015_05'-names in the table myprefix_sequence increases every time I refresh the piwik-webpage, right now it took154 rows in the table.

Then I deleted all the lines containing 'myprefix_archive_numeric_2015_05' and used the SQL above. It worked one time when I refreshed the piwik page, then the number of entrys in the table 'myprefix_sequence' increased again.

If you need more information please tell me. I would be grateful for your help.

@tsteur
Copy link
Member

tsteur commented May 4, 2015

In the database table 'myprefix_sequence' I find the name 'myprefix_archive_numeric_2015_05' 113 times

This is problematic. The value should exist only once at all times. I can see there was a change recently
1238b6e @mattab .

If we do create a new sequence there, it should check for a specific exception, not just for any exception.

@msigrun Can you execute the following SQL query and post the output here? show create table myprefix_sequence; . In theory it should not be possible to have the same name there multiple times. Which MySQL version are you using?

@msigrun
Copy link
Author

msigrun commented May 5, 2015

It is MySQL 5

CREATE TABLE myprefix_sequence (
name varchar(120) CHARACTER SET utf8 NOT NULL,
value bigint(20) unsigned NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1

@msigrun
Copy link
Author

msigrun commented May 5, 2015

But this is strange: I am using Piwik also on a different server (same provider, also MySQL 5). There, Piwik 2.12.1 worked and I just succeeded with the update to 2.13.

Here is the SQL result:
CREATE TABLE piwik_sequence (
name varchar(120) NOT NULL,
value bigint(20) unsigned NOT NULL,
PRIMARY KEY (name)
) ENGINE=InnoDB DEFAULT CHARSET=utf8

In the dumpfile of the elder database version it looks like this (from Piwik 2.12.1):
CREATE TABLE piwik_sequence (
name varchar(120) NOT NULL,
value bigint(20) unsigned NOT NULL,
PRIMARY KEY (name)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

How come that my other installation has PRIMARY KEY defined in table myprefix_sequence?

I tried this SQL-statement (with PRIMARY KEY) to solve the problem:
CREATE TABLE piwik_sequence (
name varchar(120) NOT NULL,
value bigint(20) unsigned NOT NULL,
PRIMARY KEY (name)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO myprefix_sequence (name, value) VALUES
('myprefix_archive_numeric_2015_04', 147),
('myprefix_archive_numeric_2015_03', 31),
('myprefix_archive_numeric_2015_02', 29),
('myprefix_archive_numeric_2015_01', 13),
('p1w1k82_archive_numeric_2015_05', 1);

Now, the data re-appeared. Fine.
But: under "Dashboard" there is written "Dashboard von myusername" - like always, but it is followed by: "Dashboard von myusername (2)" "Dashboard von myusername (3)" "Dashboard von myusername (4)" "Dashboard von myusername (5)"
(I use the German translation, "von" means "from" or "of")

@tsteur
Copy link
Member

tsteur commented May 5, 2015

I expected that for some random reason there's no primary key defined in your sequence table. There should a primary key defined (as you already figured out and added one). I have no clue how this can happen. Maybe someone else can? Do you use MySQL 5.0 or a later one?

The dashboard problem seems to be unrelated to this. At least I cannot explain how this could happen because of this. Is there maybe a primary key missing as well?

Can you execute the query show create table myprefix_user_dashboard

@msigrun
Copy link
Author

msigrun commented May 6, 2015

MySQL-Server is 5.5.41-0+wheezy1
and tadaaaaa:
CREATE TABLE myprefix_user_dashboard (
login varchar(100) CHARACTER SET utf8 NOT NULL,
iddashboard int(11) NOT NULL,
name varchar(100) CHARACTER SET utf8 DEFAULT NULL,
layout text CHARACTER SET utf8 NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1

whereas the other installation (which works) has
CREATE TABLE piwik_user_dashboard (
login varchar(100) NOT NULL,
iddashboard int(11) NOT NULL,
name varchar(100) DEFAULT NULL,
layout text NOT NULL,
PRIMARY KEY (login,iddashboard)
) ENGINE=MyISAM DEFAULT CHARSET=utf8

True. This table has no primary key and I am afraid more tables are affected. How come?

Should I contact my provider as both installations are a provided service (1st click installation)?

@tsteur
Copy link
Member

tsteur commented May 7, 2015

It would be great if you could contact your provider. Maybe they have heard of something like this before. It's the first time that I see such an issue. I have no clue how this can happen and didn't find anything when searching for it. Maybe someone else has an idea?

@msigrun
Copy link
Author

msigrun commented May 7, 2015

Thank you tsteur for your help. I will contact the provider and keep you informed.

Someone else has an idea? As this bug also existed somewhere else like in the forum I mentioned above.

@tsteur
Copy link
Member

tsteur commented May 7, 2015

I think the problem for the users in the forum was fixed. It was caused for them by a different problem.

@msigrun
Copy link
Author

msigrun commented May 8, 2015

The provider recommends a new installation. I will do this and then insert the existing data.

@tsteur tsteur added the answered For when a question was asked and we referred to forum or answered it. label May 10, 2015
@tsteur tsteur added this to the 2.14.0 milestone May 10, 2015
@tsteur tsteur self-assigned this May 10, 2015
@tsteur
Copy link
Member

tsteur commented May 10, 2015

Thx for letting us know. I will close it for now. If anyone has an idea how this can happen, or whether it happened before (in this case we could maybe add a system check for this or a self-repair) please comment here.

@tsteur tsteur closed this as completed May 10, 2015
@tsteur tsteur changed the title API returned an error API returned an error (primary keys missing in database) May 10, 2015
@tsteur
Copy link
Member

tsteur commented May 13, 2015

@msigrun just a question, do you have another application installed in the same database?

@msigrun
Copy link
Author

msigrun commented May 15, 2015

No other application, I started with a new database.

I found the source of trouble when I did the new installation. In the beginning, the primary key was missing again, because I copied the original tables with a new prefix (phpMyAdmin 4.0.5).

If I do so, the copied table has no primary key! I tried this several times, every time it was like this. Just as I finally replaced the prefix piwik_ with myprefix_, the primary key stayed.

@tsteur
Copy link
Member

tsteur commented May 17, 2015

OK thx!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
answered For when a question was asked and we referred to forum or answered it.
Projects
None yet
Development

No branches or pull requests

2 participants