<p><em>Note: I’m temporarily making this a page because it seems Hugo (currently 0.27.1) cannot use a custom slug for a post when there is a permalink defined in <code>config.toml</code></em></p>
<p>Rough notes for importing the CGIAR Library content. It was decided that this content would go to a new top-level community called <em>CGIAR System Organization</em>.</p>
<p>Things that need to happen before the migration:</p>
<ulclass="task-list">
<li><label><inputtype="checkbox"checkeddisabledclass="task-list-item"> Create top-level community on CGSpace to hold the CGIAR Library content: <sup>10568</sup>⁄<sub>83389</sub>
<ulclass="task-list">
<li><label><inputtype="checkbox"checkeddisabledclass="task-list-item"> Update nginx redirects in ansible templates</label></li>
<li><label><inputtype="checkbox"checkeddisabledclass="task-list-item"> Update handle in DSpace XMLUI config</label></li>
<li><label><inputtype="checkbox"checkeddisabledclass="task-list-item"> Merge <ahref="https://github.com/ilri/DSpace/pull/339">#339</a> to <code>5_x-prod</code> branch and rebuild DSpace</label></li>
<li><label><inputtype="checkbox"checkeddisabledclass="task-list-item"> Increase <code>max_connections</code> in <code>/etc/postgresql/9.5/main/postgresql.conf</code> by ~10
<ul>
<li><code>SELECT * FROM pg_stat_activity;</code> seems to show ~6 extra connections used by the command line tools during import</li>
</ul></label></li>
<li><label><inputtype="checkbox"checkeddisabledclass="task-list-item"> Temporarily disable nightly <code>index-discovery</code> cron job because the import process will be taking place during some of this time and I don’t want them to be competing to update the Solr index</label></li>
<li><label><inputtype="checkbox"checkeddisabledclass="task-list-item"> Import communities and collections, paying attention to options to skip missing parents and ignore handles:</label></li>
<p>This submits AIP hierarchies recursively (-r) and suppresses errors when an item’s parent collection hasn’t been created yet—for example, if the item is mapped. The large historic archive (<sup>10947</sup>⁄<sub>1</sub>) is created in several steps because it requires a lot of memory and often crashes.</p>
<pre><code>dspace=# select handle from item, handle where handle.resource_id = item.item_id AND item.item_id in (select item_id from metadatavalue where metadata_field_id=11 and date(text_value) > '2017-05-01T00:00:00Z');
<li><label><inputtype="checkbox"disabledclass="task-list-item"> Shut down Tomcat and run <code>update-sequences.sql</code> as the system’s <code>postgres</code> user</label></li>
<li><label><inputtype="checkbox"checkeddisabledclass="task-list-item"> Adjust CGSpace’s <code>handle-server/config.dct</code> to add the new prefix alongside our existing 10568, ie:</label></li>
</ul>
<pre><code>"server_admins" = (
"300:0.NA/10568"
"300:0.NA/10947"
)
"replication_admins" = (
"300:0.NA/10568"
"300:0.NA/10947"
)
"backup_admins" = (
"300:0.NA/10568"
"300:0.NA/10947"
)
</code></pre>
<ulclass="task-list">
<li><label><inputtype="checkbox"checkeddisabledclass="task-list-item"> Regenerate Handle server’s <code>sitebndl.zip</code> on CGIAR Library server:</label></li>
</ul>
<pre><code>$ sudo su -
# cp -a /usr/local/dspace/handle-server /usr/local/dspace/handle-server-2017-09-19.bak
<li>The handle setup script will ask for IP address, contact person, etc</li>
<li>Use CGSpace’s IP address, but give some contact person from the system organization</li>
<li>Copy the resulting <code>sitebndl.zip</code> somewhere so we can send it to Handle.net</li>
<li>Now I’m wondering how we’ll do this when we move servers in the future, because the <code>make-handle-config</code> basically assumes you only have one handle</li>
<li>Also, there is <code>dspace make-handle-config</code> and <code>bin/make-handle-config</code> and both behave differently (the first is interactive, the second reads your <code>dspace.cfg</code> and generates your handle config and <code>sitebndl.zip</code> accordingly)</li>
<li><p>I’m really not sure on the proper order of events actually</p></li>
<li><label><inputtype="checkbox"disabledclass="task-list-item"> Switch to Let’s Encrypt HTTPS certificates (after DNS is updated and server isn’t busy):</label></li>
<h3id="foreign-key-error-in-dspace-cleanup">Foreign Key Error in <code>dspace cleanup</code></h3>
<p>The cleanup script is sometimes used during import processes to clean the database and assetstore after failed AIP imports. If you see the following error with <code>dspace cleanup -v</code>:</p>
<pre><code>Error: ERROR: update or delete on table "bitstream" violates foreign key constraint "bundle_primary_bitstream_id_fkey" on table "bundle"
Detail: Key (bitstream_id)=(119841) is still referenced from table "bundle".
</code></pre>
<p>The solution is to set the <code>primary_bitstream_id</code> to NULL in PostgreSQL:</p>
<pre><code>dspace=# update bundle set primary_bitstream_id=NULL where primary_bitstream_id in (119841);
</code></pre>
<h3id="psqlexception-during-aip-ingest">PSQLException During AIP Ingest</h3>
<p>After a few rounds of ingesting—possibly with failures—you might end up with inconsistent IDs in the database. In this case, during AIP ingest of a single collection in submit mode (-s):</p>
<pre><code>org.dspace.content.packager.PackageValidationException: Exception while ingesting 10947-2527/10947-2527.zip, Reason: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "handle_pkey"
Detail: Key (handle_id)=(86227) already exists.
</code></pre>
<p>The normal solution is to run the <code>update-sequences.sql</code> script (with Tomcat shut down) but it doesn’t seem to work in this case. Finding the maximum <code>handle_id</code> and manually updating the sequence seems to work:</p>
<pre><code>dspace=# select * from handle where handle_id=(select max(handle_id) from handle);