[Csync2] csync_check_del broken under PostgreSQL

Lars Ellenberg lars.ellenberg at linbit.com
Mon Oct 23 13:23:51 CEST 2017


On Sun, Oct 22, 2017 at 11:33:55AM +0100, James Le Cuirot wrote:
> When checking for deleted files recursively, csync2 issues a SQL
> statement like this.
> 
> => SELECT filename from file where filename > '/mnt/csync2/portage/app-editors/ng/' and filename < '/mnt/csync2/portage/app-editors/ng0' ORDER BY filename;
>  filename 
> ----------
> (0 rows)
> 
> This never returns anything under PostgreSQL. The behaviour is actually
> rather odd. Using LIKE gives the result we expect.
> 
> => SELECT filename FROM file WHERE filename LIKE '/mnt/csync2/portage/app-editors/ng/%';
>                                filename                               
> ----------------------------------------------------------------------
>  /mnt/csync2/portage/app-editors/ng/metadata.xml
>  /mnt/csync2/portage/app-editors/ng/files
>  /mnt/csync2/portage/app-editors/ng/files/ng-1.5beta1-ncurses.patch
>  /mnt/csync2/portage/app-editors/ng/files/ng-1.5beta1-configure.patch
>  /mnt/csync2/portage/app-editors/ng/Manifest
>  /mnt/csync2/portage/app-editors/ng/ng-1.5_beta1-r2.ebuild
> (6 rows)
> 
> But watch what happens when we change the 0 to a g.
> 
> => SELECT filename from file where filename > '/mnt/csync2/portage/app-editors/ng/' and filename < '/mnt/csync2/portage/app-editors/ngg' ORDER BY filename;
>                                filename                               
> ----------------------------------------------------------------------
>  /mnt/csync2/portage/app-editors/ng/files
>  /mnt/csync2/portage/app-editors/ng/files/ng-1.5beta1-configure.patch
>  /mnt/csync2/portage/app-editors/ng/files/ng-1.5beta1-ncurses.patch
> (3 rows)
> 
> It's almost like the / in ng/files isn't used in the comparison. I
> couldn't find anything in the PostgreSQL documentation specifically
> about using the <> operators with strings.

What are your locale and collate settings?

afaik, = < > compare "collate character units", while LIKE, appart from
supporting wildcards, compares "byte per byte" when used with literals.
I may be wrong.

Anyways, maybe alter table ... binary ... helps?
Or change "TEXT" to "BLOB"?
Something like that?

I don't think many installations out there use csync2 with mysql or postgres,
so it is very likely that there are a number of shortcomings burried in there,
I'd expect "very long path names" to show problems as well, where "very
long" may be simply "longer than the default supported unique key length
on text fields.

-- 
: Lars Ellenberg
: LINBIT | Keeping the Digital World Running
: DRBD -- Heartbeat -- Corosync -- Pacemaker
: R&D, Integration, Ops, Consulting, Support

DRBD® and LINBIT® are registered trademarks of LINBIT


More information about the Csync2 mailing list