Skip to content

Instantly share code, notes, and snippets.

@bigbes
Created December 26, 2017 17:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bigbes/b0461a791a264487d2a9827ef7e3eac9 to your computer and use it in GitHub Desktop.
Save bigbes/b0461a791a264487d2a9827ef7e3eac9 to your computer and use it in GitHub Desktop.
diff --git a/shard.lua b/shard.lua
index f9ee05e..0c83af7 100644
--- a/shard.lua
+++ b/shard.lua
@@ -268,14 +268,10 @@ local function shard_status()
offline = {},
maintenance = maintenance
}
- for j = 1, #shards do
- local srd = shards[j]
- for i = 1, redundancy do
- if not srd[i] then
- break
- end
- local s = { uri = srd[i].uri, id = srd[i].id }
- if srd[i].conn and srd[i].conn:is_connected() then
+ for _, shard_set in ipairs(shards) do
+ for _, shard in ipairs(shard_set) do
+ local s = { uri = shard.uri, id = shard.id }
+ if shard.conn and shard.conn:is_connected() then
table.insert(result.online, s)
else
table.insert(result.offline, s)
@@ -722,8 +718,8 @@ local function append_shard(servers, is_replica, start_waiter)
return false, string.format('"%s" are offline', table.concat(uris, ', '))
end
- local password = pool.servers['1'].list[1].password
- local login = pool.servers['1'].list[1].login
+ local login = configuration.login
+ local password = configuration.password
-- check new nodes' availability
for _, srv in ipairs(non_arbiters) do
@@ -746,7 +742,6 @@ local function append_shard(servers, is_replica, start_waiter)
box.space._shard:replace{RSD_STATE, 1}
end
-- add new "virtual" shard and append server
- shards_n = shards_n + 1
shards[shards_n] = {}
-- get updated shard list from a new shard
@@ -807,14 +802,15 @@ local function append_shard(servers, is_replica, start_waiter)
-- disable new shard by default
--server.ignore = true
-- append server to connection pool
- pool:connect(shards_n * redundancy - id + 1, server)
+ pool:connect((shards_n + 1) * redundancy - id + 1, server)
local zone = pool.servers[server.zone]
zone.list[zone.n].zone_name = server.zone
if not server.arbiter then
- table.insert(shards[shards_n], zone.list[zone.n])
+ table.insert(shards[shards_n + 1], zone.list[zone.n])
end
end
+ shards_n = shards_n + 1
if not is_replica then
box.space._shard:replace{RSD_STATE, 2}
elseif start_waiter then
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment