#1322 mod_storage_memory does not support 'key' querys

Reporter Jonas Schäfer
Owner Zash
Created
Updated
Stars ★ (1)
Tags
  • Milestone-0.11
  • Status-Fixed
  • Priority-Medium
  • Type-Defect
  1. Jonas Schäfer on

    What steps will reproduce the problem? 1. Have a PubSub node 2. Publish more than one item 3. Attempt to query the items via their IDs What is the expected output? A <items><item/><item/></items> structure with the appropriate items. What do you see instead? A <items><item/><item/></items> structure where the same item is returned multiple times. What version of the product are you using? On what operating system? $ hg log | head changeset: 9831:43f81e85cec2 tag: tip user: Kim Alvefur <zash@zash.se> date: Sun Feb 24 16:30:11 2019 +0100 summary: MUC: Fire an event to allow affecting decision of whether to allow a role change $ hg status | cat M certs/localhost.cnf M plugins/mod_pubsub/mod_pubsub.lua ? certs/Makefile ? certs/example.com.crt ? certs/example.com.key ? certs/keystone.cnf ? certs/keystone.crt ? certs/keystone.key ? certs/localhost.cnf.bkp~2016-10-13T16:14:02 ? certs/localhost.crt ? certs/localhost.crt.bkp~2016-10-13T16:23:10 ? certs/localhost.key ? certs/localhost.key.bkp~2016-10-13T16:23:10 ? plugins/mod_http_upload ? plugins/mod_storage_memory $ hg diff | cat diff -r 8e68136cde08 certs/localhost.cnf --- a/certs/localhost.cnf Fri Feb 22 07:33:23 2019 +0100 +++ b/certs/localhost.cnf Tue Feb 26 18:17:01 2019 +0100 @@ -11,7 +11,7 @@ [distinguished_name] countryName = GB organizationName = Prosody IM -organizationalUnitName = https://prosody.im/doc/certificates +organizationalUnitName = http://prosody.im/doc/certificates commonName = Example certificate [req] diff -r 8e68136cde08 plugins/mod_pubsub/mod_pubsub.lua --- a/plugins/mod_pubsub/mod_pubsub.lua Fri Feb 22 07:33:23 2019 +0100 +++ b/plugins/mod_pubsub/mod_pubsub.lua Tue Feb 26 18:17:01 2019 +0100 @@ -159,7 +159,10 @@ end); local admin_aff = module:get_option_string("default_admin_affiliation", "owner"); -local function get_affiliation(jid) +local function get_affiliation(jid, node, action) + if action == "create" then + return "owner"; + end local bare_jid = jid_bare(jid); if bare_jid == module.host or usermanager.is_admin(bare_jid, module.host) then return admin_aff; The patch is for allowing my end-to-end tests to arbitrarily create items \o/. Please provide any additional information below. I’m using mod_storage_memory, if that matters. Prosody logs: c2s562411ad9a30 debug Received[c2s]: <iq to='pubsub.localhost' id=':vG2g58uDm7O9PS2-g0xG' type='get'> pubsub.localhost:storage_memory debug query included pubsub.localhost:pubsub debug Get item 3df05e07-ad4f-4ffb-88ce-8510ee1f313b (published at 1551201167 by <nil>) pubsub.localhost:storage_memory debug query included pubsub.localhost:pubsub debug Get item 3df05e07-ad4f-4ffb-88ce-8510ee1f313b (published at 1551201167 by <nil>) c2s562411ad9a30 debug Sending[c2s]: <iq to='0ukhyecylx5vftxl@localhost/AyT0wms3' id=':vG2g58uDm7O9PS2-g0xG' type='result' from='pubsub.localhost'> A scansion type of thing to reproduce: [Client] Alice jid: d3mprpefsattdzqw@localhost/g4gTfCy0 password: password --------- Alice connects Alice sends: <presence xmlns:stream="http://etherx.jabber.org/streams" id=":7IoqYcT3191rfk_dZGo2"/> Alice receives: <presence xmlns:stream="http://etherx.jabber.org/streams" from="d3mprpefsattdzqw@localhost/g4gTfCy0" id=":7IoqYcT3191rfk_dZGo2"/> Alice sends: <iq xmlns:stream="http://etherx.jabber.org/streams" to="pubsub.localhost" id=":m0SM8Hn5JxP9BJJ_X4Mz" type="set"> <pubsub xmlns="http://jabber.org/protocol/pubsub"> <create node="e96caf12-264f-4e5a-988e-00ae191771b6"/> </pubsub> </iq> Alice receives: <iq xmlns:stream="http://etherx.jabber.org/streams" to="d3mprpefsattdzqw@localhost/g4gTfCy0" from="pubsub.localhost" type="result" id=":m0SM8Hn5JxP9BJJ_X4Mz"/> Alice sends: <iq xmlns:stream="http://etherx.jabber.org/streams" to="pubsub.localhost" id=":gwZgEQmzAHcQz-FZOxi-" type="get"> <pubsub xmlns="http://jabber.org/protocol/pubsub#owner"> <configure node="e96caf12-264f-4e5a-988e-00ae191771b6"/> </pubsub> </iq> Alice receives: <iq xmlns:stream="http://etherx.jabber.org/streams" to="d3mprpefsattdzqw@localhost/g4gTfCy0" from="pubsub.localhost" type="result" id=":gwZgEQmzAHcQz-FZOxi-"> <pubsub xmlns="http://jabber.org/protocol/pubsub#owner"> <configure node="e96caf12-264f-4e5a-988e-00ae191771b6"> <x xmlns="jabber:x:data" type="form"> <field var="FORM_TYPE" type="hidden"> <value>http://jabber.org/protocol/pubsub#node_config</value> </field> <field var="pubsub#title" label="Title" type="text-single"/> <field var="pubsub#description" label="Description" type="text-single"/> <field var="pubsub#type" label="The type of node data, usually specified by the namespace of the payload (if any)" type="text-single"/> <field var="pubsub#max_items" label="Max # of items to persist" type="text-single"> <validate xmlns="http://jabber.org/protocol/xdata-validate" datatype="xs:integer"/> <value>20</value> </field> <field var="pubsub#persist_items" label="Persist items to storage" type="boolean"> <value>0</value> </field> <field var="pubsub#access_model" label="Specify the subscriber model" type="list-single"> <option label="authorize"> <value>authorize</value> </option> <option label="open"> <value>open</value> </option> <option label="presence"> <value>presence</value> </option> <option label="roster"> <value>roster</value> </option> <option label="whitelist"> <value>whitelist</value> </option> <value>open</value> </field> <field var="pubsub#publish_model" label="Specify the publisher model" type="list-single"> <option label="publishers"> <value>publishers</value> </option> <option label="subscribers"> <value>subscribers</value> </option> <option label="open"> <value>open</value> </option> <value>publishers</value> </field> <field var="pubsub#deliver_notifications" label="Whether to deliver event notifications" type="boolean"> <value>1</value> </field> <field var="pubsub#deliver_payloads" label="Whether to deliver payloads with event notifications" type="boolean"> <value>1</value> </field> <field var="pubsub#notification_type" label="Specify the delivery style for notifications" type="list-single"> <option label="Messages of type normal"> <value>normal</value> </option> <option label="Messages of type headline"> <value>headline</value> </option> <value>headline</value> </field> <field var="pubsub#notify_delete" label="Whether to notify subscribers when the node is deleted" type="boolean"> <value>1</value> </field> <field var="pubsub#notify_retract" label="Whether to notify subscribers when items are removed from the node" type="boolean"> <value>1</value> </field> </x> </configure> </pubsub> </iq> Alice sends: <iq xmlns:stream="http://etherx.jabber.org/streams" to="pubsub.localhost" id=":pfWBQ2MNIq8ieul57Qp7" type="set"> <pubsub xmlns="http://jabber.org/protocol/pubsub"> <publish node="e96caf12-264f-4e5a-988e-00ae191771b6"> <item> <foo xmlns="https://zombofant.net/xmlns/aioxmpp#test">foo</foo> </item> </publish> </pubsub> </iq> Alice receives: <iq xmlns:stream="http://etherx.jabber.org/streams" to="d3mprpefsattdzqw@localhost/g4gTfCy0" from="pubsub.localhost" type="result" id=":pfWBQ2MNIq8ieul57Qp7"> <pubsub xmlns="http://jabber.org/protocol/pubsub"> <publish node="e96caf12-264f-4e5a-988e-00ae191771b6"> <item id="20e9eb9e-8acb-436e-a486-40e80400faf1"/> </publish> </pubsub> </iq> Alice sends: <iq xmlns:stream="http://etherx.jabber.org/streams" to="pubsub.localhost" id=":Q5TLT6nsW0HHdkDgrPPe" type="set"> <pubsub xmlns="http://jabber.org/protocol/pubsub"> <publish node="e96caf12-264f-4e5a-988e-00ae191771b6"> <item> <foo xmlns="https://zombofant.net/xmlns/aioxmpp#test">bar</foo> </item> </publish> </pubsub> </iq> Alice receives: <iq xmlns:stream="http://etherx.jabber.org/streams" to="d3mprpefsattdzqw@localhost/g4gTfCy0" from="pubsub.localhost" type="result" id=":Q5TLT6nsW0HHdkDgrPPe"> <pubsub xmlns="http://jabber.org/protocol/pubsub"> <publish node="e96caf12-264f-4e5a-988e-00ae191771b6"> <item id="4b94623d-1127-41c0-ac47-e283fd890557"/> </publish> </pubsub> </iq> Alice sends: <iq xmlns:stream="http://etherx.jabber.org/streams" to="pubsub.localhost" id=":3nvB2E20p1iuM6lOPaP6" type="get"> <pubsub xmlns="http://jabber.org/protocol/pubsub"> <items node="e96caf12-264f-4e5a-988e-00ae191771b6"> <item id="20e9eb9e-8acb-436e-a486-40e80400faf1"/> <item id="4b94623d-1127-41c0-ac47-e283fd890557"/> </items> </pubsub> </iq> Alice receives: <iq xmlns:stream="http://etherx.jabber.org/streams" to="d3mprpefsattdzqw@localhost/g4gTfCy0" from="pubsub.localhost" type="result" id=":3nvB2E20p1iuM6lOPaP6"> <pubsub xmlns="http://jabber.org/protocol/pubsub"> <items node="e96caf12-264f-4e5a-988e-00ae191771b6"> <item xmlns="http://jabber.org/protocol/pubsub" id="4b94623d-1127-41c0-ac47-e283fd890557"> <foo xmlns="https://zombofant.net/xmlns/aioxmpp#test">bar</foo> </item> <item xmlns="http://jabber.org/protocol/pubsub" id="4b94623d-1127-41c0-ac47-e283fd890557"> <foo xmlns="https://zombofant.net/xmlns/aioxmpp#test">bar</foo> </item> </items> </pubsub> </iq> Alice sends: <iq xmlns:stream="http://etherx.jabber.org/streams" to="pubsub.localhost" id=":XQdyK54iyOKiJvUoX9t_" type="get"> <pubsub xmlns="http://jabber.org/protocol/pubsub"> <items node="e96caf12-264f-4e5a-988e-00ae191771b6"/> </pubsub> </iq> Alice receives: <iq xmlns:stream="http://etherx.jabber.org/streams" to="d3mprpefsattdzqw@localhost/g4gTfCy0" from="pubsub.localhost" type="result" id=":XQdyK54iyOKiJvUoX9t_"> <pubsub xmlns="http://jabber.org/protocol/pubsub"> <items node="e96caf12-264f-4e5a-988e-00ae191771b6"> <item xmlns="http://jabber.org/protocol/pubsub" id="20e9eb9e-8acb-436e-a486-40e80400faf1"> <foo xmlns="https://zombofant.net/xmlns/aioxmpp#test">foo</foo> </item> <item xmlns="http://jabber.org/protocol/pubsub" id="4b94623d-1127-41c0-ac47-e283fd890557"> <foo xmlns="https://zombofant.net/xmlns/aioxmpp#test">bar</foo> </item> </items> </pubsub> </iq> Alice sends: <iq xmlns:stream="http://etherx.jabber.org/streams" to="pubsub.localhost" id=":ySGQOz5tnyWT82idwJZP" type="set"> <pubsub xmlns="http://jabber.org/protocol/pubsub#owner"> <delete node="e96caf12-264f-4e5a-988e-00ae191771b6"/> </pubsub> </iq> Alice receives: <iq xmlns:stream="http://etherx.jabber.org/streams" to="d3mprpefsattdzqw@localhost/g4gTfCy0" from="pubsub.localhost" type="result" id=":ySGQOz5tnyWT82idwJZP"/> (NOTE: ^ that is not the expected output, that is what I’m seeing. The expected output would have the list of all items and the list of items queried by ID identical.)

  2. Zash on

    We ruled out util.pubsub and determined that the fault is in mod_storage_memory. The problem is that it does not support the 'key' field in archive queries, which is how mod_pubsub requests individual items.

    Changes
    • owner Zash
    • tags Status-Accepted Milestone-0.11
    • title pubsub: Get Items by IDs returns incorrect items mod_storage_memory does not support 'key' querys
  3. Zash on

    Fixed in https://hg.prosody.im/0.11/rev/96d9c121547b Thanks for the report and the test case

    Changes
    • tags Status-Fixed
  4. Jonas Schäfer on

    Thanks! Works with latest 0.11 revision and built-in storage memory.

New comment

Not published. Used for spam prevention and optional update notifications.