postgresql – logical worker replication says the publication does not exist, however this seems to actually exist?

I’m trying to setup logical replication between two database instances.

I’ve created a publication on the main db, and a subscription on the replica. Specifically:

on main db:

create publication chris for all tables; 

on replica db:

CREATE SUBSCRIPTION chris
    CONNECTION 'host=localhost port=5540 dbname=finder connect_timeout=10'
    PUBLICATION chris;

However for some reason the replica does not seem to be recognizing the publication (essentially ERROR: could not receive data from WAL stream: ERROR: publication "chris" does not exist) (logs from the replica):

Oct 20 18:18:31 test2 8y7qb8wz8ps875yrvpmg9c1zsffls4hy-unit-script-postgresql-start(289): 2020-10-20 18:18:31.013 GMT (289) LOG:  background worker "logical replication worker" (PID 3035) exited with exit code 1
Oct 20 18:18:36 test2 8y7qb8wz8ps875yrvpmg9c1zsffls4hy-unit-script-postgresql-start(289): 2020-10-20 18:18:36.020 GMT (3036) LOG:  logical replication apply worker for subscription "chris" has started
Oct 20 18:18:36 test2 8y7qb8wz8ps875yrvpmg9c1zsffls4hy-unit-script-postgresql-start(289): 2020-10-20 18:18:36.022 GMT (3036) ERROR:  could not receive data from WAL stream: ERROR:  publication "chris" does not exist
Oct 20 18:18:36 test2 8y7qb8wz8ps875yrvpmg9c1zsffls4hy-unit-script-postgresql-start(289):         CONTEXT:  slot "chris", output plugin "pgoutput", in the change callback, associated LSN 0/6BA6EC8
Oct 20 18:18:36 test2 8y7qb8wz8ps875yrvpmg9c1zsffls4hy-unit-script-postgresql-start(289): 2020-10-20 18:18:36.023 GMT (289) LOG:  background worker "logical replication worker" (PID 3036) exited with exit code 1
Oct 20 18:18:41 test2 8y7qb8wz8ps875yrvpmg9c1zsffls4hy-unit-script-postgresql-start(289): 2020-10-20 18:18:41.030 GMT (3039) LOG:  logical replication apply worker for subscription "chris" has started
Oct 20 18:18:41 test2 8y7qb8wz8ps875yrvpmg9c1zsffls4hy-unit-script-postgresql-start(289): 2020-10-20 18:18:41.033 GMT (3039) ERROR:  could not receive data from WAL stream: ERROR:  publication "chris" does not exist
Oct 20 18:18:41 test2 8y7qb8wz8ps875yrvpmg9c1zsffls4hy-unit-script-postgresql-start(289):         CONTEXT:  slot "chris", output plugin "pgoutput", in the change callback, associated LSN 0/6BA6EC8
Oct 20 18:18:41 test2 8y7qb8wz8ps875yrvpmg9c1zsffls4hy-unit-script-postgresql-start(289): 2020-10-20 18:18:41.034 GMT (289) LOG:  background worker "logical replication worker" (PID 3039) exited with exit code 1

The main db’s logs strangely seems to also be showing the same error (ERROR: publication "chris" does not exist):

Oct 20 18:22:56 pgtestpublic 22rj0nr8pn1k0r3q8q6pxixp6hn2zi4i-unit-script-postgresql-start(260): 2020-10-20 18:22:56.545 GMT (514) CONTEXT:  slot "chris", output plugin "pgoutput", in the change callback, associated LSN >
Oct 20 18:23:01 pgtestpublic 22rj0nr8pn1k0r3q8q6pxixp6hn2zi4i-unit-script-postgresql-start(260): 2020-10-20 18:23:01.555 GMT (515) LOG:  starting logical decoding for slot "chris"
Oct 20 18:23:01 pgtestpublic 22rj0nr8pn1k0r3q8q6pxixp6hn2zi4i-unit-script-postgresql-start(260): 2020-10-20 18:23:01.555 GMT (515) DETAIL:  Streaming transactions committing after 0/6BA6E60, reading WAL from 0/6BA6E28.
Oct 20 18:23:01 pgtestpublic 22rj0nr8pn1k0r3q8q6pxixp6hn2zi4i-unit-script-postgresql-start(260): 2020-10-20 18:23:01.555 GMT (515) LOG:  logical decoding found consistent point at 0/6BA6E28
Oct 20 18:23:01 pgtestpublic 22rj0nr8pn1k0r3q8q6pxixp6hn2zi4i-unit-script-postgresql-start(260): 2020-10-20 18:23:01.555 GMT (515) DETAIL:  There are no running transactions.
Oct 20 18:23:01 pgtestpublic 22rj0nr8pn1k0r3q8q6pxixp6hn2zi4i-unit-script-postgresql-start(260): 2020-10-20 18:23:01.556 GMT (515) ERROR:  publication "chris" does not exist
Oct 20 18:23:01 pgtestpublic 22rj0nr8pn1k0r3q8q6pxixp6hn2zi4i-unit-script-postgresql-start(260): 2020-10-20 18:23:01.556 GMT (515) CONTEXT:  slot "chris", output plugin "pgoutput", in the change callback, associated LSN >
Oct 20 18:23:06 pgtestpublic 22rj0nr8pn1k0r3q8q6pxixp6hn2zi4i-unit-script-postgresql-start(260): 2020-10-20 18:23:06.566 GMT (518) LOG:  starting logical decoding for slot "chris"
Oct 20 18:23:06 pgtestpublic 22rj0nr8pn1k0r3q8q6pxixp6hn2zi4i-unit-script-postgresql-start(260): 2020-10-20 18:23:06.566 GMT (518) DETAIL:  Streaming transactions committing after 0/6BA6E60, reading WAL from 0/6BA6E28.
Oct 20 18:23:06 pgtestpublic 22rj0nr8pn1k0r3q8q6pxixp6hn2zi4i-unit-script-postgresql-start(260): 2020-10-20 18:23:06.566 GMT (518) LOG:  logical decoding found consistent point at 0/6BA6E28

However I do see the correct expected output from:

select * from pg_catalog.pg_publication;
select * from pg_catalog.pg_publication;

on the main database.

What could I investigate further? And what may likely be the cause of the error?

asp.net web api – .NET Core Dependency Injection – Worker Service x Web Api

Folks,

I have a big question about how .NET dependency injection native works on a Service Worker project.

We need to resolve a service(Scoped:IMyRepository) on constructor of an MediatR Handler, but we have an error at runtime, please see:

(Shared.csproj)

Repository Folder

using System;

namespace Shared.Repository
{
    public interface IMyRepository
    {
        void Add();   
    }

    public class MyRepository : IMyRepository
    {
        public void Add()
        {
            throw new NotImplementedException();
        }
    }
}

MediatR Folder

using MediatR;
using System.Threading;
using Shared.Repository;
using System.Threading.Tasks;

namespace Shared.MediatR
{
    public class PingQuery : IRequest<string> { }

    public class PingQueryHandler : IRequestHandler<PingQuery, string>
    {
        readonly IMyRepository _myRepository;

        public PingQueryHandler(IMyRepository myRepository)
        {
            _myRepository = myRepository;
        }

        public Task<string> Handle(PingQuery request, CancellationToken cancellationToken)
        {
            return Task.FromResult("Pong");
        }
    }
}

(WorkerService.csproj)

WorkerService.cs

using MediatR;
using Shared.MediatR;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

namespace WorkerService
{
    public class Worker : BackgroundService
    {
        readonly IMediator _mediator;
        readonly ILogger<Worker> _logger;
        
        public Worker(ILogger<Worker> logger, IMediator mediator)
        {
            _logger = logger;
            _mediator = mediator;
        }

        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            while (!stoppingToken.IsCancellationRequested)
            {
                var result = await _mediator.Send(new PingQuery());

                _logger.LogInformation("MediatR result: {result}", result);

                await Task.Delay(1000, stoppingToken);
            }
        }
    }
}

Program.cs

using MediatR;
using Shared.MediatR;
using Shared.Repository;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.DependencyInjection;

namespace WorkerService
{
    public class Program
    {
        public static void Main(string() args)
        {
            CreateHostBuilder(args).Build().Run();
        }

        public static IHostBuilder CreateHostBuilder(string() args) =>
            Host.CreateDefaultBuilder(args)
                .ConfigureServices((hostContext, services) =>
                {
                    services.AddMediatR(typeof(PingQuery));
                    services.AddScoped<IMyRepository, MyRepository>();

                    services.AddHostedService<Worker>(); <- Singleton Resolution
                });
    }
}

With this configuration, we got the following error:

(Exception Unhandled)
System.InvalidOperationException: ‘Error constructing handler for request of type
MediatR.IRequestHandler`2(Shared.MediatR.PingQuery,System.String). Register your handlers with the
container. See the samples in GitHub for examples.’

(Inner Exception)
InvalidOperationException: Cannot resolve
‘MediatR.IRequestHandler`2(Shared.MediatR.PingQuery,System.String)’ from root provider because it
requires scoped service ‘Shared.Repository.IMyRepository’.

Worker ServiceCollection

And now comes the other part of the question. If we make this same “configuration” on a Web Application project, the D.I can solve (Scoped:IMyRepository).

Like:

(WebApi.csproj)

Program.cs (I decided resolve the dependencies(MediatR, IMyRepository) in this class, just to give a closer look to the “Worker Service” D.I resolution)

using MediatR;
using Shared.MediatR;
using Shared.Repository;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.DependencyInjection;

namespace WebApi
{
    public class Program
    {
        public static void Main(string() args)
        {
            CreateHostBuilder(args).Build().Run();
        }

        public static IHostBuilder CreateHostBuilder(string() args) =>
            Host.CreateDefaultBuilder(args)
                .ConfigureServices((hostContext, services) => 
                {
                    services.AddMediatR(typeof(PingQuery));
                    services.AddScoped<IMyRepository, MyRepository>();
                })
                .ConfigureWebHostDefaults(webBuilder =>
                {
                    webBuilder.UseStartup<Startup>();
                });
    }
}

Startup.cs

using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

namespace WebApi
{
    public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        public IConfiguration Configuration { get; }

        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();
        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            /*Omitted for brevity*/
        }
    }
}

Web Application ServiceCollection

WeatherForecastController.cs

using MediatR;
using Shared.MediatR;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;

namespace WebApi.Controllers
{
    (ApiController)
    (Route("(controller)"))
    public class WeatherForecastController : ControllerBase
    {
        readonly IMediator _mediator;
        
        public WeatherForecastController(IMediator mediator)
        {
            _mediator = mediator;
        }

        (HttpGet)
        public async Task<string> Get()
        {
            return await _mediator.Send(new PingQuery());
        }
    }
}

When we call the HttpGet of the Controller above, the D.I has been resolved on PingQueryHandler:

PingQueryHandler D.I solved

Why? I looked for similar cases, and most likely it involves the way the Worker Service solves the D.I (without creating scope), as mentioned here, and Jimmy Bogard(MediatR) mentions that MediatR needs the dependencies resolved in a scope here.

Is there a way to resolve this? Does anyone know the reason for the difference in dependecy injection between project types?

The solution would be to inject IServiceScopeFactory to solve my dependency, like mentioned on this S.O answer? I don’t know if this applies to a Service Worker too…

I’m a little confused now, and I would like to understand how things work, any help is welcome 🙂

Can two miners enter the pool under one worker?

I know that most pools allow multiple connections under one worker, does it work for Hashalot

Feature detect ES module from Service Worker

I’m trying to detect if the browser supports es modules import from a Service Worker.

To be clear, I’m not trying to import es modules from the SW, I’m trying to programatically detect from the SW if the browser can import es modules scripts.

I’ve tried using 'noModule' in HTMLScriptElement.prototype or document.currentScript && "noModule" in document.currentScript; but both HTMLScriptElement and document are undefined in the SW context.

Is there a way to do that which does not involve sending a message to the worker ?

How to change the security group of Amazon EKS worker nodes?

I want to add a security group to the worker nodes of Amazon EKS.

It seems that I can change “Additional security group” to add the security group to the worker nodes.

enter image description here

But I cannot find any way to modify “Additional security group” in AWS console.

Does anyone know how to add security groups to the worker nodes?

web browser – Are web worker / service worker secure environments to store a password, credit card information, access tokens?

If there is a case where I wish to store sensitive data like a password, credit card information, or access tokens:

Are web workers / service workers a secure environment, where such data can not be compromised?
If so, what to do to really secure it?
If not so, why not exactly?

IIS 10 not showing worker process Current Requests

I have enabled Monitor and Tracing by adding Windows Server 2016 Roles. But IIS not showing me worker process Current Requests when I request a webpage
enter image description here

How can I view current requests coming in IIS for App pool?

[ Biology ] Open Question : Are worker ants allowed to unionize?

[ Biology ] Open Question : Are worker ants allowed to unionize?

macos – What is Safari Service worker ? Would disabling it affect website performance?

For the past three days, I have seen Outlook and Twitter service workers trigger randomly, even if I never opened those sites in non-private mode. They consume 2 cores and distract me. Then I force quit them.

Before applying the solution in

I need to know

  • Why websites use it?
  • What would be the impact if I disable all of them ? (I’f prefer if I can handle it on case by case basis)

dock worker using btrfs on lvm2 support

I modified my synology DS918 (DSM 6.2.2-24922 Update 4) to run docker-19.03.8. Unfortunately while the main medium /volume1 is btrfs and docker supports btrfs as a storage driver it

requires a dedicated bulk storage device such as a physical disk

Synology uses LVM2 by default (I think) below:

root@nas1:~# docker info 2> /dev/null | grep -i root
 Docker Root Dir: /volume1/@docker
root@nas1:~# mount | grep ' /volume1 '
/dev/mapper/vg1-volume_1 on /volume1 type btrfs (rw,relatime,synoacl,space_cache=v2,auto_reclaim_space,metadata_ratio=50,subvolid=257,subvol=/@syno)

I cannot shoot images, for this reason (using traefik as an example, this is universal):

root@nas1:~# docker pull traefik:v2.2
v2.2: Pulling from library/traefik
aad63a933944: Pull complete
f365f1b91ebb: Extracting (==================================================>)  694.1kB/694.1kB
dc367a6045f5: Download complete
ff697159d003: Download complete
failed to register layer: Failed to create btrfs snapshot: inappropriate ioctl for device

which suggests that the underlying problem concerns btrfs snapshots / sub-volumes (although I don't know much about how to use or manipulate them).

Questions:

  1. Can docker be made to work with btrfs-on-lvm2? I tried to change to "storage-driver":"devicemapper" (and "overlay2"), no luck (dockerd does not start). Nothing else in the docker documents – this suggests other mechanisms.

  2. Is there a way to mount Synology /volume1 on a non LVM2 partition? It is mirrored (RAID-1) of 8 TB with exported shares.