[Pacemaker] reliable way to cib SEGFAULT -- how is cibadmin -Q --xpath supposed to work?

Lars Ellenberg lars.ellenberg at linbit.com
Wed Jun 3 16:10:33 UTC 2009


current mercurial pacemaker stable-1.0

do
cibadmin -Q --xpath //@id
and watch your cib segfault:
WARN: Managed /usr/lib/heartbeat/cib process 15295 killed by signal 11 [SIGSEGV - Segmentation violation]

:)

(gdb) bt
#0  0x40280a8b in xmlAddChild () from /usr/lib/libxml2.so.2
#1  0x40031828 in add_node_copy (parent=0x80b6c10, src_node=0x8101720) at xml.c:266
#2  0x40051c64 in cib_process_xpath (op=0x806a068 "cib_query", options=2, section=0x80ffe68 "//@id", req=0x8115bf0, input=0x0, existing_cib=0x8115d98, result_cib=0xbfd1d198, answer=0xbfd1d19c) at cib_ops.c:938
#3  0x4004ebb4 in cib_process_query (op=0x806a068 "cib_query", options=2, section=0x80ffe68 "//@id", req=0x8115bf0, input=0x0, existing_cib=0x8115d98, result_cib=0xbfd1d198, answer=0xbfd1d19c) at cib_ops.c:49
#4  0x400531c1 in cib_perform_op (op=0x806a068 "cib_query", call_options=2, fn=0x805c8d4, is_query=1, section=0x80ffe68 "//@id", req=0x8115bf0, input=0x0, manage_counters=0, config_changed=0xbfd1d188, current_cib=0x8115d98, result_cib=0xbfd1d198, diff=0x0, output=0xbfd1d19c)
    at cib_utils.c:539

blah blah.

problem: the result is an attribute node, and gets added to the properties
field of the querry-result node on first match,
the next match will segfault out somewhere.

for only one match, I simply get an empty answer from cibadmin, no segfault.

now, why do I want to do that.
lets say I have the IP, and want to know the xml id of the IPaddr2 primitive
that handles this IP.

(yes, of course, you are right.  actually I do not care about the IPaddr2, but
 want to deduce the master id from a given drbd resource name.
 but lets stay with the IP example for now.)

cibadmin -Q --xpath '//primitive[@type="IPaddr2" and instance_attributes/nvpair [@name = "ip" and @value="10.0.0.1"]]'

fine.  I can sed the id out from there.
but I'd like to just do
cibadmin -Q --xpath '//primitive[@type="IPaddr2" and instance_attributes/nvpair [@name = "ip" and @value="10.0.0.1"]]/@id'
(which, unfortunately, is empty).

according to xmllint, my xpath query is correct, however:

cat > tmp.xml <<___
<cib>
  <configuration>
    <resources>
      <primitive class="ocf" id="ip_try3" provider="heartbeat" type="IPaddr2">
        <instance_attributes id="ip_try3-instance_attributes">
          <nvpair id="ip_try3-instance_attributes-ip" name="ip" value="10.0.0.1"/>
        </instance_attributes>
      </primitive>
    </resources>
  </configuration>
</cib>
___


xmllint --shell tmp.xml <<<'ls //@id'
/ > ls //@id
tan        7 ip_try3
t--       27 ip_try3-instance_attributes
t--       30 ip_try3-instance_attributes-ip
/ > 

xmllint --shell tmp.xml <<<'ls //primitive[@type="IPaddr2" and instance_attributes/nvpair[@name = "ip" and @value="10.0.0.1"]]/@id'
/ > ls //primitive[@type="IPaddr2" and instance_attributes/nvpair[@name = "ip" and @value="10.0.0.1"]]/@id
tan        7 ip_try3
/ > 

-- 
: Lars Ellenberg
: LINBIT | Your Way to High Availability
: DRBD/HA support and consulting http://www.linbit.com

DRBD® and LINBIT® are registered trademarks of LINBIT, Austria.




More information about the Pacemaker mailing list