Bug 1615718

Summary: pmchart: "Cannot open PCP archive: /var/log/pcp/pmlogger/nkshirsa.pnq.csb/20180704.0 Attempt to use an illegal context"
Product: Red Hat Enterprise Linux 8 Reporter: nikhil kshirsagar <nkshirsa>
Component: pcpAssignee: Nathan Scott <nathans>
Status: CLOSED ERRATA QA Contact: Jan Kurik <jkurik>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 8.0CC: agerstmayr, mgoodwin, nathans, patrickm
Target Milestone: rcKeywords: Bugfix, Triaged
Target Release: 8.5Flags: pm-rhel: mirror+
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: pcp-5.3.0-4.el8 Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-11-09 17:49:39 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description nikhil kshirsagar 2018-08-14 06:27:45 UTC
Description of problem:
additional archives fail to get added to existing chart with "Cannot open PCP archive: /var/log/pcp/pmlogger/nkshirsa.pnq.csb/20180704.0 Attempt to use an illegal context"

Version-Release number of selected component (if applicable):
pcp-3.12.2-5.el7.x86_64

How reproducible:
Create a pmchart chart with one archive, then try to add another archive with the "open view" option 


Additional info:
archive that had this issue is available at:

https://drive.google.com/file/d/1X8nwkgF29qnSKKPpjQO19JBIw8Mj0itj/view?usp=sharing
https://drive.google.com/file/d/1CZyGX2njKcjKH0TERVlLA650DZMjWDyn/view?usp=sharing
https://drive.google.com/file/d/1rbmv4c5rI2-laoDhRQHgk1KAzG2gyc2E/view?usp=sharing

Comment 3 Nathan Scott 2018-08-14 06:59:52 UTC
There's a good chance this is fixed in the more recent PCP - I can't reproduce the problem you're seeing (if I understand it correctly) ... could you try git PCP to confirm Nikhil?  (anything from pcp-4.1.0 or later should do)

If we can't reproduce it with pmchart from git, its likely the 7.6 pcp rebase has already included the fix.

Comment 4 Mark Goodwin 2018-08-14 23:39:45 UTC
I can reproduce this, running current pcp-4.1.2 sources. Here's the debug diags from running pmchart -Dcontext,pmc .... when I try and open another archive for the same host as the archive that is already open:

QmcGroup::use: No direct match for context "/var/log/pcp/pmlogger/kilcunda/20180815.00.10.2.xz" (type 2).
QmcGroup::use: Creating new context for "/var/log/pcp/pmlogger/kilcunda/20180815.00.10.2.xz"
QmcSource::getSource: Creating new source for /var/log/pcp/pmlogger/kilcunda/20180815.00.10.2.xz
pmWhichContext() -> 0, cur=0
__pmSetVersionIPC: fd=33 version=2
IPC table fd(PDU version): 17(2,0) 18(2,0) 19(2,0) 33(2,0)
__pmSetVersionIPC: fd=37 version=2
IPC table fd(PDU version): 17(2,0) 18(2,0) 19(2,0) 33(2,0) 37(2,0)
__pmSetVersionIPC: fd=38 version=2
IPC table fd(PDU version): 17(2,0) 18(2,0) 19(2,0) 33(2,0) 37(2,0) 38(2,0)
pmNewContext(2, /var/log/pcp/pmlogger/kilcunda/20180815.00.10.2.xz) -> 1
Dump Contexts: current -> contexts[1] handle 1
contexts[1] handle 1: log /var/log/pcp/pmlogger/kilcunda/20180815.00.10.2.xz: not open
 origin=1534255813.269358 delta=0
Dump Instance Profile state=INCLUDE, 0 profiles
pmWhichContext() -> 1, cur=1
pmWhichContext() -> 1, cur=1
__pmSetVersionIPC: fd=39 version=2
IPC table fd(PDU version): 17(2,0) 18(2,0) 19(2,0) 33(2,0) 37(2,0) 38(2,0) 39(2,0)
QmcSource::QmcSource: Created context 1 to archive "/var/log/pcp/pmlogger/kilcunda/20180815.00.10.2.xz"
pmWhichContext() -> 1, cur=1
pmNewZone(AEST-10) -> 2
pmUseZone(0) tz=AEST-10
pmUseContext(0) -> contexts[0]
pmUseContext(1) -> contexts[1]
QmcSource::dupContext: Using original context for archive "/var/log/pcp/pmlogger/kilcunda/20180815.00.10.2.xz"
pmDestroyContext(1) -> 0, curr_handle=-1
QmcSource::delContext: No contexts remain, removing archive "/var/log/pcp/pmlogger/kilcunda/20180815.00.10.2.xz"
QmcGroup::fetch: 0 contexts
QmcGroup::fetch: Done
QmcGroup::fetch: 0 contexts
QmcGroup::fetch: Done
QmcGroup::fetch: 0 contexts
QmcGroup::fetch: Done
QmcGroup::fetch: 0 contexts
QmcGroup::fetch: Done
QmcGroup::fetch: 0 contexts
QmcGroup::fetch: Done
QmcGroup::fetch: 0 contexts
QmcGroup::fetch: Done
QmcGroup::fetch: 0 contexts
QmcGroup::fetch: Done
pmchart: Error: Archives "20180801" and "/var/log/pcp/pmlogger/kilcunda/20180815.00.10.2.xz" are from the same host "kilcunda"
pmchart: Consider combining them using pmlogextract(1)

So I guess this is a context sharing issue since the two archives are for the same host.

In the mean-time, the work-around would be to specify the directory containing both archives with the -a flag, rather than trying to open the archives independently. In this directory mode, multiple archives in the same directory for the same host will share the same context, i.e. the archives are "auto-stitched" together.

Comment 5 Mark Goodwin 2018-08-15 00:10:09 UTC
Here's where the PM_ERR_NOCONTEXT error is returned from QmcGroup::use() in src/libpcp_qmc/src/qmc_group.cpp :

    185         // If we are in archive mode and are adding an archive,
    186         // make sure another archive for the same host does not exist
    187         if (my.restrictArchives && type == PM_CONTEXT_ARCHIVE) {
    188             for (i = 0; i < numContexts(); i++)
    189                 // No need to restrict comparison here, both are from
    190                 // log labels.
    191                 if (my.contexts[i]->source().host() ==
    192                         newContext->source().host()) {
    193                     pmprintf("%s: Error: Archives \"%s\" and \"%s\" are from "
    194                              "the same host \"%s\"\n", pmGetProgname(),
    195                              my.contexts[i]->source().sourceAscii(),
    196                              newContext->source().sourceAscii(),
    197                              my.contexts[i]->source().hostAscii());
    198                     pmprintf("%s: Consider combining them using pmlogextract(1)\n",
    199                              pmGetProgname());
    200                     delete newContext;
    201                     return PM_ERR_NOCONTEXT;
    202                 }
    203         }
    204 
   
Nathan, git-blame says you wrote that code, back in 2007 (!). Is the check still correct/relevant now we have Dave's archive auto-stitching?

Comment 6 Nathan Scott 2018-08-15 00:40:07 UTC
| Is the check still correct/relevant now we have Dave's archive auto-stitching?

Yes, I believe it is still needed.  Nikhil, are you adding either the same archive twice?  Or two different archives for the same host?  (I see only one archive attached to the BZ - so is it the first case?)

FWIW, pretty sure the UI wont allow selecting a directory to open - that'd be another extension worth adding.  The -a/--archive option should be OK with that though.  The error message (popup dialog) is a bit vague - it could certainly be augmented with some of those diagnostic text suggestions ("use pmlogextract" and "use a directory") as well.

Comment 7 nikhil kshirsagar 2018-08-15 01:55:31 UTC
Definitely not the same archive twice. I would expect that to fail. It's like mgoodwin said, another archive of the same host. I think I added just the one that caused the failure thinking it was something in the archive itself. But technically any two archives seem to reproduce this. At least the ones I tried.

Comment 9 Nathan Scott 2018-08-15 06:20:59 UTC
| I mean I uploaded just the one that caused the failure...

I suspect it takes both to hit the problem - the order probably doesn't matter (so its not either of the archives thats the problem, its using both together).

pmchart doesn't support multiple archives from the same host, except via the libpcp multi-archive functionality - which is not accessible from the UI (from memory) only the command line.

Comment 10 Nathan Scott 2019-06-28 03:54:05 UTC
Reset product to RHEL-8 as we'll want to fix this but its too late in the RHEL-7 lifecycle.

Comment 16 Nathan Scott 2021-05-14 01:48:37 UTC
This has been fixed upstream now by the following commit:

commit 0b62b6e2fef99a143b993bed273ce83e5a5563c3
Author: Nathan Scott <nathans>
Date:   Fri May 14 11:46:29 2021 +1000

    pmchart: use libpcp_qmc diagnostic for archives from same host
    
    Instead of providing a cryptic higher-level error message when
    the user attempts to open archives from the same host, use the
    message libpcp_qmc has constructed previously - all we need to
    do is to pmflush(3) it.
    
    Resolves Red Hat BZ #1615718

Comment 20 errata-xmlrpc 2021-11-09 17:49:39 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (pcp bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2021:4171