<!-- 
RSS generated by JIRA (8.3.4#803005-sha1:1f96e09b3c60279a408a2ae47be3c745f571388b) at Sat Feb 10 16:05:22 JST 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>PFS-JIRA</title>
    <link>https://pfspipe.ipmu.jp/jira</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>8.3.4</version>
        <build-number>803005</build-number>
        <build-date>13-09-2019</build-date>
    </build-info>


<item>
            <title>[PIPE2D-1272] Switch drp summit registry to postgres </title>
                <link>https://pfspipe.ipmu.jp/jira/browse/PIPE2D-1272</link>
                <project id="10002" key="PIPE2D">DRP 2-D Pipeline</project>
                    <description>&lt;p&gt;Since summit drp is not heavily used we though we could get away with using sqlite but some ingest failures started to happen few days ago.&lt;/p&gt;

&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;(rubin3_ics) pfs@shell-ics:/data/logs/actors/drp$ cat 2023-*|grep &apos;Failed to register&apos;
2023-07-22 04:02:35.951Z actor.ingestPfs  30 ingest.py:627 Failed to ingest file /data/raw/2023-07-22/ramps/PFSB09719733.fits: Failed to register file /data/raw/2023-07-22/ramps/PFSB09719733.fits
2023-07-22 10:23:59.725Z actor.ingestPfs  30 ingest.py:627 Failed to ingest file /data/raw/2023-07-22/ramps/PFSB09731433.fits: Failed to register file /data/raw/2023-07-22/ramps/PFSB09731433.fits
2023-07-23 06:42:20.056Z actor.ingestPfs  30 ingest.py:627 Failed to ingest file /data/raw/2023-07-23/ramps/PFSB09748533.fits: Failed to register file /data/raw/2023-07-23/ramps/PFSB09748533.fits
2023-07-23 13:06:58.276Z actor.ingestPfs  30 ingest.py:627 Failed to ingest file /data/raw/2023-07-23/ramps/PFSB09757133.fits: Failed to register file /data/raw/2023-07-23/ramps/PFSB09757133.fits
2023-07-23 14:10:09.782Z actor.ingestPfs  30 ingest.py:627 Failed to ingest file /data/raw/2023-07-23/ramps/PFSB09758713.fits: Failed to register file /data/raw/2023-07-23/ramps/PFSB09758713.fits
2023-07-24 12:43:33.564Z actor.ingestPfs  30 ingest.py:627 Failed to ingest file /data/raw/2023-07-24/ramps/PFSB09781333.fits: Failed to register file /data/raw/2023-07-24/ramps/PFSB09781333.fits
2023-07-24 21:06:02.068Z actor.ingestPfs  30 ingest.py:627 Failed to ingest file /data/raw/2023-07-24/ramps/PFSB09789733.fits: Failed to register file /data/raw/2023-07-24/ramps/PFSB09789733.fits
2023-07-25 11:05:10.116Z actor.ingestPfs  30 ingest.py:627 Failed to ingest file /data/raw/2023-07-25/ramps/PFSB09801433.fits: Failed to register file /data/raw/2023-07-25/ramps/PFSB09801433.fits
2023-07-25 13:24:19.964Z actor.ingestPfs  30 ingest.py:627 Failed to ingest file /data/raw/2023-07-25/sps/PFSA09804332.fits: Failed to register file /data/raw/2023-07-25/sps/PFSA09804332.fits
2023-07-25 21:38:30.050Z actor.ingestPfs  30 ingest.py:627 Failed to ingest file /data/raw/2023-07-25/ramps/PFSB09813513.fits: Failed to register file /data/raw/2023-07-25/ramps/PFSB09813513.fits
2023-07-25 22:30:51.503Z actor.ingestPfs  30 ingest.py:627 Failed to ingest file /data/raw/2023-07-25/ramps/PFSB09814833.fits: Failed to register file /data/raw/2023-07-25/ramps/PFSB09814833.fits
2023-07-25 22:42:22.287Z actor.ingestPfs  30 ingest.py:627 Failed to ingest file /data/raw/2023-07-25/ramps/PFSB09815133.fits: Failed to register file /data/raw/2023-07-25/ramps/PFSB09815133.fits
2023-07-26 05:26:15.771Z actor.ingestPfs  30 ingest.py:627 Failed to ingest file /data/raw/2023-07-26/ramps/PFSB09820413.fits: Failed to register file /data/raw/2023-07-26/ramps/PFSB09820413.fits
2023-07-26 08:42:29.993Z actor.ingestPfs  30 ingest.py:627 Failed to ingest file /data/raw/2023-07-26/sps/PFSA09833631.fits: Failed to register file /data/raw/2023-07-26/sps/PFSA09833631.fits
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;My guess is that it&apos;s failing because of concurrent ingest.&lt;br/&gt;
&lt;a href=&quot;https://pfspipe.ipmu.jp/jira/secure/ViewProfile.jspa?name=price&quot; class=&quot;user-hover&quot; rel=&quot;price&quot;&gt;price&lt;/a&gt; I remember you did the migration on pfsa, if you have some instructions/scripts ready, I&apos;d be happy to do that on shell2-ics.&lt;/p&gt;</description>
                <environment></environment>
        <key id="23755">PIPE2D-1272</key>
            <summary>Switch drp summit registry to postgres </summary>
                <type id="1" iconUrl="https://pfspipe.ipmu.jp/jira/secure/viewavatar?size=xsmall&amp;avatarId=10503&amp;avatarType=issuetype">Bug</type>
                                            <priority id="10000" iconUrl="https://pfspipe.ipmu.jp/jira/images/icons/priorities/medium.svg">Normal</priority>
                        <status id="1" iconUrl="https://pfspipe.ipmu.jp/jira/images/icons/statuses/open.png" description="The issue is open and ready for the assignee to start work on it.">Open</status>
                    <statusCategory id="2" key="new" colorName="blue-gray"/>
                                    <resolution id="-1">Unresolved</resolution>
                                        <assignee username="arnaud.lefur">arnaud.lefur</assignee>
                                    <reporter username="arnaud.lefur">arnaud.lefur</reporter>
                        <labels>
                            <label>engRun12</label>
                    </labels>
                <created>Wed, 26 Jul 2023 11:42:50 +0000</created>
                <updated>Wed, 30 Aug 2023 14:20:07 +0000</updated>
                                                                                <due></due>
                            <votes>0</votes>
                                    <watches>3</watches>
                                                                <comments>
                            <comment id="34172" author="cloomis" created="Wed, 26 Jul 2023 12:20:19 +0000"  >&lt;p&gt;The db name in Hilo is &lt;tt&gt;registry_db&lt;/tt&gt;. We need to be sure that either that db on &lt;tt&gt;shell2-ics&lt;/tt&gt; does not get replicated to Hilo, or that it gets a different name.....&lt;/p&gt;</comment>
                            <comment id="34176" author="price" created="Wed, 26 Jul 2023 17:01:44 +0000"  >&lt;p&gt;My notes from &lt;a href=&quot;https://pfspipe.ipmu.jp/jira/browse/PIPE2D-1058&quot; title=&quot;Avoid/fix registry sqlite deadlocks&quot; class=&quot;issue-link&quot; data-issue-key=&quot;PIPE2D-1058&quot;&gt;&lt;del&gt;PIPE2D-1058&lt;/del&gt;&lt;/a&gt;:&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;
PIPE2D-1058: Avoid/fix registry sqlite deadlocks

We&lt;span class=&quot;code-quote&quot;&gt;&apos;re going to move the registry to postgresql. I&apos;&lt;/span&gt;ve asked CSES &lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt; a &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; database on tiger2-sumire.

Testing on my laptop &lt;span class=&quot;code-keyword&quot;&gt;while&lt;/span&gt; waiting &lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt; CSES:

createuser -h localhost pfs
createdb -h localhost --owner=pfs pfs_gen2

sqlite3 registry.sqlite3 .dump | sed -e &lt;span class=&quot;code-quote&quot;&gt;&apos;s|^PRAGMA.*$||&apos;&lt;/span&gt; -e &lt;span class=&quot;code-quote&quot;&gt;&apos;s|integer primary key autoincrement|serial primary key|g&apos;&lt;/span&gt; -e &lt;span class=&quot;code-quote&quot;&gt;&apos;s|&lt;span class=&quot;code-object&quot;&gt;double&lt;/span&gt;|&lt;span class=&quot;code-object&quot;&gt;double&lt;/span&gt; precision|g&apos;&lt;/span&gt; -e &lt;span class=&quot;code-quote&quot;&gt;&apos;s|^.*sqlite.*$||&apos;&lt;/span&gt; -e &lt;span class=&quot;code-quote&quot;&gt;&apos;s|pfsDesignId &lt;span class=&quot;code-object&quot;&gt;int&lt;/span&gt;|pfsDesignId bigint|g&apos;&lt;/span&gt; | tee registry.sql | psql -h localhost -U pfs pfs_gen2

Here&apos;s how to delete all the tables in a database in postgresql:

DO $$ DECLARE
    r RECORD;
BEGIN
    FOR r IN (SELECT tablename FROM pg_tables WHERE schemaname = current_schema()) LOOP
        EXECUTE &lt;span class=&quot;code-quote&quot;&gt;&apos;DROP TABLE IF EXISTS &apos;&lt;/span&gt; || quote_ident(r.tablename) || &lt;span class=&quot;code-quote&quot;&gt;&apos; CASCADE&apos;&lt;/span&gt;;
    END LOOP;
END $$;

pfs_gen2=&amp;gt; select field, pfsDesignId, count(*) from raw group by field, pfsDesignId order by field, pfsDesignId;

Results look identical (at least &lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt; the first page!) between postresql and sqlite.

Yabe-san created a database at Hilo:

    psql -h 133.40.152.102 -p 5433 -U pfs -d registry_gen2

The password is XXX

Save that password:

price@pfsa-usr01-gb:~ $ cat .pgpass 
*:*:registry_gen2:pfs:XXX

I&lt;span class=&quot;code-quote&quot;&gt;&apos;m working on pfsa-usr01-gb (via &lt;span class=&quot;code-quote&quot;&gt;&quot;ssh pfs&quot;&lt;/span&gt; with the VPN), which I&apos;&lt;/span&gt;m told is at Hilo. Looks like there&apos;s a data repo in /work/drp, and raw data in /data/raw, and the stack is /work/stack.

price@pfsa-usr01-gb:~ $ sqlite3 /work/drp/registry.sqlite3 .dump | sed -e &lt;span class=&quot;code-quote&quot;&gt;&apos;s|^PRAGMA.*$||&apos;&lt;/span&gt; -e &lt;span class=&quot;code-quote&quot;&gt;&apos;s|integer primary key autoincrement|serial primary key|g&apos;&lt;/span&gt; -e &lt;span class=&quot;code-quote&quot;&gt;&apos;s|&lt;span class=&quot;code-object&quot;&gt;double&lt;/span&gt;|&lt;span class=&quot;code-object&quot;&gt;double&lt;/span&gt; precision|g&apos;&lt;/span&gt; -e &lt;span class=&quot;code-quote&quot;&gt;&apos;s|^.*sqlite.*$||&apos;&lt;/span&gt; -e &lt;span class=&quot;code-quote&quot;&gt;&apos;s|pfsDesignId &lt;span class=&quot;code-object&quot;&gt;int&lt;/span&gt;|pfsDesignId bigint|g&apos;&lt;/span&gt; | tee registry.sql | psql -h 133.40.152.102 -p 5433 -U pfs registry_gen2

Well, that worked just fine.

To use it, we need to put a &lt;span class=&quot;code-quote&quot;&gt;&quot;registry.pgsql&quot;&lt;/span&gt; file in the repo:

price@pfsa-usr01-gb:~ $ cat /work/drp/registry.pgsql 
host: &lt;span class=&quot;code-quote&quot;&gt;&quot;133.40.152.102&quot;&lt;/span&gt;
port: 5433
user: &lt;span class=&quot;code-quote&quot;&gt;&quot;pfs&quot;&lt;/span&gt;
database: &lt;span class=&quot;code-quote&quot;&gt;&quot;registry_gen2&quot;&lt;/span&gt;

(Password will be supplied via ~/.pgpass, which is better &lt;span class=&quot;code-keyword&quot;&gt;protected&lt;/span&gt;.)

price@pfsa-usr01-gb:~ $ . /work/stack/loadLSST.bash 
(lsst-scipipe-1172c30) price@pfsa-usr01-gb:~ $ setup pfs_pipe2d
(lsst-scipipe-1172c30) price@pfsa-usr01-gb:~ $ reduceExposure.py /work/drp --calib /work/drp/CALIB-20220630 --rerun price/pipe2d-1058 --id visit=72016 arm=r
root INFO: Loading config overrride file &lt;span class=&quot;code-quote&quot;&gt;&apos;/work/stack_INFRA-290/stack/miniconda3-4.5.12-1172c30/Linux64/obs_pfs/w.2022.17/config/reduceExposure.py&apos;&lt;/span&gt;
CameraMapper INFO: Loading exposure registry from /work/drp/registry.pgsql
CameraMapper INFO: Loading calib registry from /work/drp/CALIB-20220630/calibRegistry.sqlite3
CameraMapper INFO: Loading calib registry from /work/drp/CALIB-20220630/calibRegistry.sqlite3
root WARN: No data found &lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt; dataId=OrderedDict([(&lt;span class=&quot;code-quote&quot;&gt;&apos;visit&apos;&lt;/span&gt;, 72016), (&lt;span class=&quot;code-quote&quot;&gt;&apos;arm&apos;&lt;/span&gt;, &lt;span class=&quot;code-quote&quot;&gt;&apos;r&apos;&lt;/span&gt;)])
root INFO: Running: /work/stack_INFRA-290/stack/miniconda3-4.5.12-1172c30/Linux64/drp_stella/w.2022.17/bin/reduceExposure.py /work/drp --calib /work/drp/CALIB-20220630 --rerun price/pipe2d-1058 --id visit=72016 arm=r
root WARN: Not running the task because there is no data to process; you may preview data using &lt;span class=&quot;code-quote&quot;&gt;&quot;--show data&quot;&lt;/span&gt;

Well, that worked, sort of. It went to the correct registry, but there&apos;s no visit=72016 in there. I guess that means we can test the ingest!

(lsst-scipipe-1172c30) price@pfsa-usr01-gb:~ $ ingestPfsImages.py /work/drp &lt;span class=&quot;code-quote&quot;&gt;&quot;/data/raw/2022-02-22/sps/PFSA07*.fits&quot;&lt;/span&gt; --mode=copy
CameraMapper INFO: Loading exposure registry from /work/drp/registry.pgsql
CameraMapper INFO: Loading calib registry from /work/drp/CALIB/calibRegistry.sqlite3
Traceback (most recent call last):
  File &lt;span class=&quot;code-quote&quot;&gt;&quot;/work/stack_INFRA-290/stack/miniconda3-4.5.12-1172c30/Linux64/obs_pfs/w.2022.17/bin/ingestPfsImages.py&quot;&lt;/span&gt;, line 3, in &amp;lt;module&amp;gt;
    PfsIngestTask.parseAndRun()
  File &lt;span class=&quot;code-quote&quot;&gt;&quot;/work/stack_INFRA-290/stack/miniconda3-4.5.12-1172c30/Linux64/pipe_tasks/18.1.0/python/lsst/pipe/tasks/ingest.py&quot;&lt;/span&gt;, line 416, in parseAndRun
    task.run(args)
  File &lt;span class=&quot;code-quote&quot;&gt;&quot;/work/stack_INFRA-290/stack/miniconda3-4.5.12-1172c30/Linux64/pipe_tasks/18.1.0/python/lsst/pipe/tasks/ingest.py&quot;&lt;/span&gt;, line 542, in run
    context = self.register.openRegistry(root, create=args.create, dryrun=args.dryrun)
  File &lt;span class=&quot;code-quote&quot;&gt;&quot;/work/stack_INFRA-290/stack/miniconda3-4.5.12-1172c30/Linux64/pipe_tasks/18.1.0/python/lsst/pipe/tasks/ingest.py&quot;&lt;/span&gt;, line 298, in openRegistry
    context = RegistryContext(registryName, self.createTable, create, self.config.permissions)
  File &lt;span class=&quot;code-quote&quot;&gt;&quot;/work/stack_INFRA-290/stack/miniconda3-4.5.12-1172c30/Linux64/obs_pfs/w.2022.17/python/lsst/obs/pfs/ingest.py&quot;&lt;/span&gt;, line 53, in __init__
    os.chmod(registryName, permissions)
PermissionError: [Errno 1] Operation not permitted: &lt;span class=&quot;code-quote&quot;&gt;&apos;/work/drp/registry.sqlite3&apos;&lt;/span&gt;

So we need to fix the ingest. Basing off w.2022.17 to be consistent with what&apos;s in use at Hilo.

(lsst-scipipe-1172c30) price@pfsa-usr01-gb:~ $ ingestPfsImages.py /work/drp &lt;span class=&quot;code-quote&quot;&gt;&quot;/data/raw/2022-02-22/sps/PFSA07*.fits&quot;&lt;/span&gt; --mode=copy --pfsConfigDir /work/drp/pfsDesign -c clobber=True

Success! But the visits are not in the psql registry... and it&apos;s ended up in the sqlite registry!
Oh! There&apos;s a separate script &lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt; ingesting into a psql registry. It has a different RegisterTask with slightly different SQL commands &lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt; creating the tables, and such.

(lsst-scipipe-1172c30) price@pfsa-usr01-gb:~/pfs/obs_pfs[tickets/PIPE2D-1058] $ ingestPfsImagesPgsql.py /work/drp &lt;span class=&quot;code-quote&quot;&gt;&quot;/data/raw/2022-02-22/sps/PFSA07*.fits&quot;&lt;/span&gt; --mode=copy --pfsConfigDir /work/drp/pfsDesign -c clobber=True
CameraMapper INFO: Loading exposure registry from /work/drp/registry.pgsql
CameraMapper INFO: Loading calib registry from /work/drp/CALIB/calibRegistry.sqlite3
ingestPfs INFO: /data/raw/2022-02-22/sps/PFSA07206314.fits --&amp;lt;copy&amp;gt;--&amp;gt; /work/drp/2022-02-22/PFSA072063m1.fits

  File &lt;span class=&quot;code-quote&quot;&gt;&quot;/home/price/pfs/obs_pfs/bin/ingestPfsImagesPgsql.py&quot;&lt;/span&gt;, line 3, in &amp;lt;module&amp;gt;
    PfsPgsqlIngestTask.parseAndRun()
  File &lt;span class=&quot;code-quote&quot;&gt;&quot;/work/stack_INFRA-290/stack/miniconda3-4.5.12-1172c30/Linux64/pipe_tasks/18.1.0/python/lsst/pipe/tasks/ingest.py&quot;&lt;/span&gt;, line 416, in parseAndRun
    task.run(args)
  File &lt;span class=&quot;code-quote&quot;&gt;&quot;/work/stack_INFRA-290/stack/miniconda3-4.5.12-1172c30/Linux64/pipe_tasks/18.1.0/python/lsst/pipe/tasks/ingest.py&quot;&lt;/span&gt;, line 553, in run
    self.register.addRow(registry, info, dryrun=args.dryrun, create=args.create)
  File &lt;span class=&quot;code-quote&quot;&gt;&quot;/work/stack_INFRA-290/stack/miniconda3-4.5.12-1172c30/Linux64/pipe_tasks/18.1.0/python/lsst/pipe/tasks/ingest.py&quot;&lt;/span&gt;, line 368, in addRow
    conn.cursor().execute(sql, values)
psycopg2.IntegrityError: duplicate key value violates unique constraint &lt;span class=&quot;code-quote&quot;&gt;&quot;raw_pkey&quot;&lt;/span&gt;
DETAIL:  Key (id)=(2) already exists.

We need to reset the auto increment start point.

registry_gen2=# select pg_get_serial_sequence(&lt;span class=&quot;code-quote&quot;&gt;&apos;raw&apos;&lt;/span&gt;, &lt;span class=&quot;code-quote&quot;&gt;&apos;id&apos;&lt;/span&gt;);
 pg_get_serial_sequence 
------------------------
 &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt;.raw_id_seq
(1 row)

registry_gen2=# select max(id) from raw;
  max  
-------
 94666
(1 row)

registry_gen2=# ALTER SEQUENCE raw_id_seq RESTART WITH 94667;
ALTER SEQUENCE

(lsst-scipipe-1172c30) price@pfsa-usr01-gb:~/pfs/obs_pfs[tickets/PIPE2D-1058] $ ingestPfsImagesPgsql.py /work/drp &lt;span class=&quot;code-quote&quot;&gt;&quot;/data/raw/2022-02-22/sps/PFSA07*.fits&quot;&lt;/span&gt; --mode=copy --pfsConfigDir /work/drp/pfsDesign -c clobber=True
(lsst-scipipe-1172c30) price@pfsa-usr01-gb:~/pfs/obs_pfs[tickets/PIPE2D-1058] $ reduceExposure.py /work/drp --calib /work/drp/CALIB-20220630 --rerun price/pipe2d-1058 --id visit=72016 arm=r -c isr.doFlat=False 

That works!
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10003">
                    <name>Relates</name>
                                                                <inwardlinks description="relates to">
                                        <issuelink>
            <issuekey id="22867">PIPE2D-1058</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10500" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                            <customfield id="customfield_10010" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>0|zzsz13:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                        <customfield id="customfield_10005" key="com.pyxis.greenhopper.jira:gh-sprint">
                        <customfieldname>Sprint</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue id="166">Eng12July</customfieldvalue>
    <customfieldvalue id="167">Eng13Oct</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10002" key="com.atlassian.jira.plugin.system.customfieldtypes:float">
                        <customfieldname>Story Points</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                        </customfields>
    </item>
</channel>
</rss>