Seaf-gc.sh reports SQL Errors in 6.2.2 CE (mariadb)

I upgraded Seafile Server from 6.1.2 to 6.2.2 and adjusted seahub from fast_cgi to WSGI. Afterwards (before starting Seafile Server), I ran seaf-fsck.sh with no errors.

Then I ran seaf-gc.sh getting the following result:

[seafserver@cloud seafile-server-latest]$ ./seaf-gc.sh

Starting seafserv-gc, please wait …
[10/08/17 17:01:23] gc-core.c(440): GC version 1 repo Demo([ID])
[10/08/17 17:01:23] gc-core.c(313): GC started. Total block number is 8.
[10/08/17 17:01:23] gc-core.c(46): GC index size is 1024 Byte.
[10/08/17 17:01:23] gc-core.c(327): Populating index.
[10/08/17 17:01:23] gc-core.c(181): Populating index for repo af3bd5ca.
[10/08/17 17:01:23] …/…/common/seaf-db.c(425): Error prepare statement SELECT value FROM SeafileConf WHERE cfg_group=? AND cfg_key=?: mysql_stmt_prepare failed: Table ‘seafile.SeafileConf’ doesn’t exist.
[10/08/17 17:01:23] gc-core.c(234): Traversed 14 commits, 8 blocks.
[10/08/17 17:01:23] gc-core.c(341): Scanning and deleting unused blocks.
[10/08/17 17:01:23] gc-core.c(364): GC finished. 8 blocks total, about 8 reachable blocks, 0 blocks are removed.

[10/08/17 17:01:23] gc-core.c(440): GC version 1 repo Cloud([ID])
[10/08/17 17:01:23] gc-core.c(313): GC started. Total block number is 1946.
[10/08/17 17:01:23] gc-core.c(46): GC index size is 1024 Byte.
[10/08/17 17:01:23] gc-core.c(327): Populating index.
[10/08/17 17:01:23] gc-core.c(181): Populating index for repo 93d1f567.
[10/08/17 17:01:23] gc-core.c(234): Traversed 9 commits, 1720 blocks.
[10/08/17 17:01:23] gc-core.c(183): Populating index for sub-repo 1c612e4e.
[10/08/17 17:01:23] gc-core.c(234): Traversed 1 commits, 49 blocks.
[10/08/17 17:01:23] gc-core.c(183): Populating index for sub-repo 3eab867e.
[10/08/17 17:01:23] gc-core.c(234): Traversed 2 commits, 64 blocks.
[10/08/17 17:01:23] gc-core.c(341): Scanning and deleting unused blocks.
[10/08/17 17:01:23] gc-core.c(364): GC finished. 1946 blocks total, about 1833 reachable blocks, 199 blocks are removed.

[10/08/17 17:01:23] gc-core.c(440): GC version 1 repo Private([ID])
[10/08/17 17:01:23] gc-core.c(313): GC started. Total block number is 5834.
[10/08/17 17:01:23] gc-core.c(46): GC index size is 2917 Byte.
[10/08/17 17:01:23] gc-core.c(327): Populating index.
[10/08/17 17:01:23] gc-core.c(181): Populating index for repo 810dc1ee.
[10/08/17 17:01:24] gc-core.c(234): Traversed 5 commits, 5833 blocks.
[10/08/17 17:01:24] gc-core.c(341): Scanning and deleting unused blocks.
[10/08/17 17:01:24] gc-core.c(364): GC finished. 5834 blocks total, about 5833 reachable blocks, 1 blocks are removed.

[10/08/17 17:01:24] gc-core.c(440): GC version 1 repo My Library Template([ID])
[10/08/17 17:01:24] gc-core.c(313): GC started. Total block number is 1.
[10/08/17 17:01:24] gc-core.c(46): GC index size is 1024 Byte.
[10/08/17 17:01:24] gc-core.c(327): Populating index.
[10/08/17 17:01:24] gc-core.c(181): Populating index for repo 3ec0beea.
[10/08/17 17:01:24] …/…/common/seaf-db.c(425): Error prepare statement SELECT value FROM SeafileConf WHERE cfg_group=? AND cfg_key=?: mysql_stmt_prepare failed: Table ‘seafile.SeafileConf’ doesn’t exist.
[10/08/17 17:01:24] gc-core.c(234): Traversed 2 commits, 1 blocks.
[10/08/17 17:01:24] gc-core.c(341): Scanning and deleting unused blocks.
[10/08/17 17:01:24] gc-core.c(364): GC finished. 1 blocks total, about 1 reachable blocks, 0 blocks are removed.

[10/08/17 17:01:24] gc-core.c(440): GC version 1 repo My Library([ID])
[10/08/17 17:01:24] gc-core.c(313): GC started. Total block number is 1.
[10/08/17 17:01:24] gc-core.c(46): GC index size is 1024 Byte.
[10/08/17 17:01:24] gc-core.c(327): Populating index.
[10/08/17 17:01:24] gc-core.c(181): Populating index for repo 27739631.
[10/08/17 17:01:24] …/…/common/seaf-db.c(425): Error prepare statement SELECT value FROM SeafileConf WHERE cfg_group=? AND cfg_key=?: mysql_stmt_prepare failed: Table ‘seafile.SeafileConf’ doesn’t exist.
[10/08/17 17:01:24] gc-core.c(234): Traversed 2 commits, 1 blocks.
[10/08/17 17:01:24] gc-core.c(341): Scanning and deleting unused blocks.
[10/08/17 17:01:24] gc-core.c(364): GC finished. 1 blocks total, about 1 reachable blocks, 0 blocks are removed.

[10/08/17 17:01:24] gc-core.c(384): === Repos deleted by users ===
[10/08/17 17:01:24] gc-core.c(392): GC deleted repo 650848a3.
[10/08/17 17:01:24] gc-core.c(456): === GC is finished ===
seafserv-gc run done

Done.

My system:

[root@cloud ~]# cat /etc/centos-release
CentOS Linux release 7.4.1708 (Core)
[root@cloud ~]# yum list installed | grep mariadb
MariaDB-client.x86_64 10.1.28-1.el7.centos @mariadb
MariaDB-common.x86_64 10.1.28-1.el7.centos @mariadb
MariaDB-server.x86_64 10.1.28-1.el7.centos @mariadb
MariaDB-shared.x86_64 10.1.28-1.el7.centos @mariadb
galera.x86_64 25.3.20-1.rhel7.el7.centos @mariadb

After starting Seafile Server, everything seems to work as expected.

Why is table ‘seafile.SeafileConf’ missing and how to solve that?

Don’t know why you don’t have this table(Have two 6.2.2 upgraded server). But at two of my seafile servers is this table empty so I guess it’s only for temp data. Here is table definitions.

CREATE TABLE `SeafileConf` (
  `cfg_group` varchar(255) NOT NULL,
  `cfg_key` varchar(255) NOT NULL,
  `value` varchar(255) DEFAULT NULL,
  `property` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1 Like

Thank you for your reply.

I found a fragment of the definition in seafserv-gc, which is called from seaf-gc,sh:

[root@cloud Server]# strings seafile-server-6.2.2/seafile/bin/seafserv-gc | grep SeafileConf
CREATE TABLE IF NOT EXISTS SeafileConf (cfg_group VARCHAR(255) NOT NULL,cfg_key VARCHAR(255) NOT NULL, value VARCHAR(255), property INTEGER) ENGINE=INNODB
CREATE TABLE IF NOT EXISTS SeafileConf (cfg_group VARCHAR(255) NOT NULL,cfg_key VARCHAR(255) NOT NULL, value VARCHAR(255), property INTEGER)
UPDATE SeafileConf SET value=? WHERE cfg_group=? AND cfg_key=?
INSERT INTO SeafileConf (value, cfg_group, cfg_key, property) VALUES (?,?,?,0)
SELECT 1 FROM SeafileConf WHERE cfg_group=? AND cfg_key=?
SELECT value FROM SeafileConf WHERE cfg_group=? AND cfg_key=?

I Assume, this is new in 6.2.x because it is not present in 6.1.2.

I don’t know why the table creation is not run on my system, but one thing I’ve done individually is the naming of the databases. Maybe it has something do with the problem.

[root@cloud Server]# echo ‘show databases;’ | mysql -u seafile -p
Enter password:
Database
ccnet
information_schema
seafile
seahub

Today I ran seaf-gc.sh and the SQL Errors are gone:

[seafserver@cloud seafile-server-latest]$ ./seaf-gc.sh

Starting seafserv-gc, please wait …
[10/09/17 08:35:54] gc-core.c(440): GC version 1 repo Demo([ID])
[10/09/17 08:35:54] gc-core.c(313): GC started. Total block number is 8.
[10/09/17 08:35:54] gc-core.c(46): GC index size is 1024 Byte.
[10/09/17 08:35:54] gc-core.c(327): Populating index.
[10/09/17 08:35:54] gc-core.c(181): Populating index for repo af3bd5ca.
[10/09/17 08:35:54] gc-core.c(234): Traversed 14 commits, 8 blocks.
[10/09/17 08:35:54] gc-core.c(341): Scanning and deleting unused blocks.
[10/09/17 08:35:54] gc-core.c(364): GC finished. 8 blocks total, about 8 reachable blocks, 0 blocks are removed.

[10/09/17 08:35:54] gc-core.c(440): GC version 1 repo Cloud([ID])
[10/09/17 08:35:55] gc-core.c(313): GC started. Total block number is 1747.
[10/09/17 08:35:55] gc-core.c(46): GC index size is 1024 Byte.
[10/09/17 08:35:55] gc-core.c(327): Populating index.
[10/09/17 08:35:55] gc-core.c(181): Populating index for repo 93d1f567.
[10/09/17 08:35:55] gc-core.c(234): Traversed 9 commits, 1720 blocks.
[10/09/17 08:35:55] gc-core.c(183): Populating index for sub-repo 1c612e4e.
[10/09/17 08:35:56] gc-core.c(234): Traversed 1 commits, 49 blocks.
[10/09/17 08:35:56] gc-core.c(183): Populating index for sub-repo 3eab867e.
[10/09/17 08:35:56] gc-core.c(234): Traversed 2 commits, 64 blocks.
[10/09/17 08:35:56] gc-core.c(341): Scanning and deleting unused blocks.
[10/09/17 08:35:56] gc-core.c(364): GC finished. 1747 blocks total, about 1833 reachable blocks, 0 blocks are removed.

[10/09/17 08:35:56] gc-core.c(440): GC version 1 repo Private([ID])
[10/09/17 08:35:56] gc-core.c(313): GC started. Total block number is 5833.
[10/09/17 08:35:56] gc-core.c(46): GC index size is 2916 Byte.
[10/09/17 08:35:56] gc-core.c(327): Populating index.
[10/09/17 08:35:56] gc-core.c(181): Populating index for repo 810dc1ee.
[10/09/17 08:35:57] gc-core.c(234): Traversed 5 commits, 5833 blocks.
[10/09/17 08:35:57] gc-core.c(341): Scanning and deleting unused blocks.
[10/09/17 08:35:57] gc-core.c(364): GC finished. 5833 blocks total, about 5833 reachable blocks, 0 blocks are removed.

[10/09/17 08:35:57] gc-core.c(440): GC version 1 repo My Library Template([ID])
[10/09/17 08:35:57] gc-core.c(313): GC started. Total block number is 1.
[10/09/17 08:35:57] gc-core.c(46): GC index size is 1024 Byte.
[10/09/17 08:35:57] gc-core.c(327): Populating index.
[10/09/17 08:35:57] gc-core.c(181): Populating index for repo 3ec0beea.
[10/09/17 08:35:57] gc-core.c(234): Traversed 2 commits, 1 blocks.
[10/09/17 08:35:57] gc-core.c(341): Scanning and deleting unused blocks.
[10/09/17 08:35:57] gc-core.c(364): GC finished. 1 blocks total, about 1 reachable blocks, 0 blocks are removed.

[10/09/17 08:35:57] gc-core.c(440): GC version 1 repo My Library([ID])
[10/09/17 08:35:57] gc-core.c(313): GC started. Total block number is 1.
[10/09/17 08:35:57] gc-core.c(46): GC index size is 1024 Byte.
[10/09/17 08:35:57] gc-core.c(327): Populating index.
[10/09/17 08:35:57] gc-core.c(181): Populating index for repo 27739631.
[10/09/17 08:35:57] gc-core.c(234): Traversed 2 commits, 1 blocks.
[10/09/17 08:35:57] gc-core.c(341): Scanning and deleting unused blocks.
[10/09/17 08:35:57] gc-core.c(364): GC finished. 1 blocks total, about 1 reachable blocks, 0 blocks are removed.

[10/09/17 08:35:57] gc-core.c(384): === Repos deleted by users ===
[10/09/17 08:35:57] gc-core.c(456): === GC is finished ===
seafserv-gc run done

Done.

Now the table exists on my system:

[seafserver@cloud seafile-server-latest]$ echo ‘show tables’ | mysql -u seafile -p seafile
Enter password:
Tables_in_seafile
Branch
GarbageRepos
InnerPubRepo
OrgQuota
OrgUserQuota
Repo
RepoFileCount
RepoGroup
RepoHead
RepoHistoryLimit
RepoInfo
RepoOwner
RepoSize
RepoTokenPeerInfo
RepoTrash
RepoUserToken
RepoValidSince
SeafileConf
SharedRepo
SystemInfo
UserQuota
UserShareQuota
VirtualRepo
WebAP

So my problem is solved. Thanks again for your help. I will not mark this thread as solved because i suspect a bug in seafserv-gc because it didn’t execute the CREATE TABLE the first time.

1 Like

I runned the script yesterday and I didn’t get any error. Your suppose with the name could be right.

Does your database user have permission to create tables? That could also be a reason.

I think so:

[root@cloud ~]# echo “SHOW GRANTS for ‘seafile’@‘localhost’” | mysql -u root -p
Enter password:
Grants for seafile@localhost
GRANT USAGE ON . TO ‘seafile’@‘localhost’ IDENTIFIED BY PASSWORD ‘XXXXXX’
GRANT ALL PRIVILEGES ON seafile.* TO ‘seafile’@‘localhost’
GRANT ALL PRIVILEGES ON ccnet.* TO ‘seafile’@‘localhost’
GRANT ALL PRIVILEGES ON seahub.* TO ‘seafile’@‘localhost’

I generated the basic configuration of MariaDB using ‘mysql_secure_installation’ and created the seafile user with Seafile’s ‘setup-seafile-mysql.sh’

Edit: today it worked without changing any access rights. One difference is: yesterday I had not started Seafile-6.2.2 once before seaf-gc.sh. And another difference: today it was the second run of seaf-gc.sh (the first run was yesterday).