Re: Support for N synchronous standby servers - take 2

From: Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>
To: masao(dot)fujii(at)gmail(dot)com
Cc: sawada(dot)mshk(at)gmail(dot)com, michael(dot)paquier(at)gmail(dot)com, robertmhaas(at)gmail(dot)com, thom(at)linux(dot)com, thomas(dot)munro(at)enterprisedb(dot)com, memissemerson(at)gmail(dot)com, josh(at)agliodbs(dot)com, amit(dot)kapila16(at)gmail(dot)com, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Support for N synchronous standby servers - take 2
Date: 2016-02-24 08:37:57
Message-ID: 20160224.173757.38720623.horiguchi.kyotaro@lab.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox
Thread:
Lists: pgsql-hackers

Hello,

Ok, I think we should concentrate the parser part for now.

At Tue, 23 Feb 2016 17:44:44 +0900 (Tokyo Standard Time), Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp> wrote in <20160223(dot)174444(dot)178687579(dot)horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>
> Hello,
>
> At Mon, 22 Feb 2016 22:52:29 +0900, Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote in <CAHGQGwENujogaQvcc=u0tffNfFGtwXNb1yFcphdTYCJdG1_j1A(at)mail(dot)gmail(dot)com>
> > Thanks for updating the patch!
> >
> > When I changed s_s_names to 'hoge*' and reloaded the configuration file,
> > the server crashed unexpectedly with the following error message.
> > This is obviously a bug.
> >
> > FATAL: syntax error
>
> I had a glance on the lexer part in the new patch. It'd be
> better to design the lexer from the beginning according to the
> required behavior.
>
> The documentation for the syntax is saying as the following,
>
> http://www.postgresql.org/docs/current/static/runtime-config-logging.html
>
> > application_name (string)
> >
> > The application_name can be any string of less than NAMEDATALEN
> > characters (64 characters in a standard build). <snip> Only
> > printable ASCII characters may be used in the application_name
> > value. Other characters will be replaced with question marks (?).
>
> And according to what some functions mentioned so far do, totally
> an application_name is treated as follwoing, I suppose.
>
> - check_application_name() currently allows [\x20-\x7e], which
> differs from the definition of the SQL identifiers.
>
> - SplitIdentifierString() and syncrep code
>
> - allows any byte except a double quote in double-quoted
> representation. A double-quote just after a delimiter can open
> quoted representation.
>
> - Non-quoted name can contain any character including double
> quotes except ',' and white spaces.
>
> - The syncrep code does case-insensitive matching with the
> application_name.
>
> So, to preserve or following the current behavior expct the last
> one, the following pattern definitions would do. The
> lexer/grammer for the new format of s_s_names could be simpler
> than what it is.
>
> space [ \n\r\f\t\v] /* See the definition of isspace(3) */
> whitespace {space}+
> dquote \"
> app_name_chars [\x21-\x2b\x2d-\x7e] /* excluding ' ', ',' */
> app_name_indq_chars [\x20\x21\x23-\x7e] /* excluding '"' */
> app_name_dq_chars ({app_name_indq_chars}|{dquote}{dquote})
> delimiter {whitespace}*,{whitespace}*
> app_name ({app_name_chars}+|{dquote}{app_name_dq_chars}+{dquote})
> s_s_names {app_name}({delimiter}{app_name})*

So I made a hasty independent parser for the syntax including the
group names for the convenience for separate testing. The parser
takes input from stdin and prints the result structure.

It can take old s_s_name format and new list format. We haven't
discussed how to add gruop names but I added it as "<grpname>"
just before the # of syncronous standbys of [] and {} lists.

Is this usable for further discussions?

The sources can be compiles by the following commandline.

$ bison -v test.y; flex -l test.l; gcc -g -DYYDEBUG=1 -DYYERROR_VERBOSE -o ltest test.tab.c

and it makes the output like following.

[horiguti(at)drain tmp]$ echo '123[1,3,<x>3{a,b,e},4,*]' | ./ltest

TYPE: PRIO_LIST
GROUPNAME: <none>
NSYNC: 123
NEST: 2
CHILDREN {
{
TYPE: HOSTNAME
HOSTNAME: 1
QUOTED: No
NEST: 1
}
{
TYPE: HOSTNAME
HOSTNAME: 3
QUOTED: No
NEST: 0
}
TYPE: QUORUM_LIST
GROUPNAME: x
NSYNC: 3
NEST: 1
CHILDREN {
{
TYPE: HOSTNAME
HOSTNAME: a
QUOTED: No
NEST: 0
}
{
TYPE: HOSTNAME
HOSTNAME: b
QUOTED: No
NEST: 0
}
{
TYPE: HOSTNAME
HOSTNAME: e
QUOTED: No
NEST: 0
}
}
{
TYPE: HOSTNAME
HOSTNAME: 4
QUOTED: No
NEST: 0
}
{
TYPE: HOSTNAME
HOSTNAME: *
QUOTED: No
NEST: 0
}
}

regards,

--
Kyotaro Horiguchi
NTT Open Source Software Center

Attachment Content-Type Size
unknown_filename text/plain 1.4 KB
unknown_filename text/plain 4.9 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2016-02-24 09:01:59 Re: Support for N synchronous standby servers - take 2
Previous Message Amit Langote 2016-02-24 08:11:04 Re: Declarative partitioning