From: gmc Date: Tue, 21 Sep 2010 04:46:52 +0000 (+0000) Subject: add ingest.metarecord_mapping.skip_on_update internal flag X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=a7887f55529dffac6e34c8eb737ab7573633117d;p=evergreen%2Fbjwebb.git add ingest.metarecord_mapping.skip_on_update internal flag Enabling this allows bibliographic reingests (for new/changed indexes or after data changes that don't affect the fingerprint) to be run in parallel without lock contention on metarecord.metarecord* operations. Signed-off-by: Galen Charlton git-svn-id: svn://svn.open-ils.org/ILS/trunk@17862 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index b5ed5758e..22c636262 100644 --- a/Open-ILS/src/sql/Pg/002.schema.config.sql +++ b/Open-ILS/src/sql/Pg/002.schema.config.sql @@ -52,6 +52,7 @@ CREATE TABLE config.internal_flag ( enabled BOOL NOT NULL DEFAULT FALSE ); INSERT INTO config.internal_flag (name) VALUES ('ingest.metarecord_mapping.skip_on_insert'); +INSERT INTO config.internal_flag (name) VALUES ('ingest.metarecord_mapping.skip_on_update'); INSERT INTO config.internal_flag (name) VALUES ('ingest.reingest.force_on_same_marc'); INSERT INTO config.internal_flag (name) VALUES ('ingest.disable_located_uri'); INSERT INTO config.internal_flag (name) VALUES ('ingest.disable_metabib_full_rec'); @@ -68,7 +69,7 @@ CREATE TABLE config.upgrade_log ( install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW() ); -INSERT INTO config.upgrade_log (version) VALUES ('0409'); -- senator +INSERT INTO config.upgrade_log (version) VALUES ('0410'); -- gmc CREATE TABLE config.bib_source ( id SERIAL PRIMARY KEY, diff --git a/Open-ILS/src/sql/Pg/030.schema.metabib.sql b/Open-ILS/src/sql/Pg/030.schema.metabib.sql index c9e8316ef..7be8ff3d6 100644 --- a/Open-ILS/src/sql/Pg/030.schema.metabib.sql +++ b/Open-ILS/src/sql/Pg/030.schema.metabib.sql @@ -964,7 +964,10 @@ BEGIN PERFORM metabib.remap_metarecord_for_bib( NEW.id, NEW.fingerprint ); END IF; ELSE -- we're doing an update, and we're not deleted, remap - PERFORM metabib.remap_metarecord_for_bib( NEW.id, NEW.fingerprint ); + PERFORM * FROM config.internal_flag WHERE name = 'ingest.metarecord_mapping.skip_on_update' AND enabled; + IF NOT FOUND THEN + PERFORM metabib.remap_metarecord_for_bib( NEW.id, NEW.fingerprint ); + END IF; END IF; RETURN NEW; diff --git a/Open-ILS/src/sql/Pg/upgrade/0410.schema.allow_parallel_reingest.sql b/Open-ILS/src/sql/Pg/upgrade/0410.schema.allow_parallel_reingest.sql new file mode 100644 index 000000000..87f48baff --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/0410.schema.allow_parallel_reingest.sql @@ -0,0 +1,74 @@ +BEGIN; + +INSERT INTO config.upgrade_log (version) VALUES ('0410'); -- gmc + +INSERT INTO config.internal_flag (name) VALUES ('ingest.metarecord_mapping.skip_on_update'); + +-- AFTER UPDATE OR INSERT trigger for biblio.record_entry +CREATE OR REPLACE FUNCTION biblio.indexing_ingest_or_delete () RETURNS TRIGGER AS $func$ +BEGIN + + IF NEW.deleted IS TRUE THEN -- If this bib is deleted + DELETE FROM metabib.metarecord_source_map WHERE source = NEW.id; -- Rid ourselves of the search-estimate-killing linkage + DELETE FROM authority.bib_linking WHERE bib = NEW.id; -- Avoid updating fields in bibs that are no longer visible + RETURN NEW; -- and we're done + END IF; + + IF TG_OP = 'UPDATE' THEN -- re-ingest? + PERFORM * FROM config.internal_flag WHERE name = 'ingest.reingest.force_on_same_marc' AND enabled; + + IF NOT FOUND AND OLD.marc = NEW.marc THEN -- don't do anything if the MARC didn't change + RETURN NEW; + END IF; + END IF; + + -- Record authority linking + PERFORM * FROM config.internal_flag WHERE name = 'ingest.disable_authority_linking' AND enabled; + IF NOT FOUND THEN + PERFORM biblio.map_authority_linking( NEW.id, NEW.marc ); + END IF; + + -- Flatten and insert the mfr data + PERFORM * FROM config.internal_flag WHERE name = 'ingest.disable_metabib_full_rec' AND enabled; + IF NOT FOUND THEN + PERFORM metabib.reingest_metabib_full_rec(NEW.id); + PERFORM * FROM config.internal_flag WHERE name = 'ingest.disable_metabib_rec_descriptor' AND enabled; + IF NOT FOUND THEN + PERFORM metabib.reingest_metabib_rec_descriptor(NEW.id); + END IF; + END IF; + + -- Gather and insert the field entry data + PERFORM metabib.reingest_metabib_field_entries(NEW.id); + + -- Located URI magic + IF TG_OP = 'INSERT' THEN + PERFORM * FROM config.internal_flag WHERE name = 'ingest.disable_located_uri' AND enabled; + IF NOT FOUND THEN + PERFORM biblio.extract_located_uris( NEW.id, NEW.marc, NEW.editor ); + END IF; + ELSE + PERFORM * FROM config.internal_flag WHERE name = 'ingest.disable_located_uri' AND enabled; + IF NOT FOUND THEN + PERFORM biblio.extract_located_uris( NEW.id, NEW.marc, NEW.editor ); + END IF; + END IF; + + -- (re)map metarecord-bib linking + IF TG_OP = 'INSERT' THEN -- if not deleted and performing an insert, check for the flag + PERFORM * FROM config.internal_flag WHERE name = 'ingest.metarecord_mapping.skip_on_insert' AND enabled; + IF NOT FOUND THEN + PERFORM metabib.remap_metarecord_for_bib( NEW.id, NEW.fingerprint ); + END IF; + ELSE -- we're doing an update, and we're not deleted, remap + PERFORM * FROM config.internal_flag WHERE name = 'ingest.metarecord_mapping.skip_on_update' AND enabled; + IF NOT FOUND THEN + PERFORM metabib.remap_metarecord_for_bib( NEW.id, NEW.fingerprint ); + END IF; + END IF; + + RETURN NEW; +END; +$func$ LANGUAGE PLPGSQL; + +COMMIT;