Menu

#490 message missing in handle_response

1.2 Dev Q
open
nobody
None
5
2014-09-22
2014-09-22
peace zone
No

I execute a user define function and get two different results. Both the two results appear randomly, the result2 is expected.

  1. Results
    results1:
    postgres=# select trap_foreign_key(2);
    NOTICE: caught foreign_key_violation
    ERROR: failed to send COMMIT command to node

results2:
postgres=# select trap_foreign_key(2);
NOTICE: caught foreign_key_violation
trap_foreign_key
------------------
0
(1 row)

  1. Object definition
    CREATE TABLE master(f1 int primary key);
    CREATE TABLE slave(f1 int references master deferrable);

CREATE FUNCTION trap_foreign_key(int) RETURNS INT AS $$
BEGIN
begin -- start transaction
insert into slave values($1);
exception
when foreign_key_violation then
raise notice 'caught foreign_key_violation';
return 0;
end;
return 1;
end$$ language plpgsql;

select trap_foreign_key(2); – detects FK violation

  1. Debug output

I add a elog in handle_reponse() of coordinator:

msg_type = get_message(conn, &msg_len, &msg);
elog(WARNING, "Received message type: %c", msg_type);

The debug output is in the attachment.
As the debug output shows, the result1 misses the N, Z messages from datanode.

  1. Reason

The reason is when the coordinator in justifing message buffer,
the datanode has not yet send the messages.The coordinator thinks
there is no message now, and return, the later messages from datanode is missed.

The coordinator code:
if (!HAS_MESSAGE_BUFFERED(conn))
return RESPONSE_EOF;

The N,Z messages comes later than the check above.

1 Attachments

Related

Bugs: #490

Discussion

  • Koichi Suzuki

    Koichi Suzuki - 2014-09-26

    Sorry, exception is not supported in XC at present. This needs
    SAVEPOINT feature inside SPI. Also, for the same reason, you cannot
    issue more than one DML in a function.

    Regards;

    Koichi Suzuki

    2014-09-22 18:41 GMT+09:00 peace zone peacezone@users.sf.net:


    [bugs:#490] message missing in handle_response

    Status: open
    Group: 1.2 Dev Q
    Created: Mon Sep 22, 2014 09:41 AM UTC by peace zone
    Last Updated: Mon Sep 22, 2014 09:41 AM UTC
    Owner: nobody

    I execute a user define function and get two different results. Both the two
    results appear randomly, the result2 is expected.

    Results
    results1:
    postgres=# select trap_foreign_key(2);
    NOTICE: caught foreign_key_violation
    ERROR: failed to send COMMIT command to node

    results2:
    postgres=# select trap_foreign_key(2);
    NOTICE: caught foreign_key_violation
    trap_foreign_key


    0
    (1 row)

    Object definition
    CREATE TABLE master(f1 int primary key);
    CREATE TABLE slave(f1 int references master deferrable);

    CREATE FUNCTION trap_foreign_key(int) RETURNS INT AS $$
    BEGIN
    begin -- start transaction
    insert into slave values($1);
    exception
    when foreign_key_violation then
    raise notice 'caught foreign_key_violation';
    return 0;
    end;
    return 1;
    end$$ language plpgsql;

    select trap_foreign_key(2); – detects FK violation

    Debug output

    I add a elog in handle_reponse() of coordinator:

    msg_type = get_message(conn, &msg_len, &msg);
    elog(WARNING, "Received message type: %c", msg_type);

    The debug output is in the attachment.
    As the debug output shows, the result1 misses the N, Z messages from
    datanode.

    Reason

    The reason is when the coordinator in justifing message buffer,
    the datanode has not yet send the messages.The coordinator thinks
    there is no message now, and return, the later messages from datanode is
    missed.

    The coordinator code:
    if (!HAS_MESSAGE_BUFFERED(conn))
    return RESPONSE_EOF;

    The N,Z messages comes later than the check above.


    Sent from sourceforge.net because you indicated interest in
    https://sourceforge.net/p/postgres-xc/bugs/490/

    To unsubscribe from further messages, please visit
    https://sourceforge.net/auth/subscriptions/

     

    Related

    Bugs: #490

    • peace zone

      peace zone - 2014-09-26

      Thanks for your response!
      1. I found this condition during doing the make check.
      2. Do we have a plan to adding this feature?

       
      • Koichi Suzuki

        Koichi Suzuki - 2014-09-26

        Sorry, I was wrong.

        If you found it within the make check, the cause is not here.

        In make check, test script sometimes cancels statement execution
        intentionally. This cancellation is done in asynchronous manner and
        when the cancellation takes time, typically in slower environment,
        following script has to run while the cancellation is not complete.

        Unfortunately, it is not simple to perform this cancellation in
        synchronous manner. Instead, we inserted some wait before the next
        script is ready to run. We understand this is not complete and we
        still have a good chance to have such error occasionally.

        You can ignore this. If you write an application where you cancel
        statement execution intentionally, then you should be careful to see
        if the cancellation is complete.

        Thank you very much for pointing out.

        Please also understand the limitation I mentioned is collect.

        Regards;

        Koichi Suzuki

        2014-09-26 11:29 GMT+09:00 peace zone peacezone@users.sf.net:

        Thanks for your response!
        1. I found this condition during doing the make check.
        2. Do we have a plan to adding this feature?


        [bugs:#490] message missing in handle_response

        Status: open
        Group: 1.2 Dev Q
        Created: Mon Sep 22, 2014 09:41 AM UTC by peace zone
        Last Updated: Mon Sep 22, 2014 09:41 AM UTC
        Owner: nobody

        I execute a user define function and get two different results. Both the two
        results appear randomly, the result2 is expected.

        Results
        results1:
        postgres=# select trap_foreign_key(2);
        NOTICE: caught foreign_key_violation
        ERROR: failed to send COMMIT command to node

        results2:
        postgres=# select trap_foreign_key(2);
        NOTICE: caught foreign_key_violation
        trap_foreign_key


        0
        (1 row)

        Object definition
        CREATE TABLE master(f1 int primary key);
        CREATE TABLE slave(f1 int references master deferrable);

        CREATE FUNCTION trap_foreign_key(int) RETURNS INT AS $$
        BEGIN
        begin -- start transaction
        insert into slave values($1);
        exception
        when foreign_key_violation then
        raise notice 'caught foreign_key_violation';
        return 0;
        end;
        return 1;
        end$$ language plpgsql;

        select trap_foreign_key(2); – detects FK violation

        Debug output

        I add a elog in handle_reponse() of coordinator:

        msg_type = get_message(conn, &msg_len, &msg);
        elog(WARNING, "Received message type: %c", msg_type);

        The debug output is in the attachment.
        As the debug output shows, the result1 misses the N, Z messages from
        datanode.

        Reason

        The reason is when the coordinator in justifing message buffer,
        the datanode has not yet send the messages.The coordinator thinks
        there is no message now, and return, the later messages from datanode is
        missed.

        The coordinator code:
        if (!HAS_MESSAGE_BUFFERED(conn))
        return RESPONSE_EOF;

        The N,Z messages comes later than the check above.


        Sent from sourceforge.net because you indicated interest in
        https://sourceforge.net/p/postgres-xc/bugs/490/

        To unsubscribe from further messages, please visit
        https://sourceforge.net/auth/subscriptions/

         

        Related

        Bugs: #490

        • peace zone

          peace zone - 2014-09-26

          Thanks for your explanation, I will do as you say

           

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.