Open claywd opened 1 year ago
Hi, please update to 25.0.7 or better 26.0.2 and report back if it fixes the issue. Thank you!
My goal is to add a label like e.g. 26-feedback to this ticket of an up-to-date major Nextcloud version where the bug could be reproduced. However this is not going to work without your help. So thanks for all your effort!
If you don't manage to reproduce the issue in time and the issue gets closed but you can reproduce the issue afterwards, feel free to create a new bug report with up-to-date information by following this link: https://github.com/nextcloud/server/issues/new?assignees=&labels=bug%2C0.+Needs+triage&template=BUG_REPORT.yml&title=%5BBug%5D%3A+
@szaimen Was any work done to address the issue in the convert command in recent releases?
Possibly yes
yeah... I decided that shared calendars weren't worth risking an upgrade with my current setup. I dropped all the records in that table and the convert command worked. I think it might be a little unreasonable to blanket request people upgrade to check if the problem still exists. I would suggest pointing people to the exact fix they need to implement. Otherwise, you risk introducing so many more errors... Its just not worth it in the long run.
An exception occurred while executing a query: SQLSTATE[22021]: Character not in repertoire: 7 ERROR: invalid byte sequence for encoding "UTF8": 0x00
Sounds like the infamous PostgreSQL not accepting code zero/NULLs in strings issue.
Apparently this is still broken also om 26.
Sounds like the infamous PostgreSQL not accepting code zero/NULLs in strings issue.
Indeed. In best case should the occ command already take care of this and update the 0x00 values in text type columns to empty strings.
Cc @nextcloud/server-backend for pointers on how to implement this. This should not be hard, or is it?
Probably there would need to be adjustmenets in this file? https://github.com/nextcloud/server/blob/master/core/Command/Db/ConvertType.php How could a logic that fixes this look like?
I am affected by this Bug too. As long as it is not fixed I can't migrate to nextcloud aio. Is there a way I can help? Is a solution in sight? Probably with the next bugfix release of nextcloud?
@ralfrupf1976 Is yours happening in the same table out of curiosity?
That's the error during the migration:
oc_properties
chunked query, 4 chunks
2800/3068 [=========================>--] 91% 1 sec/1 sec
In ExceptionConverter.php line 91:
An exception occurred while executing a query: SQLSTATE[22021]: Character not in repertoire: 7 ERROR: invalid byte sequence for encoding "UTF8": 0x00
In Exception.php line 30:
SQLSTATE[22021]: Character not in repertoire: 7 ERROR: invalid byte sequence for encoding "UTF8": 0x00
In Statement.php line 101:
SQLSTATE[22021]: Character not in repertoire: 7 ERROR: invalid byte sequence for encoding "UTF8": 0x00
Ideally we track down the source of these null 0x00 characters ending up in there to start with and address it there. Of course we may still have to deal with existing in-place data.
What we really need are steps to reproduce the situation where the 0x00 character entries are created to start with.
The next best thing is to identify which existing database entries are triggering this. And the following can be ran from your MariaDB/MySQL client to do so:
SELECT * FROM oc_properties WHERE propertyvalue like concat('%', 0x00, '%');
If you feel comfortable sharing a few of the returned entries, that could be insightful to tracking down the true culprit. It is a read-only command so it should be safe (unlike the one below). But database backups are recommended nonetheless!
It may be possible to manually fix these entries (see below), but this is untested.
The side effect of doing this are untested. Make a backup. Don't try this unless you're comfortable with the ramifications, know how to restore from your backups, and/or are able to do it solely on a throwaway test instance!
The following will, in theory, change all occurrences of the invisible character (0x00
) with an actual empty string.
UPDATE oc_properties SET propertyvalue = replace(propertyvalue, 0x00, '') WHERE propertyvalue like concat('%', 0x00, '%');
P.S. I'm currently making the assumption that the character is ending up in the propertyvalue
column. I suppose it could be elsewhere, but that's my best guess.
SELECT * FROM oc_properties WHERE propertyvalue like concat('%', 0x00, '%');
SELECT * FROM oc_properties WHERE propertyvalue like concat('%', 0x00, '%');
+------+---------------+--------------------------------------------------------------+---------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------+
| id | userid | propertypath | propertyname | propertyvalue | valuetype |
+------+---------------+--------------------------------------------------------------+---------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------+
| 3422 | michal.maurer | calendars/michal.maurer/personal_shared_by_marianne.schnyder | {urn:ietf:params:xml:ns:caldav}schedule-calendar-transp | O:48:"Sabre\CalDAV\Xml\Property\ScheduleCalendarTransp":1:{s:8:" * value";s:6:"opaque";} | 3 |
| 3439 | michal.maurer | calendars/michal.maurer/michal-pfarrerin | {DAV:}resourcetype | O:35:"Sabre\DAV\Xml\Property\ResourceType":1:{s:8:" * value";a:3:{i:0;s:39:"{urn:ietf:params:xml:ns:caldav}calendar";i:1;s:43:"{http://calendarserver.org/ns/}shared-owner";i:2;s:16:"{DAV:}collection";}} | 3 |
+------+---------------+--------------------------------------------------------------+---------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------+
2 rows in set (0.01 sec)
YES - the UPDATE oc_properties command above helped! Now the conversation has completed and my nextcloud runs on postgrsql!! Thank you very much - i can continue now with the migration to Nextcloud AIO.
Above you see the 2 entries which made the error...
Seems we're passing private and protected member variables unfettered through PHP serialization somewhere. PHP serialize()
sticks null bytes around them in the serialized output:
Sabre\CalDAV\Xml\Property\ScheduleCalendarTransp
Sabre\DAV\Xml\Property\ResourceType
https://www.php.net/manual/en/function.serialize.php
Limited to Calendar stuff so far it appears.
Since this is a TEXT rather than BLOB column... In MySQL it likely doesn't make much difference, but with PostgreSQL it's another matter.
I'm also kind of wondering if maybe this was a transient bug somewhere along the way. I only say that because it seems like it would have come up more. That or introduced relatively recently...
Does anyone have a fix for this? I have no null characters...
Not sure if exactly related, but it might help with reproducing this issue:
We ran into this error after my girlfriend tried to share a calendar with me from her iPhone calendar app. The calendar disappeared from her phone and web interface. Quite a dangerous bug for novice users.
It wasn't caused by the migration however since our database has already been migrated from MySQL to PostgreSQL a while ago.
It was quite easy to reproduce for me:
Deleting the records with the offending propertyvalue
for that user's calendar made the calendars appear again.
Deleting the records with the offending
propertyvalue
for that user's calendar made the calendars appear again.
How did you identify the offending record?
You can simply remove all rows with valuetype = 3
(object type)
⚠️ This issue respects the following points: ⚠️
Bug description
converting database from mysql to postgres fails for (more than one) reason but specifically this time because of encoding issues between the tables with error
An exception occurred while executing a query: SQLSTATE[22021]: Character not in repertoire: 7 ERROR: invalid byte sequence for encoding "UTF8": 0x00 CONTEXT: unnamed portal parameter $5
Steps to reproduce
./occ db:convert-type --password "redacted" pgsql nextcloud pg_db_name nextcloud
as the www-data user within the nextcloud directoryExpected behavior
New database tables and schema are configured and populated in new postgresql db with transformed from previous mysql db.
Installation method
Community Docker image
Nextcloud Server version
24
Operating system
Debian/Ubuntu
PHP engine version
PHP 8.1
Web server
Nginx
Database engine version
PostgreSQL
Is this bug present after an update or on a fresh install?
Fresh Nextcloud Server install
Are you using the Nextcloud Server Encryption module?
Encryption is Disabled
What user-backends are you using?
Configuration report
List of activated Apps
Nextcloud Signing status
Nextcloud Logs
Additional info
I think this may be an issue with the way characters were stored in mysql vs postgresql. Not just in this table but in general in all the tables.
table output