提交 95a55de4 authored 作者: Andrei Tokar's avatar Andrei Tokar

cope with unfinish map rename due to database closure

上级 c0dcb0df
......@@ -2518,11 +2518,14 @@ public class MVStore {
int id = map.getId();
String oldName = getMapName(id);
if (oldName != null && !oldName.equals(newName)) {
String idHexStr = Integer.toHexString(id);
// we need to cope whith the case of previously unfinished rename
String existingIdHexStr = meta.get("name." + newName);
DataUtils.checkArgument(
!meta.containsKey("name." + newName),
existingIdHexStr == null || existingIdHexStr.equals(idHexStr),
"A map named {0} already exists", newName);
// at first create a new name as an "alias"
meta.put("name." + newName, Integer.toHexString(id));
meta.put("name." + newName, idHexStr);
// switch roles of a new and old names - old one is an alias now
meta.put(MVMap.getMapKey(id), map.asString(newName));
// get rid of the old name completely
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论