fix: harden multi-instance scheduler and worker execution

This commit is contained in:
dahyeon committed 2026-06-27 13:19:43 -07:00
1 parent df7dcd3a9c
commit 60a006008a
23 files changed
+1442 -299

No files matched your search

@@ -392,6 +392,8 @@ export interface DakaoOutboxMessage extends MongooseTimestamps {
payload: Record<string, unknown>;
state: DakaoOutboxMessageState;
publishAttempts: number;
publishLeaseOwnerIdentifier?: string;
publishLeaseExpiresAt?: Date;
publishedAt?: Date;
terminalAt?: Date;
resultEventId?: string;
@@ -733,6 +735,7 @@ export interface LegacyImportJob extends MongooseTimestamps {
totalSkippedDuplicate: number;
totalErrors: number;
averageMemberSeconds?: number;
completedMemberJobIds: string[];
errors?: LegacyImportJobError[];
}
@@ -1282,6 +1285,8 @@ export const DakaoOutboxMessageSchema = new Schema<DakaoOutboxMessage>(
default: 'pending',
},
publishAttempts: { type: Number, required: true, default: 0 },
publishLeaseOwnerIdentifier: { type: String },
publishLeaseExpiresAt: { type: Date },
publishedAt: { type: Date },
terminalAt: { type: Date },
resultEventId: { type: String },
@@ -1302,6 +1307,11 @@ export const DakaoOutboxMessageSchema = new Schema<DakaoOutboxMessage>(
);
DakaoOutboxMessageSchema.index({ state: 1, updatedAt: 1 });
DakaoOutboxMessageSchema.index({
state: 1,
publishLeaseExpiresAt: 1,
updatedAt: 1,
});
DakaoOutboxMessageSchema.index({ correlationId: 1 }, { sparse: true });
export const DakaoSendResultEventSchema = new Schema<DakaoSendResultEvent>(
@@ -1988,6 +1998,11 @@ export const LegacyImportJobSchema = new Schema<LegacyImportJob>(
totalSkippedDuplicate: { type: Number, required: true, default: 0 },
totalErrors: { type: Number, required: true, default: 0 },
averageMemberSeconds: { type: Number },
completedMemberJobIds: {
type: [String],
required: true,
default: [],
},
errors: {
type: [LegacyImportJobErrorSubSchema],
required: true,
@@ -2003,6 +2018,7 @@ export const LegacyImportJobSchema = new Schema<LegacyImportJob>(
LegacyImportJobSchema.index({ communityId: 1, startedAt: -1 });
LegacyImportJobSchema.index({ communityId: 1, state: 1 });
LegacyImportJobSchema.index({ jobId: 1, completedMemberJobIds: 1 });
const AuctionPlayerSnapshotSubSchema = new Schema<AuctionPlayerSnapshot>(
{