Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit bdc9d87

Browse files
committed
Printing sql if cmd failed in broadcast.
1 parent 03fb53b commit bdc9d87

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

bin/shardman_init.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ for worker_datadir in "${worker_datadirs[@]}"; do
3030
cat postgresql.conf.worker >> ${worker_datadir}/postgresql.conf
3131
done
3232

33+
for datadir in $lord_datadir "${worker_datadirs[@]}"; do
34+
cat pg_hba.conf > ${datadir}/pg_hba.conf
35+
done
36+
3337
start_nodes
3438
for port in $lord_port "${worker_ports[@]}"; do
3539
createdb -p $port `whoami`

bin/shardman_start.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ cd "${script_dir}/.."
1010
restart_nodes # make sure nodes run
1111
# first workers, then lord
1212
for port in "${worker_ports[@]}" $lord_port; do
13-
psql -p $port -c "drop extension if exists pg_shardman cascade;"
13+
psql -p $port -c "set synchronous_commit to local; drop extension if exists pg_shardman cascade;"
1414
done
1515

1616
make clean
1717
make install
1818

1919
restart_nodes
2020
for port in $lord_port "${worker_ports[@]}"; do
21-
psql -p $port -c "create extension pg_shardman cascade;"
21+
psql -p $port -c "set synchronous_commit to local; create extension pg_shardman cascade;"
2222
done
2323

2424
run_demo

pg_shardman.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ wait_command_completion(PGconn* conn)
113113
Datum
114114
broadcast(PG_FUNCTION_ARGS)
115115
{
116-
char* sql = text_to_cstring(PG_GETARG_TEXT_PP(0));
116+
char *sql_full = text_to_cstring(PG_GETARG_TEXT_PP(0));
117+
char* sql = pstrdup(sql_full);
117118
bool ignore_errors = PG_GETARG_BOOL(1);
118119
bool two_phase = PG_GETARG_BOOL(2);
119120
bool sync_commit_on = PG_GETARG_BOOL(3);
@@ -196,6 +197,7 @@ broadcast(PG_FUNCTION_ARGS)
196197
}
197198
if (!sync_commit_on)
198199
{
200+
/* mem freed with context */
199201
if (two_phase)
200202
{
201203
sql = psprintf("SET SESSION synchronous_commit TO local; BEGIN; %s; PREPARE TRANSACTION 'shardlord';", sql);
@@ -220,8 +222,6 @@ broadcast(PG_FUNCTION_ARGS)
220222
node_id, PQerrorMessage(conn[n_cmds-1]));
221223
goto cleanup;
222224
}
223-
if (!sync_commit_on)
224-
pfree(sql);
225225

226226
sql = sep + 1;
227227
}
@@ -249,10 +249,10 @@ broadcast(PG_FUNCTION_ARGS)
249249
{
250250
if (ignore_errors)
251251
{
252-
errmsg = psprintf("%s%d:Failed to received response for '%s': %s", errmsg ? errmsg : "", node_id, sql, PQerrorMessage(conn[i]));
252+
errmsg = psprintf("%s%d:Failed to received response for '%s': %s", errmsg ? errmsg : "", node_id, sql_full, PQerrorMessage(conn[i]));
253253
continue;
254254
}
255-
errmsg = psprintf("Failed to receive response for query %s from node %d: %s", sql, node_id, PQerrorMessage(conn[i]));
255+
errmsg = psprintf("Failed to receive response for query %s from node %d: %s", sql_full, node_id, PQerrorMessage(conn[i]));
256256
goto cleanup;
257257
}
258258

@@ -262,11 +262,11 @@ broadcast(PG_FUNCTION_ARGS)
262262
{
263263
if (ignore_errors)
264264
{
265-
errmsg = psprintf("%s%d:Command %s failed: %s", errmsg ? errmsg : "", node_id, sql, PQerrorMessage(conn[i]));
265+
errmsg = psprintf("%s%d:Command %s failed: %s", errmsg ? errmsg : "", node_id, sql_full, PQerrorMessage(conn[i]));
266266
PQclear(res);
267267
continue;
268268
}
269-
errmsg = psprintf("Command %s failed at node %d: %s", sql, node_id, PQerrorMessage(conn[i]));
269+
errmsg = psprintf("Command %s failed at node %d: %s", sql_full, node_id, PQerrorMessage(conn[i]));
270270
PQclear(res);
271271
goto cleanup;
272272
}
@@ -277,11 +277,11 @@ broadcast(PG_FUNCTION_ARGS)
277277
if (ignore_errors)
278278
{
279279
appendStringInfoString(&resp, "?;");
280-
elog(WARNING, "SHARDMAN: Query '%s' doesn't return single tuple at node %d", sql, node_id);
280+
elog(WARNING, "SHARDMAN: Query '%s' doesn't return single tuple at node %d", sql_full, node_id);
281281
}
282282
else
283283
{
284-
errmsg = psprintf("Query '%s' doesn't return single tuple at node %d", sql, node_id);
284+
errmsg = psprintf("Query '%s' doesn't return single tuple at node %d", sql_full, node_id);
285285
PQclear(res);
286286
goto cleanup;
287287
}
@@ -384,7 +384,7 @@ gen_create_table_sql(PG_FUNCTION_ARGS)
384384
join_path_components(pg_dump_path, pg_dump_path, "pg_dump");
385385
canonicalize_path(pg_dump_path);
386386

387-
cmd = psprintf("%s -t '%s' --schema-only --dbname='%s' 2>&1",
387+
cmd = psprintf("%s -t '%s' --no-owner --schema-only --dbname='%s' 2>&1",
388388
pg_dump_path, relation, shardlord_connstring);
389389

390390
if ((fp = popen(cmd, "r")) == NULL)

0 commit comments

Comments
 (0)