Some comments about our new atexit handling.
This commit is contained in:
parent
b6b6a8bfb3
commit
8fc8b656a2
@ -243,6 +243,12 @@ static char *
|
|||||||
utoa(unsigned int value, char *buffer)
|
utoa(unsigned int value, char *buffer)
|
||||||
{
|
{
|
||||||
sprintf(buffer, "%u", value);
|
sprintf(buffer, "%u", value);
|
||||||
|
/* XXX: originally, we would just return buffer here without
|
||||||
|
* the pgut_strdup(). But repack_cleanup_callback() seems to
|
||||||
|
* depend on getting back a freshly strdup'd copy of buffer,
|
||||||
|
* not sure why. So now we are leaking a tiny bit of memory
|
||||||
|
* with each utoa() call.
|
||||||
|
*/
|
||||||
return pgut_strdup(buffer);
|
return pgut_strdup(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -900,6 +906,13 @@ rebuild_indexes(const repack_table *table)
|
|||||||
|
|
||||||
ret = select(max_fd + 1, &input_mask, NULL, NULL, &timeout);
|
ret = select(max_fd + 1, &input_mask, NULL, NULL, &timeout);
|
||||||
#endif
|
#endif
|
||||||
|
/* XXX: the errno != EINTR check means we won't bail
|
||||||
|
* out on SIGINT. We should probably just remove this
|
||||||
|
* check, though it seems we also need to fix up
|
||||||
|
* the on_interrupt handling for workers' index
|
||||||
|
* builds (those PGconns don't seem to have c->cancel
|
||||||
|
* set, so we don't cancel the in-progress builds).
|
||||||
|
*/
|
||||||
if (ret < 0 && errno != EINTR)
|
if (ret < 0 && errno != EINTR)
|
||||||
elog(ERROR, "poll() failed: %d, %d", ret, errno);
|
elog(ERROR, "poll() failed: %d, %d", ret, errno);
|
||||||
|
|
||||||
@ -1705,6 +1718,10 @@ repack_cleanup_callback(bool fatal, void *userdata)
|
|||||||
params[0] = utoa(target_table, buffer);
|
params[0] = utoa(target_table, buffer);
|
||||||
params[1] = utoa(temp_obj_num, buffer);
|
params[1] = utoa(temp_obj_num, buffer);
|
||||||
|
|
||||||
|
/* testing PQstatus() of connection and conn2, as we do
|
||||||
|
* in repack_cleanup(), doesn't seem to work here,
|
||||||
|
* so just use an unconditional reconnect().
|
||||||
|
*/
|
||||||
reconnect(ERROR);
|
reconnect(ERROR);
|
||||||
command("SELECT repack.repack_drop($1, $2)", 2, params);
|
command("SELECT repack.repack_drop($1, $2)", 2, params);
|
||||||
temp_obj_num = 0; /* reset temporary object counter after cleanup */
|
temp_obj_num = 0; /* reset temporary object counter after cleanup */
|
||||||
|
13
lib/repack.c
13
lib/repack.c
@ -944,8 +944,11 @@ repack_drop(PG_FUNCTION_ARGS)
|
|||||||
/* connect to SPI manager */
|
/* connect to SPI manager */
|
||||||
repack_init();
|
repack_init();
|
||||||
|
|
||||||
/* drop log table */
|
/* drop log table: must be done before dropping the pk type,
|
||||||
if(numobj > 0)
|
* since the log table is dependent on the pk type. (That's
|
||||||
|
* why we check numobj > 1 here.)
|
||||||
|
*/
|
||||||
|
if (numobj > 1)
|
||||||
{
|
{
|
||||||
execute_with_format(
|
execute_with_format(
|
||||||
SPI_OK_UTILITY,
|
SPI_OK_UTILITY,
|
||||||
@ -955,7 +958,7 @@ repack_drop(PG_FUNCTION_ARGS)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* drop type for pk type */
|
/* drop type for pk type */
|
||||||
if(numobj > 0)
|
if (numobj > 0)
|
||||||
{
|
{
|
||||||
execute_with_format(
|
execute_with_format(
|
||||||
SPI_OK_UTILITY,
|
SPI_OK_UTILITY,
|
||||||
@ -968,7 +971,7 @@ repack_drop(PG_FUNCTION_ARGS)
|
|||||||
* drop repack trigger: We have already dropped the trigger in normal
|
* drop repack trigger: We have already dropped the trigger in normal
|
||||||
* cases, but it can be left on error.
|
* cases, but it can be left on error.
|
||||||
*/
|
*/
|
||||||
if(numobj > 0)
|
if (numobj > 0)
|
||||||
{
|
{
|
||||||
execute_with_format(
|
execute_with_format(
|
||||||
SPI_OK_UTILITY,
|
SPI_OK_UTILITY,
|
||||||
@ -991,7 +994,7 @@ repack_drop(PG_FUNCTION_ARGS)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* drop temp table */
|
/* drop temp table */
|
||||||
if(numobj > 0)
|
if (numobj > 0)
|
||||||
{
|
{
|
||||||
execute_with_format(
|
execute_with_format(
|
||||||
SPI_OK_UTILITY,
|
SPI_OK_UTILITY,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user