Skip to content

set command ‘set transaction_read_only = 0;‘ routed to standby node and execute failed. #155

@liujinyang-highgo

Description

@liujinyang-highgo

Hi,
I have met an issue:

envionment
pgpool 4.6.2 + three backend nodes(one primary and two standby nodes, weight=0:1:1)

reproduce

  1. start pgpool
  2. run following command:
    begin;
    set transaction_read_only = 0;
    commit;
  3. 'set transaction_read_only = 0;' would be routed to standby node and execute failed.

analyze
when node is VariableSetStmt and the value is integer, it should be 'if (!v->val.ival.ival)' but not 'if (v->val.ival.ival)'

in function static POOL_DEST send_to_where(Node *node)
{
     ......
     else if (IsA(node, VariableSetStmt))
    {
                ListCell   *list_item;
                bool            ret = POOL_BOTH;

                /*
                 * SET transaction_read_only TO off
                 */
                if (((VariableSetStmt *) node)->kind == VAR_SET_VALUE &&
                        !strcmp(((VariableSetStmt *) node)->name, "transaction_read_only"))
                {
                        List       *options = ((VariableSetStmt *) node)->args;

                        foreach(list_item, options)
                        {
                                A_Const    *v = (A_Const *) lfirst(list_item);

                                switch (nodeTag(&v->val))
                                {
                                        case T_String:
                                                if (!strcasecmp(v->val.sval.sval, "off") ||
                                                        !strcasecmp(v->val.sval.sval, "f") ||
                                                        !strcasecmp(v->val.sval.sval, "false"))
                                                        ret = POOL_PRIMARY;
                                                break;
                                        case T_Integer:
                                                if (v->val.ival.ival)
                                                        ret = POOL_PRIMARY;
                                        default:
                                                break;
                                }
                        }
                        return ret;
                }
     }

}

  1. attachment is the patch , verified has been passed.

0001-fix-issue-set-transaction_read_only-0-was-routed-to-.patch

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions