projects
/
idzebra-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix the way we delete the shadow files after a "succesful" commit
[idzebra-moved-to-github.git]
/
index
/
zebraapi.c
diff --git
a/index/zebraapi.c
b/index/zebraapi.c
index
3296732
..
0c94394
100644
(file)
--- a/
index/zebraapi.c
+++ b/
index/zebraapi.c
@@
-1,4
+1,4
@@
-/* $Id: zebraapi.c,v 1.206 2006-03-26 14:17:01 adam Exp $
+/* $Id: zebraapi.c,v 1.211 2006-04-04 00:00:18 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
Copyright (C) 1995-2005
Index Data ApS
@@
-297,7
+297,7
@@
struct zebra_register *zebra_register_open(ZebraService zs, const char *name,
yaz_log (YLOG_DEBUG, "zebra_register_open rw=%d useshadow=%d p=%p n=%s rp=%s",
rw, useshadow, reg, name, reg_path ? reg_path : "(none)");
yaz_log (YLOG_DEBUG, "zebra_register_open rw=%d useshadow=%d p=%p n=%s rp=%s",
rw, useshadow, reg, name, reg_path ? reg_path : "(none)");
- reg->dh = data1_createx (DATA1_FLAG_XML);
+ reg->dh = data1_create();
if (!reg->dh)
{
xfree(reg->name);
if (!reg->dh)
{
xfree(reg->name);
@@
-332,7
+332,9
@@
struct zebra_register *zebra_register_open(ZebraService zs, const char *name,
data1_set_tabroot (reg->dh, reg_path);
reg->recTypes = recTypes_init (zs->record_classes, reg->dh);
data1_set_tabroot (reg->dh, reg_path);
reg->recTypes = recTypes_init (zs->record_classes, reg->dh);
- if ((reg->zebra_maps = zebra_maps_open (res, reg_path)) == 0)
+ reg->zebra_maps =
+ zebra_maps_open(res, reg_path, profilePath);
+ if (!reg->zebra_maps)
{
recTypes_destroy(reg->recTypes);
bfs_destroy(reg->bfs);
{
recTypes_destroy(reg->recTypes);
bfs_destroy(reg->bfs);
@@
-341,7
+343,6
@@
struct zebra_register *zebra_register_open(ZebraService zs, const char *name,
xfree(reg);
return 0;
}
xfree(reg);
return 0;
}
-
reg->rank_classes = NULL;
reg->key_buf = 0;
reg->rank_classes = NULL;
reg->key_buf = 0;
@@
-376,6
+377,16
@@
struct zebra_register *zebra_register_open(ZebraService zs, const char *name,
if (!strcmp (recordCompression, "bzip2"))
record_compression = REC_COMPRESS_BZIP2;
if (!strcmp (recordCompression, "bzip2"))
record_compression = REC_COMPRESS_BZIP2;
+ if (1)
+ {
+ const char *index_fname = res_get_def(res, "index", "default.idx");
+ if (index_fname && *index_fname)
+ {
+ if (zebra_maps_read_file(reg->zebra_maps, index_fname) != ZEBRA_OK)
+ ret = ZEBRA_FAIL;
+ }
+ }
+
if (!(reg->records = rec_open (reg->bfs, rw, record_compression)))
{
yaz_log (YLOG_WARN, "rec_open failed");
if (!(reg->records = rec_open (reg->bfs, rw, record_compression)))
{
yaz_log (YLOG_WARN, "rec_open failed");
@@
-448,7
+459,7
@@
struct zebra_register *zebra_register_open(ZebraService zs, const char *name,
ret = ZEBRA_FAIL;
}
}
ret = ZEBRA_FAIL;
}
}
- if (reg->records)
+ if (ret == ZEBRA_OK)
{
reg->zei = zebraExplain_open(reg->records, reg->dh,
res, rw, reg,
{
reg->zei = zebraExplain_open(reg->records, reg->dh,
res, rw, reg,
@@
-743,8
+754,6
@@
static void zebra_select_register (ZebraHandle zh, const char *new_reg)
{
if (res_get_int(zh->res, "staticrank", &zh->m_staticrank) == ZEBRA_OK)
yaz_log(YLOG_LOG, "static rank set and is %d", zh->m_staticrank);
{
if (res_get_int(zh->res, "staticrank", &zh->m_staticrank) == ZEBRA_OK)
yaz_log(YLOG_LOG, "static rank set and is %d", zh->m_staticrank);
- else
- yaz_log(YLOG_LOG, "static rank unset");
}
}
}
}
@@
-1352,7
+1361,8
@@
ZEBRA_RES zebra_admin_exchange_record(ZebraHandle zh,
{
if (action == 1) /* fail if insert */
{
{
if (action == 1) /* fail if insert */
{
- zebra_end_trans(zh);
+ if (zebra_end_trans(zh) != ZEBRA_OK)
+ yaz_log(YLOG_WARN, "zebra_end_trans failed");
zebra_setError(zh, YAZ_BIB1_ES_IMMEDIATE_EXECUTION_FAILED,
"Cannot insert record: already exist");
return ZEBRA_FAIL;
zebra_setError(zh, YAZ_BIB1_ES_IMMEDIATE_EXECUTION_FAILED,
"Cannot insert record: already exist");
return ZEBRA_FAIL;
@@
-1364,7
+1374,8
@@
ZEBRA_RES zebra_admin_exchange_record(ZebraHandle zh,
{
if (action == 2 || action == 3) /* fail if delete or update */
{
{
if (action == 2 || action == 3) /* fail if delete or update */
{
- zebra_end_trans(zh);
+ if (zebra_end_trans(zh) != ZEBRA_OK)
+ yaz_log(YLOG_WARN, "zebra_end_trans failed");
zebra_setError(zh, YAZ_BIB1_ES_IMMEDIATE_EXECUTION_FAILED,
"Cannot delete/update record: does not exist");
return ZEBRA_FAIL;
zebra_setError(zh, YAZ_BIB1_ES_IMMEDIATE_EXECUTION_FAILED,
"Cannot delete/update record: does not exist");
return ZEBRA_FAIL;
@@
-1395,7
+1406,11
@@
ZEBRA_RES zebra_admin_exchange_record(ZebraHandle zh,
{
dict_delete_ord(zh->reg->matchDict, db_ord, recid_z);
}
{
dict_delete_ord(zh->reg->matchDict, db_ord, recid_z);
}
- zebra_end_trans(zh);
+ if (zebra_end_trans(zh) != ZEBRA_OK)
+ {
+ yaz_log(YLOG_WARN, "zebra_end_trans failed");
+ res = ZEBRA_FAIL;
+ }
return res;
}
return res;
}
@@
-1455,7
+1470,11
@@
ZEBRA_RES zebra_drop_database(ZebraHandle zh, const char *db)
"drop database only supported for isam:b");
ret = ZEBRA_FAIL;
}
"drop database only supported for isam:b");
ret = ZEBRA_FAIL;
}
- zebra_end_trans (zh);
+ if (zebra_end_trans (zh) != ZEBRA_OK)
+ {
+ yaz_log(YLOG_WARN, "zebra_end_trans failed");
+ ret = ZEBRA_FAIL;
+ }
return ret;
}
return ret;
}
@@
-1474,7
+1493,10
@@
ZEBRA_RES zebra_create_database (ZebraHandle zh, const char *db)
if (zebraExplain_newDatabase (zh->reg->zei, db, 0
/* explainDatabase */))
{
if (zebraExplain_newDatabase (zh->reg->zei, db, 0
/* explainDatabase */))
{
- zebra_end_trans (zh);
+ if (zebra_end_trans (zh) != ZEBRA_OK)
+ {
+ yaz_log(YLOG_WARN, "zebra_end_trans failed");
+ }
zebra_setError(zh, YAZ_BIB1_ES_IMMEDIATE_EXECUTION_FAILED, db);
return ZEBRA_FAIL;
}
zebra_setError(zh, YAZ_BIB1_ES_IMMEDIATE_EXECUTION_FAILED, db);
return ZEBRA_FAIL;
}
@@
-1964,19
+1986,24
@@
static ZEBRA_RES zebra_commit_ex(ZebraHandle zh, int clean_only)
sync ();
#endif
}
sync ();
#endif
}
- yaz_log (YLOG_DEBUG, "commit clean");
- bf_commitClean (bfs, rval);
seqno++;
zebra_set_state (zh, 'o', seqno);
seqno++;
zebra_set_state (zh, 'o', seqno);
+
+ zebra_unlock (zh->lock_shadow);
+ zebra_unlock (zh->lock_normal);
+
+ zebra_lock_w(zh->lock_shadow);
+ bf_commitClean (bfs, rval);
+ zebra_unlock (zh->lock_normal);
}
else
{
}
else
{
+ zebra_unlock(zh->lock_shadow);
+ zebra_unlock(zh->lock_normal);
yaz_log (log_level, "nothing to commit");
}
bfs_destroy (bfs);
yaz_log (log_level, "nothing to commit");
}
bfs_destroy (bfs);
- zebra_unlock (zh->lock_shadow);
- zebra_unlock (zh->lock_normal);
return ZEBRA_OK;
}
return ZEBRA_OK;
}
@@
-2186,7
+2213,11
@@
ZEBRA_RES zebra_insert_record (ZebraHandle zh,
match, fname,
0,
0); /* allow_update */
match, fname,
0,
0); /* allow_update */
- zebra_end_trans(zh);
+ if (zebra_end_trans(zh) != ZEBRA_OK)
+ {
+ yaz_log(YLOG_WARN, "zebra_end_trans failed");
+ res = ZEBRA_FAIL;
+ }
return res;
}
return res;
}
@@
-2217,7
+2248,11
@@
ZEBRA_RES zebra_update_record (ZebraHandle zh,
match, fname,
force_update,
1); /* allow_update */
match, fname,
force_update,
1); /* allow_update */
- zebra_end_trans(zh);
+ if (zebra_end_trans(zh) != ZEBRA_OK)
+ {
+ yaz_log(YLOG_WARN, "zebra_end_trans failed");
+ res = ZEBRA_FAIL;
+ }
return res;
}
return res;
}
@@
-2246,7
+2281,11
@@
ZEBRA_RES zebra_delete_record (ZebraHandle zh,
match,fname,
force_update,
1); /* allow_update */
match,fname,
force_update,
1); /* allow_update */
- zebra_end_trans(zh);
+ if (zebra_end_trans(zh) != ZEBRA_OK)
+ {
+ yaz_log(YLOG_WARN, "zebra_end_trans failed");
+ res = ZEBRA_FAIL;
+ }
return res;
}
return res;
}